-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User Assigned Managed Identity: Insufficient privileges to complete the operation #2552
Comments
Get-MgContext output: 2024-01-31T15:00:41Z [Information] OUTPUT: Scopes : The scopes part is empty. I cannot add the -Scopes parameter to the Connect-MGGraph cmdlet when using managed identity. I suspect that is part of the issue. |
Have you added the API permissions to the Managed Identity? You can check in the Entra ID portal under Enterprise Applications (specifically the Permissions blade) If you haven't, then you'll need to use New-MgServicePrincipalAppRoleAssignment to assign permissions. If you haven't done that before, reply here - I've got a function which might be of use. |
@SeniorConsulting I'm fiddling with SPN permissions in another context and would certainly like to see what that function could do for my project. |
Yes I did that. I added all the permissions that were output by the (Find-MgGraphCommand -Command get-mguser).permissions using the following script:
The permissions are displayed on the permissions tab in the enterprise application. As a means of troubleshooting, I also had the function app output a token using the Get-AzAccessToken and using that to connect using Connect-MgGraph -AccessToken $secureToken. Connection is succesful, but same error when trying to run any command I should be able to. When I inspect the token, it also has no scopes. |
I just redeployed everything (my function app + associated resources and the user assigned managed identity) and now it's working. No idea what was wrong since I triple checked that the correct managed identity was associated and the permissions were set, and confirmed the managed identity ID by the Get-MgContext command but at least it's working again. @salbeck-sit you can refer to my previous comment for the commands to set the permissions. Make sure to replace the values in the $graphPermissions array (and to not paste the permissions twice like I did). You should probably move the $managedIdentity = (Get-AzADServicePrincipal -Filter "displayName eq '$uamiDisplayname'") outside of the foreach loop as well, as it doesn't really make sense for it to be in the loop. |
When using a user assigned managed identity in a function app, I get an insufficient privileges error on all commands. I have the appropriate permissions (such as user.read.all) set up on the Enterprise Application representing my user assigned managed identity.
The connection is succesful, as I see the welcome message.
To Reproduce
Expected behavior
Output the desig
Debug Output
Module Version
2.12.0
PSVersionTable
Name Value
PSVersion 7.2.13
PSEdition Core
GitCommitId 7.2.13
OS Microsoft Windows 10.0.14393
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Environment Data
The text was updated successfully, but these errors were encountered: