Skip to content

Commit 24df45e

Browse files
committed
edit cli, powershell, and bicep quickstarts
1 parent 2f903a3 commit 24df45e

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The Azure CLI commands use a backslash (`\`) for line continuation to improve re
5151

5252
## Create policy assignment
5353

54-
Use the following commands to create a new policy assignment for your resource group. This example uses an existing resource group that contains a virtual machine _without_ managed disks. The resource group is the scope for the policy assignment.
54+
Use the following commands to create a new policy assignment for your resource group. This example uses an existing resource group that contains a virtual machine _without_ managed disks. The resource group is the scope for the policy assignment. This example uses the built-in policy definition [Audit VMs that do not use managed disks](https://github.com/Azure/azure-policy/blob/master/built-in-policies/policyDefinitions/Compute/VMRequireManagedDisk_Audit.json).
5555

5656
Run the following commands and replace `<resourceGroupName>` with your resource group name:
5757

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

Lines changed: 16 additions & 6 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/20/2024
4+
ms.date: 02/23/2024
55
ms.topic: quickstart
66
ms.custom: subject-bicepqs, devx-track-bicep, devx-track-azurecli, devx-track-azurepowershell
77
---
@@ -23,7 +23,7 @@ In this quickstart, you use a Bicep file to create a policy assignment that vali
2323

2424
## Review the Bicep file
2525

26-
The Bicep file creates a policy assignment for a resource group scope and assigns the built-in policy definition [Audit VMs that do not use managed disks](https://github.com/Azure/azure-policy/blob/master/built-in-policies/policyDefinitions/Compute/VMRequireManagedDisk_Audit.json). For a list of available built-in policies, see [Azure Policy samples](./samples/index.md).
26+
The Bicep file creates a policy assignment for a resource group scope and assigns the built-in policy definition [Audit VMs that do not use managed disks](https://github.com/Azure/azure-policy/blob/master/built-in-policies/policyDefinitions/Compute/VMRequireManagedDisk_Audit.json).
2727

2828
Create the following Bicep file as _policy-assignment.bicep_.
2929

@@ -100,6 +100,8 @@ Get-AzResourceProvider -ProviderNamespace 'Microsoft.PolicyInsights' |
100100
Register-AzResourceProvider -ProviderNamespace 'Microsoft.PolicyInsights'
101101
```
102102

103+
For more information, go to [Get-AzResourceProvider](/powershell/module/az.resources/get-azresourceprovider) and [Register-AzResourceProvider](/powershell/module/az.resources/register-azresourceprovider).
104+
103105
# [Azure CLI](#tab/azure-cli)
104106

105107
```azurecli
@@ -111,6 +113,8 @@ az provider show \
111113
az provider register --namespace Microsoft.PolicyInsights
112114
```
113115

116+
The Azure CLI commands use a backslash (`\`) for line continuation to improve readability. For more information, go to [az provider](/cli/azure/provider).
117+
114118
---
115119

116120
The following commands deploy the policy definition to your resource group. Replace `<resourceGroupName>` with your resource group name:
@@ -146,7 +150,7 @@ az deployment group create \
146150
--template-file policy-assignment.bicep
147151
```
148152

149-
The `rgname` variable uses an expression to get your resource group's name used in the deployment command. The Azure CLI commands use a backslash (`\`) for line continuation to improve readability.
153+
The `rgname` variable uses an expression to get your resource group's name used in the deployment command.
150154

151155
- `name` is the deployment name displayed in the output and in Azure for the resource group's deployments.
152156
- `resource-group` is the name of your resource group where the policy is assigned.
@@ -175,6 +179,8 @@ PolicyAssignmentId : /subscriptions/{subscriptionId}/resourcegroups/{resourceGro
175179
Properties : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.Policy.PsPolicyAssignmentProperties
176180
```
177181

182+
For more information, go to [Get-AzPolicyAssignment](/powershell/module/az.resources/get-azpolicyassignment).
183+
178184
# [Azure CLI](#tab/azure-cli)
179185

180186
The `rgid` variable uses an expression to get the resource group's ID used to show the policy assignment.
@@ -209,6 +215,8 @@ The output is verbose but resembles the following example:
209215
]
210216
```
211217

218+
For more information, go to [az policy assignment](/cli/azure/policy/assignment).
219+
212220
---
213221

214222
## Identify non-compliant resources
@@ -258,6 +266,8 @@ ComplianceState : NonCompliant
258266
AdditionalProperties : {[complianceReasonCode, ]}
259267
```
260268

269+
For more information, go to [Get-AzPolicyState](/powershell/module/az.policyinsights/Get-AzPolicyState).
270+
261271
# [Azure CLI](#tab/azure-cli)
262272

263273
```azurecli
@@ -270,9 +280,7 @@ policyid=$(az policy assignment show \
270280
az policy state list --resource $policyid --filter "(isCompliant eq false)"
271281
```
272282

273-
The `policyid` variable uses an expression to get the policy assignment's ID.
274-
275-
The `filter` parameter limits the output to non-compliant resources.
283+
The `policyid` variable uses an expression to get the policy assignment's ID. The `filter` parameter limits the output to non-compliant resources.
276284

277285
The `az policy state list` output is verbose, but for this article the `complianceState` shows `NonCompliant`.
278286

@@ -283,6 +291,8 @@ The `az policy state list` output is verbose, but for this article the `complian
283291
"isCompliant": false,
284292
```
285293

294+
For more information, go to [az policy state](/cli/azure/policy/state).
295+
286296
---
287297

288298
## Clean up resources

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

Lines changed: 12 additions & 4 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/16/2024
4+
ms.date: 02/23/2024
55
ms.topic: quickstart
66
ms.custom: devx-track-azurepowershell
77
---
@@ -45,9 +45,11 @@ To verify if `Microsoft.PolicyInsights` is registered, run `Get-AzResourceProvid
4545
Register-AzResourceProvider -ProviderNamespace 'Microsoft.PolicyInsights'
4646
```
4747

48+
For more information, go to [Get-AzResourceProvider](/powershell/module/az.resources/get-azresourceprovider) and [Register-AzResourceProvider](/powershell/module/az.resources/register-azresourceprovider).
49+
4850
## Create policy assignment
4951

50-
Use the following commands to create a new policy assignment for your resource group. This example uses an existing resource group that contains a virtual machine _without_ managed disks. The resource group is the scope for the policy assignment.
52+
Use the following commands to create a new policy assignment for your resource group. This example uses an existing resource group that contains a virtual machine _without_ managed disks. The resource group is the scope for the policy assignment. This example uses the built-in policy definition [Audit VMs that do not use managed disks](https://github.com/Azure/azure-policy/blob/master/built-in-policies/policyDefinitions/Compute/VMRequireManagedDisk_Audit.json).
5153

5254
Run the following commands and replace `<resourceGroupName>` with your resource group name:
5355

@@ -97,6 +99,12 @@ Properties : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementa
9799

98100
For more information, go to [New-AzPolicyAssignment](/powershell/module/az.resources/new-azpolicyassignment).
99101

102+
If you want to redisplay the policy assignment information, run the following command:
103+
104+
```azurepowershell
105+
Get-AzPolicyAssignment -Name 'audit-vm-managed-disks' -Scope $rg.ResourceId
106+
```
107+
100108
## Identify non-compliant resources
101109

102110
The compliance state for a new policy assignment takes a few minutes to become active and provide results about the policy's state.
@@ -120,8 +128,6 @@ The `$complianceparms` variable uses splatting to create parameter values used i
120128
- `PolicyAssignmentName` specifies the name used when the policy assignment was created.
121129
- `Filter` uses an expression to find resources that aren't compliant with the policy assignment.
122130

123-
For more information, go to [Get-AzPolicyState](/powershell/module/az.policyinsights/Get-AzPolicyState).
124-
125131
Your results resemble the following example and `ComplianceState` shows `NonCompliant`:
126132

127133
```output
@@ -146,6 +152,8 @@ ComplianceState : NonCompliant
146152
AdditionalProperties : {[complianceReasonCode, ]}
147153
```
148154

155+
For more information, go to [Get-AzPolicyState](/powershell/module/az.policyinsights/Get-AzPolicyState).
156+
149157
## Clean up resources
150158

151159
To remove the policy assignment, run the following command:

0 commit comments

Comments
 (0)