Skip to content

Instantly share code, notes, and snippets.

@jpda
Created March 27, 2018 21:48
Show Gist options
  • Select an option

  • Save jpda/b34a852f1b7575cc98203d5d4c359078 to your computer and use it in GitHub Desktop.

Select an option

Save jpda/b34a852f1b7575cc98203d5d4c359078 to your computer and use it in GitHub Desktop.
add MSI service principal to approle
# you may not need tenantId, but if it is ambiguous you should set it here
Connect-AzureAd -TenantId
# name of your MSI service principal, in my case msi-func. You can also get the ID from Enterprise Applications in AAD (not App Reg)
$msifunc = Get-AzureADServicePrincipal -SearchString "msi-func"
# name of your AAD service principal, in my case aad-func. You can also get the ID from App Registrations in AAD
$aadapp = Get-AzureADServicePrincipal -SearchString "aad-func"
# Id - the ID of the role. You can get it from the app's manifest
# PrincipalId - the object ID of the MSI principal
# ObjectId - the object ID of the MSI principal
# ResourceId - the object ID of the AAD app
New-AzureADServiceAppRoleAssignment -Id $aadapp.AppRoles[0].Id -PrincipalId $msifunc.ObjectId -ObjectId $msifunc.ObjectId -ResourceId $aadapp.ObjectId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment