CmdID

CmdID / az / az policy / az policy assignment / az policy assignment identity

az policy assignment identity assign

Assign a managed identity. Azure CLI reference

Assign the system or user assigned managed identity to the policy assignment matching the given name and scope.

3 examples 3 options Its page in the Azure CLI reference

Opens CmdID with your command. It is read in your browser and sent nowhere.

Examples

from the Azure CLI, each command read by CmdID

Add a system assigned managed identity to a policy assignment

az policy assignment identity assign --system-assigned -g MyResourceGroup -n MyPolicyAssignmentIdentify
--system-assignedSet the system managed identity.
-gName of resource group.

Add a system assigned managed identity to a policy assignment and grant it the Contributor role for a resource group

az policy assignment identity assign --system-assigned -g MyResourceGroup -n MyPolicyAssignment --role Contributor --identity-scope /subscriptions/{subscriptionId}/resourceGroups/MyResourceGroupIdentify
--system-assignedSet the system managed identity.
-gName of resource group.

Add a user assigned managed identity to a policy assignment

az policy assignment identity assign --user-assigned MyAssignedId -g MyResourceGroup -n MyPolicyAssignmentIdentify
--user-assignedSet the user managed identity.
-gName of resource group.

Options

3 in the Azure CLI reference
--mi-system-assigned, --system-assignedSet the system managed identity.
--mi-user-assigned, --user-assignedSet the user managed identity.
--scope, --name, -n