[Azure Stack] ADFS : New-AzureRmRoleAssignment fails with 'The provided information does not map to an AD object id'
Description
The following command New-AzureRmRoleAssignment -ApplicationId $ServicePrincipal.ApplicationIdentifier -RoleDefinitionName Contributor
fails with
New-AzureRmRoleAssignment : The provided information does not map to an AD object id. At line:1 char:1 New-AzureRmRoleAssignment -ApplicationId $ServicePrincipal.Applicatio CategoryInfo : CloseError: (:) [New-AzureRmRoleAssignment], KeyNotFoundException FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand
Script/Steps for Reproduction
pass in the $creds
$session = New-PSSession -ComputerName Azs-ERCS01 -ConfigurationName PrivilegedEndpoint -Credential $creds
$cert = New-SelfSignedCertificate -CertStoreLocation "cert:\CurrentUser\My" -Subject "CN=BalaApp2" -KeySpec KeyExchange
$ServicePrincipal = Invoke-Command -Session $session -ScriptBlock { New-GraphApplication -Name 'BalaApp2' -ClientCertificates $using:cert}
$AzureStackInfo = Invoke-Command -Session $session -ScriptBlock { get-azurestackstampinformation }
$session|remove-pssession
$ServicePrincipal
New-AzureRmRoleAssignment -ApplicationId $ServicePrincipal.ApplicationIdentifier -RoleDefinitionName Contributor
Module Version
AzureRM.Resources - 6.0.2 AzureRM - 2.3.0
Work Around
Using the ClientId for the -ApplicationId parameter work. The namings are confusing.
New-AzureRmRoleAssignment -ApplicationId $ServicePrincipal.ClientId -RoleDefinitionName Contributor -Scope "/subscriptions/618083d8-5d85-4924-bcba-ff7b046e1460"
@bganapa Is this a bug or a feature request?
This is by design, and any changes will break Az.