Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Microsoft.Authorization policyAssignments
Bicep resource definition
The policyAssignments resource type can be deployed with operations that target:
- Tenant - See tenant deployment commands* Management groups - See management group deployment commands* Subscription - See subscription deployment commands* Resource groups - See resource group deployment commands
For a list of changed properties in each API version, see change log.
Resource format
To create a Microsoft.Authorization/policyAssignments resource, add the following Bicep to your template.
resource symbolicname 'Microsoft.Authorization/policyAssignments@2026-06-01' = {
scope: resourceSymbolicName or scope
identity: {
type: 'string'
userAssignedIdentities: {
{customized property}: {}
}
}
location: 'string'
name: 'string'
properties: {
assignmentType: 'string'
definitionVersion: 'string'
description: 'string'
displayName: 'string'
enforcementMode: 'string'
metadata: any(...)
nonComplianceMessages: [
{
message: 'string'
policyDefinitionReferenceId: 'string'
}
]
notScopes: [
'string'
]
overrides: [
{
kind: 'string'
selectors: [
{
in: [
'string'
]
kind: 'string'
notIn: [
'string'
]
progress: int
}
]
value: 'string'
}
]
parameters: {
{customized property}: {
value: any(...)
}
}
policyDefinitionId: 'string'
resourceSelectors: [
{
name: 'string'
selectors: [
{
in: [
'string'
]
kind: 'string'
notIn: [
'string'
]
progress: int
}
]
}
]
selfServeExemptionSettings: {
enabled: bool
policyDefinitionReferenceIds: [
'string'
]
}
}
}
Property Values
Microsoft.Authorization/policyAssignments
| Name | Description | Value |
|---|---|---|
| identity | The managed identity associated with the policy assignment. | Identity |
| location | The location of the policy assignment. Only required when utilizing managed identity. | string |
| name | The resource name | string Constraints: Pattern = ^[^<>%&:\?/]*[^<>%&:\?/ ]+$ (required) |
| properties | Properties for the policy assignment. | PolicyAssignmentProperties |
| scope | Use when creating a resource at a scope that is different than the deployment scope. | Set this property to the symbolic name of a resource to apply the extension resource. |
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}'. | IdentityUserAssignedIdentities |
IdentityUserAssignedIdentities
| Name | Description | Value |
|---|
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 |
Override
| Name | Description | Value |
|---|---|---|
| kind | The override kind. | 'definitionVersion' 'policyEffect' |
| selectors | The list of the selector expressions. | Selector[] |
| value | The value to override the policy property. | string |
ParameterValuesValue
| Name | Description | Value |
|---|---|---|
| value | The value of the parameter. | any |
PolicyAssignmentProperties
| Name | Description | Value |
|---|---|---|
| assignmentType | The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. | 'Custom' 'NotSpecified' 'System' 'SystemHidden' |
| definitionVersion | The version of the policy definition to use. | string |
| 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, DoNotEnforce, and Enroll | 'Default' 'DoNotEnforce' 'Enroll' |
| metadata | The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. | any |
| nonComplianceMessages | The messages that describe why a resource is non-compliant with the policy. | NonComplianceMessage[] |
| notScopes | The policy's excluded scopes. | string[] |
| overrides | The policy property value override. | Override[] |
| parameters | The parameter values for the assigned policy rule. The keys are the parameter names. | PolicyAssignmentPropertiesParameters |
| policyDefinitionId | The ID of the policy definition or policy set definition being assigned. | string |
| resourceSelectors | The resource selector list to filter policies by resource properties. | ResourceSelector[] |
| selfServeExemptionSettings | The self-serve exemption settings for the policy assignment. | SelfServeExemptionSettings |
PolicyAssignmentPropertiesParameters
| Name | Description | Value |
|---|
ResourceSelector
| Name | Description | Value |
|---|---|---|
| name | The name of the resource selector. | string |
| selectors | The list of the selector expressions. | Selector[] |
Selector
| Name | Description | Value |
|---|---|---|
| in | The list of values to filter in. | string[] |
| kind | The selector kind. | 'groupPrincipalId' 'policyDefinitionReferenceId' 'resourceLocation' 'resourcePercentage' 'resourceType' 'resourceWithoutLocation' 'userPrincipalId' |
| notIn | The list of values to filter out. | string[] |
| progress | The percent of total resources that will be governed by the policy. | int Constraints: Min value = 1 Max value = 99 |
SelfServeExemptionSettings
| Name | Description | Value |
|---|---|---|
| enabled | Indicates whether self-serve exemption is enabled. | bool |
| policyDefinitionReferenceIds | The policy definition reference IDs for self-serve exemption. | string[] |
UserAssignedIdentitiesValue
| Name | Description | Value |
|---|
Usage Examples
Bicep Samples
A basic example of deploying Policy Assignment.
targetScope = 'subscription'
param resourceName string = 'acctest0001'
param location string = 'eastus'
resource policyAssignment 'Microsoft.Authorization/policyAssignments@2022-06-01' = {
name: resourceName
scope: subscription()
properties: {
displayName: ''
enforcementMode: 'Default'
parameters: {
listOfAllowedLocations: {
value: [
'West Europe'
'West US 2'
'East US 2'
]
}
}
policyDefinitionId: policyDefinition.id
scope: subscription().id
}
}
resource policyDefinition 'Microsoft.Authorization/policyDefinitions@2021-06-01' = {
name: resourceName
properties: {
description: ''
displayName: 'my-policy-definition'
mode: 'All'
parameters: {
allowedLocations: {
metadata: {
description: 'The list of allowed locations for resources.'
displayName: 'Allowed locations'
strongType: 'location'
}
type: 'Array'
}
}
policyRule: {
if: {
not: {
field: 'location'
in: /* ERROR: Unparsed HCL syntax in LiteralNode */ {}
}
}
then: {
effect: 'audit'
}
}
policyType: 'Custom'
}
}
Azure Verified Modules
The following Azure Verified Modules can be used to deploy this resource type.
| Module | Description |
|---|---|
| Authorization - Policy Assignment | AVM Resource Module for Authorization - Policy Assignment |
| Authorization - Policy Assignment - Management Group Scope | AVM Child Module for Authorization - Policy Assignment - Management Group Scope |
| Authorization - Policy Assignment - Resource Group Scope | AVM Child Module for Authorization - Policy Assignment - Resource Group Scope |
| Authorization - Policy Assignment - Subscription Scope | AVM Child Module for Authorization - Policy Assignment - Subscription Scope |
Azure Quickstart Samples
The following Azure Quickstart templates contain Bicep samples for deploying this resource type.
| Bicep File | Description |
|---|---|
| Assign built-in policy to audit VM managed disks | This template assigns a built-in policy to a resource group scope to audit virtual machine (VM) managed disks. |
| Create an Azure Virtual Network Manager and sample VNETs | This template deploys an Azure Virtual Network Manager and sample virtual networks into the named resource group. It supports multiple connectivity topologies and network group membership types. |
| Deploy a Policy Def and Assign to Multiple Mgmt Groups | This template is a management group level template that will create a policy definition and assign that policy to multiple management groups. |
| Deploy a policy definition and assign to a management group | 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. |
ARM template resource definition
The policyAssignments resource type can be deployed with operations that target:
- Tenant - See tenant deployment commands* Management groups - See management group deployment commands* Subscription - See subscription deployment commands* Resource groups - See resource group deployment commands
For a list of changed properties in each API version, see change log.
Resource format
To create a Microsoft.Authorization/policyAssignments resource, add the following JSON to your template.
{
"type": "Microsoft.Authorization/policyAssignments",
"apiVersion": "2026-06-01",
"name": "string",
"identity": {
"type": "string",
"userAssignedIdentities": {
"{customized property}": {
}
}
},
"location": "string",
"properties": {
"assignmentType": "string",
"definitionVersion": "string",
"description": "string",
"displayName": "string",
"enforcementMode": "string",
"metadata": {},
"nonComplianceMessages": [
{
"message": "string",
"policyDefinitionReferenceId": "string"
}
],
"notScopes": [ "string" ],
"overrides": [
{
"kind": "string",
"selectors": [
{
"in": [ "string" ],
"kind": "string",
"notIn": [ "string" ],
"progress": "int"
}
],
"value": "string"
}
],
"parameters": {
"{customized property}": {
"value": {}
}
},
"policyDefinitionId": "string",
"resourceSelectors": [
{
"name": "string",
"selectors": [
{
"in": [ "string" ],
"kind": "string",
"notIn": [ "string" ],
"progress": "int"
}
]
}
],
"selfServeExemptionSettings": {
"enabled": "bool",
"policyDefinitionReferenceIds": [ "string" ]
}
}
}
Property Values
Microsoft.Authorization/policyAssignments
| Name | Description | Value |
|---|---|---|
| apiVersion | The api version | '2026-06-01' |
| identity | The managed identity associated with the policy assignment. | Identity |
| location | The location of the policy assignment. Only required when utilizing managed identity. | string |
| name | The resource name | string Constraints: Pattern = ^[^<>%&:\?/]*[^<>%&:\?/ ]+$ (required) |
| properties | Properties for the policy assignment. | PolicyAssignmentProperties |
| type | The resource type | 'Microsoft.Authorization/policyAssignments' |
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}'. | IdentityUserAssignedIdentities |
IdentityUserAssignedIdentities
| Name | Description | Value |
|---|
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 |
Override
| Name | Description | Value |
|---|---|---|
| kind | The override kind. | 'definitionVersion' 'policyEffect' |
| selectors | The list of the selector expressions. | Selector[] |
| value | The value to override the policy property. | string |
ParameterValuesValue
| Name | Description | Value |
|---|---|---|
| value | The value of the parameter. | any |
PolicyAssignmentProperties
| Name | Description | Value |
|---|---|---|
| assignmentType | The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. | 'Custom' 'NotSpecified' 'System' 'SystemHidden' |
| definitionVersion | The version of the policy definition to use. | string |
| 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, DoNotEnforce, and Enroll | 'Default' 'DoNotEnforce' 'Enroll' |
| metadata | The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. | any |
| nonComplianceMessages | The messages that describe why a resource is non-compliant with the policy. | NonComplianceMessage[] |
| notScopes | The policy's excluded scopes. | string[] |
| overrides | The policy property value override. | Override[] |
| parameters | The parameter values for the assigned policy rule. The keys are the parameter names. | PolicyAssignmentPropertiesParameters |
| policyDefinitionId | The ID of the policy definition or policy set definition being assigned. | string |
| resourceSelectors | The resource selector list to filter policies by resource properties. | ResourceSelector[] |
| selfServeExemptionSettings | The self-serve exemption settings for the policy assignment. | SelfServeExemptionSettings |
PolicyAssignmentPropertiesParameters
| Name | Description | Value |
|---|
ResourceSelector
| Name | Description | Value |
|---|---|---|
| name | The name of the resource selector. | string |
| selectors | The list of the selector expressions. | Selector[] |
Selector
| Name | Description | Value |
|---|---|---|
| in | The list of values to filter in. | string[] |
| kind | The selector kind. | 'groupPrincipalId' 'policyDefinitionReferenceId' 'resourceLocation' 'resourcePercentage' 'resourceType' 'resourceWithoutLocation' 'userPrincipalId' |
| notIn | The list of values to filter out. | string[] |
| progress | The percent of total resources that will be governed by the policy. | int Constraints: Min value = 1 Max value = 99 |
SelfServeExemptionSettings
| Name | Description | Value |
|---|---|---|
| enabled | Indicates whether self-serve exemption is enabled. | bool |
| policyDefinitionReferenceIds | The policy definition reference IDs for self-serve exemption. | string[] |
UserAssignedIdentitiesValue
| Name | Description | Value |
|---|
Usage Examples
Azure Quickstart Templates
The following Azure Quickstart templates deploy this resource type.
| Template | Description |
|---|---|
| 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. |
| Assign built-in policy to audit VM managed disks 👁 Deploy to Azure |
This template assigns a built-in policy to a resource group scope to audit virtual machine (VM) managed disks. |
| Create an Azure Virtual Network Manager and sample VNETs 👁 Deploy to Azure |
This template deploys an Azure Virtual Network Manager and sample virtual networks into the named resource group. It supports multiple connectivity topologies and network group membership types. |
| 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. |
| 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. |
Terraform (AzAPI provider) resource definition
The policyAssignments resource type can be deployed with operations that target:
- Tenant* Management groups* Subscription* Resource groups
For a list of changed properties in each API version, see change log.
Resource format
To create a Microsoft.Authorization/policyAssignments resource, add the following Terraform to your template.
resource "azapi_resource" "symbolicname" {
type = "Microsoft.Authorization/policyAssignments@2026-06-01"
name = "string"
parent_id = "string"
identity {
type = "string"
identity_ids = [
"string"
]
}
location = "string"
body = {
properties = {
assignmentType = "string"
definitionVersion = "string"
description = "string"
displayName = "string"
enforcementMode = "string"
metadata = ?
nonComplianceMessages = [
{
message = "string"
policyDefinitionReferenceId = "string"
}
]
notScopes = [
"string"
]
overrides = [
{
kind = "string"
selectors = [
{
in = [
"string"
]
kind = "string"
notIn = [
"string"
]
progress = int
}
]
value = "string"
}
]
parameters = {
{customized property} = {
value = ?
}
}
policyDefinitionId = "string"
resourceSelectors = [
{
name = "string"
selectors = [
{
in = [
"string"
]
kind = "string"
notIn = [
"string"
]
progress = int
}
]
}
]
selfServeExemptionSettings = {
enabled = bool
policyDefinitionReferenceIds = [
"string"
]
}
}
}
}
Property Values
Microsoft.Authorization/policyAssignments
| Name | Description | Value |
|---|---|---|
| identity | The managed identity associated with the policy assignment. | Identity |
| location | The location of the policy assignment. Only required when utilizing managed identity. | string |
| name | The resource name | string Constraints: Pattern = ^[^<>%&:\?/]*[^<>%&:\?/ ]+$ (required) |
| parent_id | The ID of the resource to apply this extension resource to. | string (required) |
| properties | Properties for the policy assignment. | PolicyAssignmentProperties |
| type | The resource type | "Microsoft.Authorization/policyAssignments@2026-06-01" |
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}'. | IdentityUserAssignedIdentities |
IdentityUserAssignedIdentities
| Name | Description | Value |
|---|
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 |
Override
| Name | Description | Value |
|---|---|---|
| kind | The override kind. | 'definitionVersion' 'policyEffect' |
| selectors | The list of the selector expressions. | Selector[] |
| value | The value to override the policy property. | string |
ParameterValuesValue
| Name | Description | Value |
|---|---|---|
| value | The value of the parameter. | any |
PolicyAssignmentProperties
| Name | Description | Value |
|---|---|---|
| assignmentType | The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable. | 'Custom' 'NotSpecified' 'System' 'SystemHidden' |
| definitionVersion | The version of the policy definition to use. | string |
| 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, DoNotEnforce, and Enroll | 'Default' 'DoNotEnforce' 'Enroll' |
| metadata | The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs. | any |
| nonComplianceMessages | The messages that describe why a resource is non-compliant with the policy. | NonComplianceMessage[] |
| notScopes | The policy's excluded scopes. | string[] |
| overrides | The policy property value override. | Override[] |
| parameters | The parameter values for the assigned policy rule. The keys are the parameter names. | PolicyAssignmentPropertiesParameters |
| policyDefinitionId | The ID of the policy definition or policy set definition being assigned. | string |
| resourceSelectors | The resource selector list to filter policies by resource properties. | ResourceSelector[] |
| selfServeExemptionSettings | The self-serve exemption settings for the policy assignment. | SelfServeExemptionSettings |
PolicyAssignmentPropertiesParameters
| Name | Description | Value |
|---|
ResourceSelector
| Name | Description | Value |
|---|---|---|
| name | The name of the resource selector. | string |
| selectors | The list of the selector expressions. | Selector[] |
Selector
| Name | Description | Value |
|---|---|---|
| in | The list of values to filter in. | string[] |
| kind | The selector kind. | 'groupPrincipalId' 'policyDefinitionReferenceId' 'resourceLocation' 'resourcePercentage' 'resourceType' 'resourceWithoutLocation' 'userPrincipalId' |
| notIn | The list of values to filter out. | string[] |
| progress | The percent of total resources that will be governed by the policy. | int Constraints: Min value = 1 Max value = 99 |
SelfServeExemptionSettings
| Name | Description | Value |
|---|---|---|
| enabled | Indicates whether self-serve exemption is enabled. | bool |
| policyDefinitionReferenceIds | The policy definition reference IDs for self-serve exemption. | string[] |
UserAssignedIdentitiesValue
| Name | Description | Value |
|---|
Usage Examples
Terraform Samples
A basic example of deploying Policy Assignment.
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
azurerm = {
source = "hashicorp/azurerm"
}
}
}
provider "azurerm" {
features {
}
}
provider "azapi" {
skip_provider_registration = false
}
variable "resource_name" {
type = string
default = "acctest0001"
}
variable "location" {
type = string
default = "eastus"
}
data "azurerm_client_config" "current" {
}
data "azapi_resource" "subscription" {
type = "Microsoft.Resources/subscriptions@2021-01-01"
resource_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}"
response_export_values = ["*"]
}
resource "azapi_resource" "policyDefinition" {
type = "Microsoft.Authorization/policyDefinitions@2021-06-01"
parent_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}"
name = var.resource_name
body = {
properties = {
description = ""
displayName = "my-policy-definition"
mode = "All"
parameters = {
allowedLocations = {
metadata = {
description = "The list of allowed locations for resources."
displayName = "Allowed locations"
strongType = "location"
}
type = "Array"
}
}
policyRule = {
if = {
not = {
field = "location"
in = "[parameters('allowedLocations')]"
}
}
then = {
effect = "audit"
}
}
policyType = "Custom"
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}
resource "azapi_resource" "policyAssignment" {
type = "Microsoft.Authorization/policyAssignments@2022-06-01"
parent_id = data.azapi_resource.subscription.id
name = var.resource_name
body = {
properties = {
displayName = ""
enforcementMode = "Default"
parameters = {
listOfAllowedLocations = {
value = [
"West Europe",
"West US 2",
"East US 2",
]
}
}
policyDefinitionId = azapi_resource.policyDefinition.id
scope = data.azapi_resource.subscription.id
}
}
schema_validation_enabled = false
response_export_values = ["*"]
}
Feedback
Was this page helpful?
