Skip to content

Commit 6c1c3de

Browse files
Merge pull request #267351 from davidsmatlak/ds-policy-docs-edits
Edits to Azure Policy quickstarts
2 parents 40673ba + 2361b12 commit 6c1c3de

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

articles/governance/policy/assign-policy-azurecli.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Quickstart: Create policy assignment using Azure CLI"
33
description: In this quickstart, you create an Azure Policy assignment to identify non-compliant resources using Azure CLI.
4-
ms.date: 02/23/2024
4+
ms.date: 02/26/2024
55
ms.topic: quickstart
66
ms.custom: devx-track-azurecli
77
---
@@ -70,7 +70,7 @@ Run the following command to create the policy assignment:
7070
```azurecli
7171
az policy assignment create \
7272
--name 'audit-vm-managed-disks' \
73-
--display-name 'Audit VMs without managed disks Assignment' \
73+
--display-name 'Audit VM managed disks' \
7474
--scope $rgid \
7575
--policy $definition \
7676
--description 'Azure CLI policy assignment to resource group'
@@ -86,7 +86,7 @@ The results of the policy assignment resemble the following example:
8686

8787
```output
8888
"description": "Azure CLI policy assignment to resource group",
89-
"displayName": "Audit VMs without managed disks Assignment",
89+
"displayName": "Audit VM managed disks",
9090
"enforcementMode": "Default",
9191
"id": "/subscriptions/{subscriptionID}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments/audit-vm-managed-disks",
9292
"identity": null,

articles/governance/policy/assign-policy-bicep.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Quickstart: Create policy assignment using Bicep file"
33
description: In this quickstart, you create an Azure Policy assignment to identify non-compliant resources using a Bicep file.
4-
ms.date: 02/23/2024
4+
ms.date: 02/26/2024
55
ms.topic: quickstart
66
ms.custom: subject-bicepqs, devx-track-bicep, devx-track-azurecli, devx-track-azurepowershell
77
---
@@ -34,14 +34,15 @@ Create the following Bicep file as _policy-assignment.bicep_.
3434
```bicep
3535
param policyAssignmentName string = 'audit-vm-managed-disks'
3636
param policyDefinitionID string = '/providers/Microsoft.Authorization/policyDefinitions/06a78e20-9358-41c9-923c-fb736d382a4d'
37+
param policyDisplayName string = 'Audit VM managed disks'
3738
3839
resource assignment 'Microsoft.Authorization/policyAssignments@2023-04-01' = {
3940
name: policyAssignmentName
4041
scope: resourceGroup()
4142
properties: {
4243
policyDefinitionId: policyDefinitionID
4344
description: 'Policy assignment to resource group scope created with Bicep file'
44-
displayName: 'audit-vm-managed-disks'
45+
displayName: policyDisplayName
4546
nonComplianceMessages: [
4647
{
4748
message: 'Virtual machines should use managed disks'
@@ -53,7 +54,13 @@ resource assignment 'Microsoft.Authorization/policyAssignments@2023-04-01' = {
5354
output assignmentId string = assignment.id
5455
```
5556

56-
The resource type defined in the Bicep file is [Microsoft.Authorization/policyAssignments](/azure/templates/microsoft.authorization/policyassignments). The Bicep file creates a policy assignment named _audit-vm-managed-disks_.
57+
The resource type defined in the Bicep file is [Microsoft.Authorization/policyAssignments](/azure/templates/microsoft.authorization/policyassignments).
58+
59+
The Bicep file uses three parameters to deploy the policy assignment:
60+
61+
- `policyAssignmentName` creates the policy assignment named _audit-vm-managed-disks_.
62+
- `policyDefinitionID` uses the ID of the built-in policy definition. For reference, the commands to get the ID are in the section to deploy the template.
63+
- `policyDisplayName` creates a display name that's visible in Azure portal.
5764

5865
For more information about Bicep files:
5966

@@ -117,6 +124,25 @@ The Azure CLI commands use a backslash (`\`) for line continuation to improve re
117124

118125
---
119126

127+
The following commands display the `policyDefinitionID` parameter's value:
128+
129+
# [PowerShell](#tab/azure-powershell)
130+
131+
```azurepowershell
132+
(Get-AzPolicyDefinition |
133+
Where-Object { $_.Properties.DisplayName -eq 'Audit VMs that do not use managed disks' }).ResourceId
134+
```
135+
136+
# [Azure CLI](#tab/azure-cli)
137+
138+
```azurecli
139+
az policy definition list \
140+
--query "[?displayName=='Audit VMs that do not use managed disks']".id \
141+
--output tsv
142+
```
143+
144+
---
145+
120146
The following commands deploy the policy definition to your resource group. Replace `<resourceGroupName>` with your resource group name:
121147

122148
# [PowerShell](#tab/azure-powershell)
@@ -195,7 +221,7 @@ The output is verbose but resembles the following example:
195221

196222
```output
197223
"description": "Policy assignment to resource group scope created with Bicep file",
198-
"displayName": "audit-vm-managed-disks",
224+
"displayName": "Audit VM managed disks",
199225
"enforcementMode": "Default",
200226
"id": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments/audit-vm-managed-disks",
201227
"identity": null,

articles/governance/policy/assign-policy-powershell.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Quickstart: Create policy assignment using Azure PowerShell"
33
description: In this quickstart, you create an Azure Policy assignment to identify non-compliant resources using Azure PowerShell.
4-
ms.date: 02/23/2024
4+
ms.date: 02/26/2024
55
ms.topic: quickstart
66
ms.custom: devx-track-azurepowershell
77
---
@@ -67,7 +67,7 @@ Run the following command to create the policy assignment:
6767
```azurepowershell
6868
$policyparms = @{
6969
Name = 'audit-vm-managed-disks'
70-
DisplayName = 'Audit VMs without managed disks Assignment'
70+
DisplayName = 'Audit VM managed disks'
7171
Scope = $rg.ResourceId
7272
PolicyDefinition = $definition
7373
Description = 'Az PowerShell policy assignment to resource group'

0 commit comments

Comments
 (0)