Assign a built-in policy to an existing resource group
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