Microsoft.Authorization policyAssignments

The policyAssignments resource type is an extension resource, which means you can apply it to another resource.

Use the scope property on this resource to set the scope for this resource.

Template format

To create a Microsoft.Authorization/policyAssignments resource, add the following Bicep or JSON to your template.

resource symbolicname 'Microsoft.Authorization/policyAssignments@2021-06-01' = {
  name: 'string'
  location: 'string'
  scope: scopeObject
  identity: {
    type: 'string'
    userAssignedIdentities: {}
  }
  properties: {
    description: 'string'
    displayName: 'string'
    enforcementMode: 'string'
    metadata: any()
    nonComplianceMessages: [
      {
        message: 'string'
        policyDefinitionReferenceId: 'string'
      }
    ]
    notScopes: [ 'string' ]
    parameters: {}
    policyDefinitionId: 'string'
  }
}

Property values

policyAssignments

Name Description Value
type The resource type

For Bicep, set this value in the resource declaration.
'Microsoft.Authorization/policyAssignments'
apiVersion The resource api version

For Bicep, set this value in the resource declaration.
'2021-06-01'
name The resource name string (required)
location The location of the policy assignment. Only required when utilizing managed identity. string
scope Use when creating an extension resource at a scope that is different than the deployment scope.

For Bicep, set this property to the symbolic name of the resource to apply the extension resource to. See Set scope for extension resources in Bicep.

For JSON, set the value to the full name of the resource to apply the extension resource to. See Setting scope on extension resources in ARM templates.
scopeObject
identity Identity for the resource. Policy assignments support a maximum of one identity. That is either a system assigned identity or a single user assigned identity. Identity
properties The policy assignment properties. PolicyAssignmentProperties

Identity

Name Description Value
type The identity type. This is the only required field when adding a system or user assigned identity to a resource. 'None'
'SystemAssigned'
'UserAssigned'
userAssignedIdentities The user identity associated with the policy. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. object

PolicyAssignmentProperties

Name Description Value
description This message will be part of response in case of policy violation. string
displayName The display name of the policy assignment. string
enforcementMode The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. 'Default'
'DoNotEnforce'
metadata Any object For Bicep, you can use the any() function.
nonComplianceMessages The messages that describe why a resource is non-compliant with the policy. NonComplianceMessage[]
notScopes The policy's excluded scopes. string[]
parameters The parameter values for the policy rule. The keys are the parameter names. object
policyDefinitionId The ID of the policy definition or policy set definition being assigned. string

NonComplianceMessage

Name Description Value
message A message that describes why a resource is non-compliant with the policy. This is shown in 'deny' error messages and on resource's non-compliant compliance results. string (required)
policyDefinitionReferenceId The policy definition reference ID within a policy set definition the message is intended for. This is only applicable if the policy assignment assigns a policy set definition. If this is not provided the message applies to all policies assigned by this policy assignment. string

Quickstart templates

The following quickstart templates deploy this resource type.

Template Description
Deploy a policy definition and assign to a management group

Deploy to Azure
This template is a management group level template that will create a policy definition and assign that policy to the target management group. Currently, this template cannot be deployed via the Azure Portal.
Deploy a Policy Def and Assign to Multiple Mgmt Groups

Deploy to Azure
This template is a management group level template that will create a policy definition and assign that policy to multiple management groups.
Assign a built-in policy to an existing resource group

Deploy to Azure
This template assigns a built-in policy to an existing resource group.