Assign a built-in policy to an existing resource group

Azure Public Test Date Azure Public Test Result

Azure US Gov Last Test Date Azure US Gov Last Test Result

Best Practice Check Cred Scan Check

Deploy To Azure Deploy To Azure US Gov Visualize

This template assigns a built-in policy to an existing resource group. You must be an owner of the scope (subscription, resourceGroup) to apply a policy. Inputs to this template are the following fields:

  • policyDefinitionID
  • policyAssignmentName

The following PowerShell script shows how to get the policy definition ID and the policy display name of a built-in policy called Audit resource location matches resource group location.

$policyDefinitionId = $(Get-AzPolicyDefinition  | Where-Object { $_.Properties.DisplayName -eq 'Audit resource location matches resource group location' }).PolicyDefinitionId

To learn more about how to deploy the template, see the quickstart article.

Tags: Microsoft.Authorization/policyAssignments