Below is the scenario: We have a User Assigned Managed Identity in Resource Group 'A' and we are creating a new Resource Group 'B' and want to add MSI from Resource Group A to be B.
How can we achieve this via Azure CLI?
Below is the scenario: We have a User Assigned Managed Identity in Resource Group 'A' and we are creating a new Resource Group 'B' and want to add MSI from Resource Group A to be B.
How can we achieve this via Azure CLI?
You could use az identity list -g '<resource group name>'
to get the id
, then use the command below, the id
means the User Assigned Managed Identity resource id, it works fine on my side.
az resource move --destination-group '<destination resource group>' --ids '<User Assigned Managed Identity resource id >'
Update:
az role assignment create --resource-group '<resourcegroupname>' --role 'Contributor' --assignee '<service principal objectId>'
Check in the portal:
Besides, you could find the ObjectId in Azure Active Directory -> Enterprise applications(All applications), just search for your User Assigned Managed Identity name.
This tutorial step shows how to grant permissions to a user assigned managed identity, via CLI: https://learn.microsoft.com/en-us/azure/active-directory/managed-service-identity/msi-tutorial-linux-vm-access-arm#grant-your-user-assigned-identity-access-to-a-resource-group-in-azure-resource-manager