Skip to content

Commit 26dcb67

Browse files
committed
review
1 parent 68af60a commit 26dcb67

10 files changed

+89
-13
lines changed

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

Lines changed: 89 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ A set of built-in policies and initiatives exists to direct resource logs to Log
1919

2020
The policies enable audit logging, sending logs belonging to the **audit** log category group to an Event Hub, Log Analytics workspace or Storage Account.
2121

22-
The policies' `effect` is set to `DeployIfNotExists` which deploys the policy as a default if there are not other settings defined.
22+
The policies' `effect` is `DeployIfNotExists`, which deploys the policy as a default if there aren't other settings defined.
2323

2424

2525
## Deploy policies.
@@ -41,13 +41,13 @@ The following steps show how to apply the policy to send audit logs to for key v
4141
1. Select the Log Analytics Workspace that you want to send the audit logs to.
4242
1. Select the **Remediation** tab.
4343
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/assign-policy-parameters.png" alt-text="A screenshot of the assign policy page, parameters tab.":::
44-
1. On the remediation tab, select the the keyvault policy from the **Policy to remediate** dropdown.
44+
1. On the remediation tab, select the keyvault policy from the **Policy to remediate** dropdown.
4545
1. Select the **Create a Managed Identity** checkbox.
4646
1. Under **Type of Managed Identity**, select **System assigned Managed Identity**.
4747
1. Select **Review + create**, then select **Create** .
4848
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/assign-policy-remediation.png" alt-text="A screenshot of the assign policy page, remediation tab.":::
4949

50-
The policy will be applied to resources after approximately 30 minutes.
50+
The policy visible in the resources' diagnostic setting after approximately 30 minutes.
5151

5252
### [CLI](#tab/cli)
5353
To apply a policy using the CLI, use the following commands:
@@ -63,32 +63,107 @@ For example, to apply the policy to send audit logs to a log analytics workspace
6363
az policy assignment create --name "policy-assignment-1" --policy "6b359d8f-f88d-4052-aa7c-32015963ecc1" --scope /subscriptions/12345678-aaaa-bbbb-cccc-1234567890ab/resourceGroups/rg-001 --params "{\"logAnalytics\": {\"value\": \"/subscriptions/12345678-aaaa-bbbb-cccc-1234567890ab/resourcegroups/rg-001/providers/microsoft.operationalinsights/workspaces/workspace001\"}}" --mi-system-assigned --location eastus
6464
```
6565

66-
2. Assign the Contributor role to the identity created for the policy assignment
66+
2. Assign the required role to the identity created for the policy assignment.
67+
Find the role in the policy definition by searching for *role*
68+
69+
```json
70+
...},
71+
"roleDefinitionIds": [
72+
"/providers/Microsoft.Authorization/roleDefinitions/92aaf0da-9dab-42b6-94a3-d43ce8d16293"
73+
],
74+
"deployment": {
75+
"properties": {...
76+
```
6777

6878
```azurecli
69-
az policy assignment identity assign --system-assigned -g <resource group name> --role Contributor --identity-scope </scope> -n <policy assignment name>
79+
az policy assignment identity assign --system-assigned -g <resource group name> --role <role name or ID> --identity-scope </scope> -n <policy assignment name>
7080
```
71-
For example.
81+
For example:
82+
7283
```azurecli
73-
az policy assignment identity assign --system-assigned -g rg-001 --role Owner --identity-scope /subscriptions/12345678-aaaa-bbbb-cccc-1234567890ab/resourceGroups/rg001 -n policy-assignment-1
84+
az policy assignment identity assign --system-assigned -g rg-001 --role 92aaf0da-9dab-42b6-94a3-d43ce8d16293 --identity-scope /subscriptions/12345678-aaaa-bbbb-cccc-1234567890ab/resourceGroups/rg001 -n policy-assignment-1
7485
```
7586

7687
3. Create a remediation task to apply the policy to existing resources.
7788

7889
```azurecli
7990
az policy remediation create -g <resource group name> --policy-assignment <policy assignment name> --name <remediation name>
8091
```
92+
8193
For example,
8294
```azurecli
8395
az policy remediation create -g rg-001 -n remediation-001 --policy-assignment policy-assignment-1
8496
```
8597

86-
For more information on policy assignment using CLI see [Azure CLI reference - az policy assignment](https://learn.microsoft.com/cli/azure/policy/assignment?view=azure-cli-latest#az-policy-assignment-create)
98+
For more information on policy assignment using CLI, see [Azure CLI reference - az policy assignment](https://learn.microsoft.com/cli/azure/policy/assignment?view=azure-cli-latest#az-policy-assignment-create)
8799
### [PowerShell](#tab/Powershell)
88100

89-
Get form dev
101+
Get from dev
90102

91103
---
104+
## Assign initiatives
105+
In this example, we assign an initiative for sending audit logs to a Log Analytics workspace.
106+
107+
1. From the policy **Definitions** page, select your scope.
108+
109+
1. Select *Initiative* in the **Definition type** dropdown.
110+
1. Select *Monitoring* in the **Category** dropdown.
111+
1. Enter *audit* in the **Search** field.
112+
1. Select thee *Enable audit category group resource logging for supported resources to Log Analytics* initiative.
113+
1. On the following page, select **Assign**
114+
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/initiatives-definitions.png" alt-text="A screenshot showing the initiatives definitions page.":::
115+
116+
1. On the **Basics** tab of the **Assign initiative** page, select a **Scope** that you want the initiative to apply to.
117+
1. Enter a name in the **Assignment name** field.
118+
1. Select the **Parameters** tab.
119+
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/assign-initiatives-basics.png" alt-text="A screenshot showing the assign initiatives basics tab":::
120+
121+
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).
122+
123+
1. Select the **Log Analytics workspace** to send your audit logs to.
124+
125+
1. Select **Review + create** then **Create**
126+
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/assign-initiatives-parameters.png" alt-text="A screenshot showing the assign initiatives parameters tab":::
127+
128+
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.
129+
130+
After 10 minutes, select the **Diagnostics settings** page for your resource.
131+
Your diagnostic setting appears in the list with the default name *setByPolicy-LogAnalytics and the workspace name that you configured in the policy.
132+
133+
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/diagnostics-settings.png" alt-text="A screenshot showing the Diagnostics setting page for a resource.":::
134+
135+
Change the default name in the **Parameters** tab of the **Assign initiative** or policy page by unselecting the **Only show parameters that need input or review** checkbox.
136+
137+
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/edit-initiative-assignment.png" alt-text="A screenshot showing the edit-initiative-assignment page with the checkbox unselected.":::
138+
139+
## Remediation tasks
140+
141+
Policies are applied to new resources when they're created. To apply a policy to existing resources, create a remediation task. Remediation tasks bring resources into compliance with a policy.
142+
143+
Remediation tasks act for specific policies. For initiatives that contain multiple policies, create a remediation task for each policy in the initiative where you have resources that you want to bring into compliance.
144+
145+
Define remediation tasks when you first assign the policy, or at any stage after assignment.
146+
147+
To create a remediation task for policies during the policy assignment, select the **Remediation** tab on **Assign policy** page and select the **Create remediation task** checkbox.
148+
149+
To create a remediation task after the policy has been assigned, select your assigned policy from the list on the Policy Assignments page.
150+
151+
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/remediation-after-assignment.png" alt-text="A screenshot showing the edit-initiative-assignment page with the checkbox unselected.":::
152+
153+
Select **Remediate**.
154+
Track the status of your remediation task in the **Remediation tasks** tab of the Policy Remediation page.
155+
156+
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/new-remediation-task-after-assignment.png" alt-text="A screenshot showing the new remediation task page.":::
157+
158+
159+
160+
161+
For more information on remediation tasks, see [Remediate non-compliant resources](../../governance/policy/how-to/remediate-resources.md)
162+
163+
164+
165+
166+
92167
## Common parameters
93168

94169
The following table describes the common parameters for each set of policies.
@@ -99,15 +174,16 @@ The following table describes the common parameters for each set of policies.
99174
|diagnosticSettingName|Diagnostic Setting Name||setByPolicy-LogAnalytics|
100175
|categoryGroup|Diagnostic category group|none,<br>audit,<br>allLogs|audit|
101176

102-
## Log Analytics policy parameters
177+
## Policy-specific parameters
178+
### Log Analytics policy parameters
103179
This policy deploys a diagnostic setting using a category group to route logs to a Log Analytics workspace.
104180

105181
|Parameter| Description| Valid Values|Default|
106182
|---|---|---|---|
107183
|resourceLocationList|Resource Location List to send logs to nearby Log Analytics. <br>"*" selects all locations|Supported locations|\*|
108184
|logAnalytics|Log Analytics Workspace|||
109185

110-
## Event Hubs policy parameters
186+
### Event Hubs policy parameters
111187

112188
This policy deploys a diagnostic setting using a category group to route logs to an Event Hub.
113189

@@ -118,7 +194,7 @@ This policy deploys a diagnostic setting using a category group to route logs to
118194
|eventHubName|Event Hub Name||Monitoring|
119195

120196

121-
## Storage Accounts policy parameters
197+
### Storage Accounts policy parameters
122198
This policy deploys a diagnostic setting using a category group to route logs to a Storage Account.
123199

124200
|Parameter| Description| Valid Values|Default|
@@ -128,7 +204,7 @@ This policy deploys a diagnostic setting using a category group to route logs to
128204

129205
## Supported Resources
130206

131-
Built-in DeployIfNotExists policies exist for Log analytics, Event Hubs and Storage Accounts for the following resources:
207+
Built-in Audit logs policies for Log Analytics workspaces, Event Hubs, and Storage Accounts exist for the following resources:
132208

133209
* microsoft.agfoodplatform/farmbeats
134210
* microsoft.apimanagement/service
Loading
Loading
71.7 KB
Loading
Loading
Loading
Loading
57.4 KB
Loading
Loading
Loading

0 commit comments

Comments
 (0)