Skip to content

Commit c65d94f

Browse files
committed
fixes
1 parent 9a4b231 commit c65d94f

File tree

3 files changed

+41
-39
lines changed

3 files changed

+41
-39
lines changed

articles/azure-monitor/essentials/diagnostic-settings-policy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Create diagnostic settings at scale using Azure Policies and Initiatives
2+
title: Create diagnostic settings at scale using Azure policies and initiatives
33
description: Use Azure Policy to create diagnostic settings in Azure Monitor at scale as each Azure resource is created.
44
author: EdB-MSFT
55
ms.author: edbaynash

articles/azure-monitor/essentials/diagnostics-settings-policies-deployifnotexists.md

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Enable Diagnostics settings by category group using built-in policies.
2+
title: Enable diagnostics settings by category group using built-in policies.
33
description: Use Azure builtin policies to create diagnostic settings in Azure Monitor.
44
author: EdB-MSFT
55
ms.author: edbaynash
@@ -31,7 +31,7 @@ The following steps show how to apply the policy to send audit logs to for key v
3131
1. Select **Monitoring** from the Category dropdown
3232
1. Enter *keyvault* in the **Search** field.
3333
1. Select the **Enable logging by category group for Key vaults (microsoft.keyvault/vaults) to Log Analytics** policy,
34-
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/policy-definitions.png" alt-text="A screenshot of the policy definitions page":::
34+
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/policy-definitions.png" alt-text="A screenshot of the policy definitions page.":::
3535
1. From the policy definition page, select **Assign**
3636
1. Select the **Parameters** tab.
3737
1. Select the Log Analytics Workspace that you want to send the audit logs to.
@@ -101,48 +101,47 @@ For more information on policy assignment using CLI, see [Azure CLI reference -
101101
To apply a policy using the PowerShell, use the following commands:
102102

103103
1. Set up your environment.
104-
Select your subscription and set your resource group
105-
```azurepowershell
106-
Select-AzSubscription <subscriptionID>
107-
$rg = Get-AzResourceGroup -Name <resource groups name>
108-
```
104+
Select your subscription and set your resource group
105+
```azurepowershell
106+
Select-AzSubscription <subscriptionID>
107+
$rg = Get-AzResourceGroup -Name <resource groups name>
108+
```
109109

110110
1. Get the policy definition and configure the parameters for the policy. In the example below we assign the policy to send keyVault logs to a Log Analytics workspace
111-
```azurepowershell
112-
$definition = Get-AzPolicyDefinition |Where-Object Name -eq 6b359d8f-f88d-4052-aa7c-32015963ecc1
113-
$params = @{"logAnalytics"="/subscriptions/<subscriptionID/resourcegroups/<resourcgroup>/providers/microsoft.operationalinsights/workspaces/<log anlaytics workspace name>"}
114-
```
111+
```azurepowershell
112+
$definition = Get-AzPolicyDefinition |Where-Object Name -eq 6b359d8f-f88d-4052-aa7c-32015963ecc1
113+
$params = @{"logAnalytics"="/subscriptions/<subscriptionID/resourcegroups/<resourcgroup>/providers/microsoft.operationalinsights/workspaces/<log anlaytics workspace name>"}
114+
```
115115

116116
1. Assign the policy
117-
```azurepowershell
118-
$policyAssignment=New-AzPolicyAssignment -Name <assignment name> -DisplayName "assignment display name" -Scope $rg.ResourceId -PolicyDefinition $definition -PolicyparameterObject $params -IdentityType 'SystemAssigned' -Location <location>
117+
```azurepowershell
118+
$policyAssignment=New-AzPolicyAssignment -Name <assignment name> -DisplayName "assignment display name" -Scope $rg.ResourceId -PolicyDefinition $definition -PolicyparameterObject $params -IdentityType 'SystemAssigned' -Location <location>
119119
120-
#To get your assignemnt use:
121-
$policyAssignment=Get-AzPolicyAssignment -Name '<assignment name>' -Scope '/subscriptions/<subscriptionID>/resourcegroups/<resource group name>'
120+
#To get your assignemnt use:
121+
$policyAssignment=Get-AzPolicyAssignment -Name '<assignment name>' -Scope '/subscriptions/<subscriptionID>/resourcegroups/<resource group name>'
122122
123-
```
123+
```
124124

125125
1. Assign the required role or roles to the system assigned Managed Identity
126-
```azurepowershell
127-
$principalID=$policyAssignment.Identity.PrincipalId
128-
$roleDefinitionIds=$definition.Properties.policyRule.then.details.roleDefinitionIds
129-
$roleDefinitionIds | ForEach-Object {
130-
$roleDefId = $_.Split("/") | Select-Object -Last 1
131-
New-AzRoleAssignment -Scope $rg.ResourceId -ObjectId $policyAssignment.Identity.PrincipalId -RoleDefinitionId $roleDefId
132-
}
133-
```
134-
135-
Start-AzPolicyComplianceScan -ResourceGroupName $rg.ResourceGroupName
126+
```azurepowershell
127+
$principalID=$policyAssignment.Identity.PrincipalId
128+
$roleDefinitionIds=$definition.Properties.policyRule.then.details.roleDefinitionIds
129+
$roleDefinitionIds | ForEach-Object {
130+
$roleDefId = $_.Split("/") | Select-Object -Last 1
131+
New-AzRoleAssignment -Scope $rg.ResourceId -ObjectId $policyAssignment.Identity.PrincipalId -RoleDefinitionId $roleDefId
132+
}
133+
```
134+
136135
1. Scan for compliance, then create a remediation task to force compliance for existing resources.
137-
```azurepowershell
138-
Start-AzPolicyComplianceScan -ResourceGroupName $rg.ResourceGroupName
139-
Start-AzPolicyRemediation -Name $policyAssignment.Name -PolicyAssignmentId $policyAssignment.PolicyAssignmentId -ResourceGroupName $rg.ResourceGroupName
140-
```
136+
```azurepowershell
137+
Start-AzPolicyComplianceScan -ResourceGroupName $rg.ResourceGroupName
138+
Start-AzPolicyRemediation -Name $policyAssignment.Name -PolicyAssignmentId $policyAssignment.PolicyAssignmentId -ResourceGroupName $rg.ResourceGroupName
139+
```
141140

142141
1. Check compliance
143-
```azurepowershell
144-
Get-AzPolicyState -PolicyAssignmentName $policyAssignment.Name -ResourceGroupName $policyAssignment.ResourceGroupName|select-object IsCompliant , ResourceID
145-
```
142+
```azurepowershell
143+
Get-AzPolicyState -PolicyAssignmentName $policyAssignment.Name -ResourceGroupName $policyAssignment.ResourceGroupName|select-object IsCompliant , ResourceID
144+
```
146145
---
147146
## Remediation tasks
148147

@@ -166,7 +165,7 @@ Track the status of your remediation task in the **Remediation tasks** tab of th
166165

167166

168167

169-
For more information on remediation tasks, see [Remediate non-compliant resources](../../governance/policy/how-to/remediate-resources.md)
168+
For more information on remediation tasks, see [Remediate noncompliant resources](../../governance/policy/how-to/remediate-resources.md)
170169

171170
## Assign initiatives
172171

@@ -191,19 +190,19 @@ In this example, we assign an initiative for sending audit logs to a Log Analyti
191190
1. On the **Basics** tab of the **Assign initiative** page, select a **Scope** that you want the initiative to apply to.
192191
1. Enter a name in the **Assignment name** field.
193192
1. Select the **Parameters** tab.
194-
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/assign-initiatives-basics.png" alt-text="A screenshot showing the assign initiatives basics tab":::
193+
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/assign-initiatives-basics.png" alt-text="A screenshot showing the assign initiatives basics tab.":::
195194

196195
The **Parameters** contains the parameters defined in the policy. In this case, we need to select the Log Analytics workspace that we want to send the logs to. For more information in the individual parameters for each policy, see [Policy-specific parameters](#policy-specific-parameters).
197196

198197
1. Select the **Log Analytics workspace** to send your audit logs to.
199198

200199
1. Select **Review + create** then **Create**
201-
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/assign-initiatives-parameters.png" alt-text="A screenshot showing the assign initiatives parameters tab":::
200+
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/assign-initiatives-parameters.png" alt-text="A screenshot showing the assign initiatives parameters tab.":::
202201

203202
To verify that your policy or initiative assignment is working, create a resource in the subscription or resource group scope that you defined in your policy assignment.
204203

205204
After 10 minutes, select the **Diagnostics settings** page for your resource.
206-
Your diagnostic setting appears in the list with the default name *setByPolicy-LogAnalytics and the workspace name that you configured in the policy.
205+
Your diagnostic setting appears in the list with the default name *setByPolicy-LogAnalytics* and the workspace name that you configured in the policy.
207206

208207
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/diagnostics-settings.png" alt-text="A screenshot showing the Diagnostics setting page for a resource.":::
209208

@@ -256,7 +255,7 @@ Log Analytics*, ResourceID "/providers/Microsoft.Authorization/policySetDefinit
256255
$policyDefinitionReferenceIds=$assignmentState.PolicyDefinitionReferenceId;
257256
```
258257
259-
1. For each resource type with non-compliant resources, start a remediation task.
258+
1. For each resource type with noncompliant resources, start a remediation task.
260259
```azurepowershell
261260
$policyDefinitionReferenceIds | ForEach-Object {
262261
$referenceId = $_

articles/azure-monitor/toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ items:
199199
- name: Create Diagnostic Settings with Azure Policy
200200
displayName: Diagnostic Settings, Platform logs, Resource logs, Activity log
201201
href: essentials/diagnostic-settings-policy.md
202+
- name: Enable Diagnostics settings using built-in policies.
203+
displayName: Diagnostic Settings, Platform logs, Resource logs, Activity log
204+
href: essentials/diagnostics-settings-policies-deployifnotexists.md
202205
- name: Transformations
203206
items:
204207
- name: Overview

0 commit comments

Comments
 (0)