Skip to content

Commit 1682265

Browse files
authored
Merge pull request #231105 from EdB-MSFT/policy-hub-fix
Policy hub fix
2 parents 6200b71 + 942cedf commit 1682265

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

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

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ ms.reviewer: lualderm
1313
Policies and policy initiatives provide a simple method to enable logging at-scale via diagnostics settings for Azure Monitor. Using a policy initiative, you can turn on audit logging for all [supported resources](#supported-resources) in your Azure environment.
1414

1515
Enable resource logs to track activities and events that take place on your resources and give you visibility and insights into any changes that occur.
16-
Assign policies to enable resource logs and to send them to destinations according to your needs. Send logs to Event Hubs for third-party SIEM systems, enabling continuous security operations. Send logs to storage accounts for longer term storage or the fulfillment of regulatory compliance.
16+
Assign policies to enable resource logs and to send them to destinations according to your needs. Send logs to event hubs for third-party SIEM systems, enabling continuous security operations. Send logs to storage accounts for longer term storage or the fulfillment of regulatory compliance.
1717

18-
A set of built-in policies and initiatives exists to direct resource logs to Log Analytics Workspaces, Event Hubs, and Storage Accounts. The policies enable audit logging, sending logs belonging to the **audit** log category group to an Event Hub, Log Analytics workspace or Storage Account. The policies' `effect` is `DeployIfNotExists`, which deploys the policy as a default if there aren't other settings defined.
18+
A set of built-in policies and initiatives exists to direct resource logs to Log Analytics Workspaces, Event Hubs, and Storage Accounts. The policies enable audit logging, sending logs belonging to the **audit** log category group to an event hub, Log Analytics workspace or Storage Account. The policies' `effect` is `DeployIfNotExists`, which deploys the policy as a default if there aren't other settings defined.
1919

2020

2121
## Deploy policies.
@@ -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" lightbox="./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.
@@ -77,6 +77,12 @@ Find the role in the policy definition by searching for *roleDefinitionIds*
7777
```azurecli
7878
az policy assignment identity assign --system-assigned --resource-group rg-001 --role 92aaf0da-9dab-42b6-94a3-d43ce8d16293 --identity-scope /subscriptions/12345678-aaaa-bbbb-cccc-1234567890ab/resourceGroups/rg001 --name policy-assignment-1
7979
```
80+
81+
When assigning policies that send logs to event hubs, you must manually add the *Azure Event Hubs Data Owner* role for the event hub to your policy assigned identity.
82+
83+
```azurecli
84+
az role assignment create --assignee <Principal ID> --role "Azure Event Hubs Data Owner" --scope /subscriptions/<subscription ID>/resourceGroups/<event hub's resource group>
85+
```
8086
1. Trigger a scan to find existing resources using [`az policy state trigger-scan`](https://learn.microsoft.com/cli/azure/policy/state?view=azure-cli-latest#az-policy-state-trigger-scan).
8187

8288
```azurecli
@@ -131,6 +137,10 @@ To apply a policy using the PowerShell, use the following commands:
131137
New-AzRoleAssignment -Scope $rg.ResourceId -ObjectId $policyAssignment.Identity.PrincipalId -RoleDefinitionId $roleDefId
132138
}
133139
```
140+
When assigning policies that send logs to event hubs, you must manually add the *Azure Event Hubs Data Owner* role for the event hub to your system assigned Managed Identity.
141+
```azurepowershell
142+
New-AzRoleAssignment -Scope /subscriptions/<subscription ID>/resourceGroups/<event hub's resource group> -ObjectId $policyAssignment.Identity.PrincipalId -RoleDefinitionId "Azure Event Hubs Data Owner"
143+
```
134144

135145
1. Scan for compliance, then create a remediation task to force compliance for existing resources.
136146
```azurepowershell
@@ -143,6 +153,22 @@ To apply a policy using the PowerShell, use the following commands:
143153
Get-AzPolicyState -PolicyAssignmentName $policyAssignment.Name -ResourceGroupName $policyAssignment.ResourceGroupName|select-object IsCompliant , ResourceID
144154
```
145155
---
156+
157+
> [!Note]
158+
> When assigning policies that send logs to event hubs, you must manually add the *Azure Event Hubs Data Owner* role for the event hub to your policy assigned identity.
159+
> Use the `az role assignment create` Azure CLI command.
160+
> ```azurecli
161+
> az role assignment create --assignee <Principal ID> --role "Azure Event Hubs Data Owner" --scope /subscriptions/<subscription ID>/resourceGroups/<event hub's resource group>
162+
>```
163+
> For example:
164+
> ```azurecli
165+
> az role assignment create --assignee xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --role "Azure Event Hubs Data Owner" --scope /subscriptions/yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy/resourceGroups/myResourceGroup
166+
>```
167+
>
168+
> Find your principal ID on the **Policy Assignment** page, **Managed Identity** tab.
169+
> :::image type="content" source="./media/diagnostics-settings-policies-deployifnotexists/find-principal.png" alt-text="A screenshot showing the policy assignment page, managed identity tab.":::
170+
171+
146172
## Remediation tasks
147173
148174
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.
@@ -359,13 +385,13 @@ The following table describes the common parameters for each set of policies.
359385
360386
### Event Hubs policy parameters
361387
362-
This policy deploys a diagnostic setting using a category group to route logs to an Event Hub.
388+
This policy deploys a diagnostic setting using a category group to route logs to an event hub.
363389
364390
|Parameter| Description| Valid Values|Default|
365391
|---|---|---|---|
366392
|resourceLocation|Resource Location must be the same location as the event hub Namespace|Supported locations||
367-
|eventHubAuthorizationRuleId|Event Hub Authorization Rule ID. The authorization rule is at event hub namespace level. For example, /subscriptions/{subscription ID}/resourceGroups/{resource group}/providers/Microsoft.EventHub/namespaces/{Event Hub namespace}/authorizationrules/{authorization rule}|||
368-
|eventHubName|Event Hub Name||Monitoring|
393+
|eventHubAuthorizationRuleId|Event hub Authorization Rule ID. The authorization rule is at event hub namespace level. For example, /subscriptions/{subscription ID}/resourceGroups/{resource group}/providers/Microsoft.EventHub/namespaces/{Event Hub namespace}/authorizationrules/{authorization rule}|||
394+
|eventHubName|Event hub name||Monitoring|
369395
370396
371397
### Storage Accounts policy parameters
69.7 KB
Loading
-21.7 KB
Loading

0 commit comments

Comments
 (0)