{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/microsoft-azure/json-schema/microsoft-azure-policy-assignment-schema.json",
  "title": "PolicyAssignment",
  "description": "The policy assignment.",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/microsoft-azure-policyassignments-api-openapi.yml#/components/schemas/PolicyAssignment",
  "type": "object",
  "properties": {
    "properties": {
      "$ref": "#/$defs/PolicyAssignmentProperties",
      "description": "Properties for the policy assignment.",
      "x-ms-client-flatten": true
    },
    "location": {
      "type": "string",
      "description": "The location of the policy assignment. Only required when utilizing managed identity."
    },
    "identity": {
      "$ref": "#/$defs/Identity",
      "description": "The managed identity associated with the policy assignment."
    }
  },
  "allOf": [
    {
      "$ref": "#/$defs/ProxyResource"
    }
  ],
  "$defs": {
    "AssignmentType": {
      "type": "string",
      "description": "The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable.",
      "enum": [
        "NotSpecified",
        "System",
        "SystemHidden",
        "Custom"
      ],
      "x-ms-enum": {
        "name": "AssignmentType",
        "modelAsString": true,
        "values": [
          {
            "name": "NotSpecified",
            "value": "NotSpecified",
            "description": "The not specified assignment type."
          },
          {
            "name": "System",
            "value": "System",
            "description": "The system assignment type."
          },
          {
            "name": "SystemHidden",
            "value": "SystemHidden",
            "description": "The system hidden assignment type."
          },
          {
            "name": "Custom",
            "value": "Custom",
            "description": "The custom assignment type."
          }
        ]
      }
    },
    "Identity": {
      "type": "object",
      "description": "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.",
      "properties": {
        "principalId": {
          "type": "string",
          "description": "The principal ID of the resource identity.  This property will only be provided for a system assigned identity",
          "readOnly": true
        },
        "tenantId": {
          "type": "string",
          "description": "The tenant ID of the resource identity.  This property will only be provided for a system assigned identity",
          "readOnly": true
        },
        "type": {
          "$ref": "#/$defs/ResourceIdentityType",
          "description": "The identity type. This is the only required field when adding a system or user assigned identity to a resource."
        },
        "userAssignedIdentities": {
          "type": "object",
          "description": "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}'.",
          "additionalProperties": {
            "$ref": "#/$defs/UserAssignedIdentitiesValue"
          }
        }
      }
    },
    "NonComplianceMessage": {
      "type": "object",
      "description": "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.",
      "properties": {
        "message": {
          "type": "string",
          "description": "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."
        },
        "policyDefinitionReferenceId": {
          "type": "string",
          "description": "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."
        }
      },
      "required": [
        "message"
      ]
    },
    "Override": {
      "type": "object",
      "description": "The policy property value override.",
      "properties": {
        "kind": {
          "$ref": "#/$defs/OverrideKind",
          "description": "The override kind."
        },
        "value": {
          "type": "string",
          "description": "The value to override the policy property."
        },
        "selectors": {
          "type": "array",
          "description": "The list of the selector expressions.",
          "items": {
            "$ref": "#/$defs/Selector"
          },
          "x-ms-identifiers": []
        }
      }
    },
    "OverrideKind": {
      "type": "string",
      "description": "The override kind.",
      "enum": [
        "policyEffect",
        "definitionVersion"
      ],
      "x-ms-enum": {
        "name": "OverrideKind",
        "modelAsString": true,
        "values": [
          {
            "name": "policyEffect",
            "value": "policyEffect",
            "description": "It will override the policy effect type."
          },
          {
            "name": "definitionVersion",
            "value": "definitionVersion",
            "description": "It will override the definition version property value of the policy assignment."
          }
        ]
      }
    },
    "ParameterValuesValue": {
      "type": "object",
      "description": "The value of a parameter.",
      "properties": {
        "value": {
          "description": "The value of the parameter."
        }
      }
    },
    "PolicyAssignmentProperties": {
      "type": "object",
      "description": "The policy assignment properties.",
      "properties": {
        "displayName": {
          "type": "string",
          "description": "The display name of the policy assignment."
        },
        "policyDefinitionId": {
          "type": "string",
          "description": "The ID of the policy definition or policy set definition being assigned."
        },
        "definitionVersion": {
          "type": "string",
          "description": "The version of the policy definition to use."
        },
        "latestDefinitionVersion": {
          "type": "string",
          "description": "The latest version of the policy definition available. This is only present if requested via the $expand query parameter.",
          "readOnly": true
        },
        "effectiveDefinitionVersion": {
          "type": "string",
          "description": "The effective version of the policy definition in use. This is only present if requested via the $expand query parameter.",
          "readOnly": true
        },
        "scope": {
          "type": "string",
          "description": "The scope for the policy assignment.",
          "readOnly": true
        },
        "notScopes": {
          "type": "array",
          "description": "The policy's excluded scopes.",
          "items": {
            "type": "string"
          }
        },
        "parameters": {
          "type": "object",
          "description": "The parameter values for the assigned policy rule. The keys are the parameter names.",
          "additionalProperties": {
            "$ref": "#/$defs/ParameterValuesValue"
          }
        },
        "description": {
          "type": "string",
          "description": "This message will be part of response in case of policy violation."
        },
        "metadata": {
          "description": "The policy assignment metadata. Metadata is an open ended object and is typically a collection of key value pairs."
        },
        "enforcementMode": {
          "type": "string",
          "description": "The policy assignment enforcement mode. Possible values are Default, DoNotEnforce, and Enroll",
          "default": "Default",
          "enum": [
            "Default",
            "DoNotEnforce",
            "Enroll"
          ],
          "x-ms-enum": {
            "name": "EnforcementMode",
            "modelAsString": true,
            "values": [
              {
                "name": "Default",
                "value": "Default",
                "description": "The policy effect is enforced during resource creation or update."
              },
              {
                "name": "DoNotEnforce",
                "value": "DoNotEnforce",
                "description": "The policy effect is not enforced during resource creation or update."
              },
              {
                "name": "Enroll",
                "value": "Enroll",
                "description": "The policy effect is not enforced during resource creation or update until the resource or scope of the resource is enrolled to the assignment instance. Enrollment occurs upon deployment of the policy enrollment resource."
              }
            ]
          }
        },
        "nonComplianceMessages": {
          "type": "array",
          "description": "The messages that describe why a resource is non-compliant with the policy.",
          "items": {
            "$ref": "#/$defs/NonComplianceMessage"
          },
          "x-ms-identifiers": [
            "message",
            "policyDefinitionReferenceId"
          ]
        },
        "resourceSelectors": {
          "type": "array",
          "description": "The resource selector list to filter policies by resource properties.",
          "items": {
            "$ref": "#/$defs/ResourceSelector"
          },
          "x-ms-identifiers": []
        },
        "overrides": {
          "type": "array",
          "description": "The policy property value override.",
          "items": {
            "$ref": "#/$defs/Override"
          },
          "x-ms-identifiers": []
        },
        "assignmentType": {
          "$ref": "#/$defs/AssignmentType",
          "description": "The type of policy assignment. Possible values are NotSpecified, System, SystemHidden, and Custom. Immutable."
        },
        "instanceId": {
          "type": "string",
          "description": "The instance ID of the policy assignment. This ID only and always changes when the assignment is deleted and recreated.",
          "readOnly": true
        },
        "selfServeExemptionSettings": {
          "$ref": "#/$defs/SelfServeExemptionSettings",
          "description": "The self-serve exemption settings for the policy assignment."
        }
      }
    },
    "ProxyResource": {
      "type": "object",
      "title": "Proxy Resource",
      "description": "The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location",
      "allOf": [
        {
          "$ref": "#/$defs/Resource"
        }
      ]
    },
    "ResourceIdentityType": {
      "type": "string",
      "description": "The identity type. This is the only required field when adding a system or user assigned identity to a resource.",
      "enum": [
        "SystemAssigned",
        "UserAssigned",
        "None"
      ],
      "x-ms-enum": {
        "name": "ResourceIdentityType",
        "modelAsString": false,
        "values": [
          {
            "name": "SystemAssigned",
            "value": "SystemAssigned",
            "description": "Indicates that a system assigned identity is associated with the resource."
          },
          {
            "name": "UserAssigned",
            "value": "UserAssigned",
            "description": "Indicates that a user assigned identity is associated with the resource."
          },
          {
            "name": "None",
            "value": "None",
            "description": "Indicates that no identity is associated with the resource or that the existing identity should be removed."
          }
        ]
      }
    },
    "ResourceSelector": {
      "type": "object",
      "description": "The resource selector to filter policies by resource properties.",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the resource selector."
        },
        "selectors": {
          "type": "array",
          "description": "The list of the selector expressions.",
          "items": {
            "$ref": "#/$defs/Selector"
          },
          "x-ms-identifiers": []
        }
      }
    },
    "Selector": {
      "type": "object",
      "description": "The selector expression.",
      "properties": {
        "kind": {
          "$ref": "#/$defs/SelectorKind",
          "description": "The selector kind."
        },
        "in": {
          "type": "array",
          "description": "The list of values to filter in.",
          "items": {
            "type": "string"
          }
        },
        "notIn": {
          "type": "array",
          "description": "The list of values to filter out.",
          "items": {
            "type": "string"
          }
        },
        "progress": {
          "type": "integer",
          "format": "int32",
          "description": "The percent of total resources that will be governed by the policy.",
          "minimum": 0,
          "maximum": 100
        }
      }
    },
    "SelectorKind": {
      "type": "string",
      "description": "The selector kind.",
      "enum": [
        "resourceLocation",
        "resourceType",
        "resourceWithoutLocation",
        "policyDefinitionReferenceId",
        "resourceRolloutPercentage",
        "userPrincipalId",
        "groupPrincipalId"
      ],
      "x-ms-enum": {
        "name": "SelectorKind",
        "modelAsString": true,
        "values": [
          {
            "name": "resourceLocation",
            "value": "resourceLocation",
            "description": "The selector kind to filter policies by the resource location."
          },
          {
            "name": "resourceType",
            "value": "resourceType",
            "description": "The selector kind to filter policies by the resource type."
          },
          {
            "name": "resourceWithoutLocation",
            "value": "resourceWithoutLocation",
            "description": "The selector kind to filter policies by the resource without location."
          },
          {
            "name": "policyDefinitionReferenceId",
            "value": "policyDefinitionReferenceId",
            "description": "The selector kind to filter policies by the policy definition reference ID."
          },
          {
            "name": "resourceRolloutPercentage",
            "value": "resourceRolloutPercentage",
            "description": "The selector kind to filter policies by the resource rollout percentage."
          },
          {
            "name": "userPrincipalId",
            "value": "userPrincipalId",
            "description": "The selector kind to filter policies by the user principal ID."
          },
          {
            "name": "groupPrincipalId",
            "value": "groupPrincipalId",
            "description": "The selector kind to filter policies by the security group membership ID."
          }
        ]
      }
    },
    "SelfServeExemptionSettings": {
      "type": "object",
      "description": "The self-serve exemption settings for a policy assignment.",
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "Indicates whether self-serve exemption is enabled."
        },
        "policyDefinitionReferenceIds": {
          "type": "array",
          "description": "The policy definition reference IDs for self-serve exemption.",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "UserAssignedIdentitiesValue": {
      "type": "object",
      "properties": {
        "principalId": {
          "type": "string",
          "description": "The principal id of user assigned identity.",
          "readOnly": true
        },
        "clientId": {
          "type": "string",
          "description": "The client id of user assigned identity.",
          "readOnly": true
        }
      }
    }
  }
}