Complete the code to assign a system-assigned managed identity to an Azure VM.
az vm create --name myVM --resource-group myResourceGroup --image UbuntuLTS --assign-identity [1]Setting --assign-identity true enables a system-assigned managed identity for the VM.
Complete the code to assign a user-assigned managed identity to an Azure VM.
az vm identity assign --resource-group myResourceGroup --name myVM --identities [1]For user-assigned managed identities, you specify the full resource ID of the identity.
Fix the error in the code to retrieve an access token for a managed identity in Azure CLI.
az account get-access-token --resource [1]The correct resource URI for Azure management API is https://management.azure.com/.
Fill both blanks to create a user-assigned managed identity and assign it to a VM.
az identity create --name [1] --resource-group myResourceGroup az vm identity assign --resource-group myResourceGroup --name myVM --identities [2]
You first create the identity with a name, then assign it using its full resource ID.
Fill all three blanks to assign a system-assigned identity, grant it Reader role on a storage account, and retrieve its principal ID.
az vm identity assign --resource-group myResourceGroup --name myVM --identities [1] az role assignment create --assignee [2] --role Reader --scope /subscriptions/xxxx/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount az vm show --resource-group myResourceGroup --name myVM --query identity.principalId -o tsv
Enable system-assigned identity with 'true', then use the principalId from the VM to assign role and retrieve it.