General
Azure Policy assignment
Applies a policy definition or initiative to resources within a scope.
Naming rules
- Abbreviation
- Length
- 1-128 display name 1-64 resource name 1-24 resource name at management group scope
- Allowed characters
- Display name can contain any characters. Resource name can't use: #<>%&:\?/ or control characters. Can't end with period or space.
- Uniqueness scope
- scope of assignment
Directory abbreviation · AVM naming key policy_assignment
Code examples
These examples look up an existing resource by its full Azure resource ID. The documentation links include deployment syntax.
Terraform
Terraform documentationhcl
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
version = "~> 2.0"
}
}
}
variable "resource_id" {
description = "Full Azure resource ID of the existing Microsoft.Authorization/policyAssignments resource."
type = string
}
data "azapi_resource" "example" {
type = "Microsoft.Authorization/policyAssignments@2026-07-01"
resource_id = var.resource_id
}
output "resource_name" {
value = data.azapi_resource.example.name
}
Bicep
Bicep documentationbicep
@description('Full resource ID of the existing Microsoft.Authorization/policyAssignments resource.')
param resourceId string
output resourceName string = reference(resourceId, '2026-07-01', 'Full').name
ARM template
ARM template documentationjson
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceId": {
"type": "string",
"metadata": {
"description": "Full resource ID of the existing Microsoft.Authorization/policyAssignments resource."
}
}
},
"resources": [],
"outputs": {
"resourceName": {
"type": "string",
"value": "[reference(parameters('resourceId'), '2026-07-01', 'Full').name]"
}
}
}