azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Update-AzADServicePrincipal -IdentifierUri will not accept an empty string @('') as in older versions

Open timpoth opened this issue 3 years ago • 2 comments

Description

For multitenant auth the identifierURI needs to be blank for an App. In the azure portal this can be done on the Expose an API tab and deleting the URI at the top of the page. In older versions of AZ Module we could pass in an empty string, @() however this no longer works. EG: Update-AzADServicePrincipal -ApplicationId '111-111-111-111-111111' -IdentifierUri @() (returned error) Set-AzureADApplication : Error occurred while executing SetApplication Code: Request_BadRequest Message: The URI scheme in property identifierUris is invalid or unsupported.

We were able to work around this by using set-AzureADApplication but it would be really nice to not have to swap between modules. EG: Set-AzureADApplication -ObjectId '222-222-222-2222-222222' -IdentifierUri @()

Issue script & Debug output

Update-AzADServicePrincipal -ApplicationId '111-111-111-111-111111' -IdentifierUri @()
(returned error)
Set-AzureADApplication : Error occurred while executing SetApplication 
Code: Request_BadRequest
Message: The URI scheme in property identifierUris is invalid or unsupported.

Environment data

Name                           Value                                                                                                                                                      
----                           -----                                                                                                                                                      
PSVersion                      5.1.22000.1335                                                                                                                                             
PSEdition                      Desktop                                                                                                                                                    
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                    
BuildVersion                   10.0.22000.1335                                                                                                                                            
CLRVersion                     4.0.30319.42000                                                                                                                                            
WSManStackVersion              3.0                                                                                                                                                        
PSRemotingProtocolVersion      2.3                                                                                                                                                        
SerializationVersion           1.1.0.1

Module versions

ModuleType Version    Name                                ExportedCommands                                                                                                                
---------- -------    ----                                ----------------                                                                                                                
Script     2.12.1     Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}                                                        
Script     6.5.3      Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment...}                                      
Binary     2.0.2.76   AzureAD                             {Add-AzureADApplicationOwner, Add-AzureADDeviceRegisteredOwner, Add-AzureADDeviceRegisteredUser, Add-AzureADDirectoryRoleMemb...

Error output

Message        : A parameter cannot be found that matches parameter name 'IdentifierUri'.
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.ParameterBindingException
InvocationInfo : {Update-AzADServicePrincipal}
Line           :     $sp=Az.MSGraph.internal\Update-AzADServicePrincipal @PSBoundParameters
                 
Position       : At C:\Program Files\WindowsPowerShell\Modules\Az.Resources\6.5.3\MSGraph.Autorest\custom\Update-AzADServicePrincipal.ps1:631 char:57
                 + ... sp=Az.MSGraph.internal\Update-AzADServicePrincipal @PSBoundParameters
                 +                                                        ~~~~~~~~~~~~~~~~~~

timpoth avatar Mar 27 '23 13:03 timpoth

Thanks for reporting! @VeryEarly could you look into this? Thanks.

isra-fel avatar Mar 28 '23 09:03 isra-fel

Hi @timpoth ,

Thanks for reporting, this is indeed a bug in our code, will be fixed and published on 2023-05-23.

VeryEarly avatar Apr 26 '23 02:04 VeryEarly