You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/essentials/diagnostics-settings-policies-deployifnotexists.md
+89-13Lines changed: 89 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ A set of built-in policies and initiatives exists to direct resource logs to Log
19
19
20
20
The policies enable audit logging, sending logs belonging to the **audit** log category group to an Event Hub, Log Analytics workspace or Storage Account.
21
21
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.
23
23
24
24
25
25
## Deploy policies.
@@ -41,13 +41,13 @@ The following steps show how to apply the policy to send audit logs to for key v
41
41
1. Select the Log Analytics Workspace that you want to send the audit logs to.
42
42
1. Select the **Remediation** tab.
43
43
:::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.
45
45
1. Select the **Create a Managed Identity** checkbox.
46
46
1. Under **Type of Managed Identity**, select **System assigned Managed Identity**.
47
47
1. Select **Review + create**, then select **Create** .
48
48
:::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/assign-policy-remediation.png" alt-text="A screenshot of the assign policy page, remediation tab.":::
49
49
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.
51
51
52
52
### [CLI](#tab/cli)
53
53
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
3. Create a remediation task to apply the policy to existing resources.
77
88
78
89
```azurecli
79
90
az policy remediation create -g <resource group name> --policy-assignment <policy assignment name> --name <remediation name>
80
91
```
92
+
81
93
For example,
82
94
```azurecli
83
95
az policy remediation create -g rg-001 -n remediation-001 --policy-assignment policy-assignment-1
84
96
```
85
97
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)
87
99
### [PowerShell](#tab/Powershell)
88
100
89
-
Get form dev
101
+
Get from dev
90
102
91
103
---
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.
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.
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
+
92
167
## Common parameters
93
168
94
169
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.
0 commit comments