Azure / Azure/azure-powershell

New-AzAdAppCredential parameter CustomKeyIdentifier documentation states type [String], this must be a [Base64String]

Open
#26,108 1 comment 0 reactions 0 assignees View on GitHub
bug customer-reported needs-triage
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Description

New-AzAdAppCredential parameter CustomKeyIdentifier documentation states type [String], this must be a [Base64String]

### Issue script & Debug output

```PowerShell
$Secret = New-AzADAppCredential -StartDate $SecretStartDate -EndDate $SecretEndDate -ApplicationId $AppId -customKeyIdentifier $SecretName
New-AzADAppCredential: C:\Program Files\WindowsPowerShell\Modules\az.Resources\7.1.0\MSGraph.Autorest\exports\ProxyCmdletDefinitions.ps1:6403:23
Line |
6403 | $scriptCmd = {& $wrappedCmd @PSBoundParameters}
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "FromBase64String" with "1" argument(s): "The input is not a valid Base-64 string as it contains a non-base 64 character, more than
| two padding characters, or an illegal character among the padding characters."
```

### Environment data

```PowerShell
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.20348
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```

### Module versions

```PowerShell
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 3.0.0 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 4.3.1 az.desktopvirtualization {Disconnect-AzWvdUserSession, Expand-AzWvdMsixImage, Get-AzWvdApplication, Get-AzWvdAppli…Script 7.1.0 az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}
```

### Error output

```PowerShell
HistoryId: 6

Message : Exception calling "FromBase64String" with "1" argument(s): "The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters."
StackTrace : at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
at System.Management.Automation.PSScriptCmdlet.DoProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
Exception : System.Management.Automation.MethodInvocationException
InvocationInfo : {}
Line : $credential.CustomKeyIdentifier = [System.Convert]::FromBase64String($PSBoundParameters['CustomKeyIdentifier'])

Position : At C:\Program Files\WindowsPowerShell\Modules\az.Resources\7.1.0\MSGraph.Autorest\custom\New-AzADAppCredential.ps1:183 char:17
+ … $credential.CustomKeyIdentifier = [System.Convert]::FromB …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 6

Message : The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
StackTrace : at System.Convert.FromBase64String(String s)
at CallSite.Target(Closure, CallSite, Type, Object)
Exception : System.FormatException
InvocationInfo : {}
Line : $credential.CustomKeyIdentifier = [System.Convert]::FromBase64String($PSBoundParameters['CustomKeyIdentifier'])

Position : At C:\Program Files\WindowsPowerShell\Modules\az.Resources\7.1.0\MSGraph.Autorest\custom\New-AzADAppCredential.ps1:183 char:17
+ … $credential.CustomKeyIdentifier = [System.Convert]::FromB …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 6

HistoryId: 3

Message : [Service_InternalServerError] : Encountered an internal server error.
StackTrace :
Exception : System.Exception
InvocationInfo : {Add-AzADApplicationPassword_AddExpanded}
Line : $scriptCmd = {& $wrappedCmd @PSBoundParameters}

Position : At C:\Program Files\WindowsPowerShell\Modules\az.Resources\7.1.0\MSGraph.Autorest\internal\ProxyCmdletDefinitions.ps1:343 char:23
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 3

HistoryId: 1

Message : [Service_InternalServerError] : Encountered an internal server error.
StackTrace :
Exception : System.Exception
InvocationInfo : {Add-AzADApplicationPassword_AddExpanded}
Line : Az.MSGraph.internal\Add-AzADApplicationPassword @PSBoundParameters

Position : At C:\Program Files\WindowsPowerShell\Modules\az.Resources\7.1.0\MSGraph.Autorest\custom\New-AzADAppCredential.ps1:265 char:17
+ … Az.MSGraph.internal\Add-AzADApplicationPassword @PSBoundP …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 1

Message : You cannot call a method on a null-valued expression.
StackTrace : at CallSite.Target(Closure, CallSite, Object)
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception : System.Management.Automation.RuntimeException
InvocationInfo : {}
Line : [System.Diagnostics.DebuggerHidden()]param() $FoundAppRegistration = $DBAppRegistrationInfo | Where-Object { ($_.SupplierAppRegistration -eq $AzureAppRegistration.DisplayName -or $_.AppRegistration -eq $AzureAppRegistration.DisplayName) -and $_.TenantID.Trim() -eq $AzureAppRegistration.TenantID }
Position : At line:1 char:110
+ … re-Object { ($_.SupplierAppRegistration -eq $AzureAppRegistration.Dis …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 1

Message : The specified module 'SQLASCmdlets' was not loaded because no valid module file was found in any module directory.
StackTrace :
Exception : System.IO.FileNotFoundException
InvocationInfo : {Import-Module}
Line : Import-Module SQLASCmdlets -ErrorAction SilentlyContinue -Global

Position : At C:\Program Files (x86)\Microsoft SQL Server\160\Tools\PowerShell\Modules\SQLPS\SqlPsPostScript.ps1:18 char:1
+ Import-Module SQLASCmdlets -ErrorAction SilentlyContinue -Global
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 1

Message : No modules were removed. Verify that the specification of modules to remove is correct and those modules exist in the runspace.
StackTrace :
Exception : System.InvalidOperationException
InvocationInfo : {Remove-Module}
Line : Remove-Module NEHASR -ErrorAction SilentlyContinue

Position : At C:\NEHAutomation\Scripts\Azure\NEHASR\NEHAutomaticSecretRenewal.ps1:814 char:5
+ Remove-Module NEHASR -ErrorAction SilentlyContinue
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 1
```

Contributor guide

Open the contributing guide

Research direction

Start with custom/New-AzADAppCredential.ps1 at line 183 and compare the CustomKeyIdentifier parameter declaration with the generated entry in MSGraph.Autorest/exports/ProxyCmdletDefinitions.ps1. Check how the parameter type is presented in New-AzAdAppCredential documentation and how base64 input is handled. Done means the documented type matches the accepted input and the cmdlet behavior is covered by the repository's relevant tests, if present.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.