A company has a policy that all Azure Storage accounts must have diagnostic settings enabled to send logs and metrics to a specific Log Analytics workspace. The governance team wants to automatically configure these diagnostic settings when a new storage account is created, without blocking the initial creation. The solution must not require manual intervention. Which Azure Policy effect should the team use in their policy definition?
Trap 1: Audit
The Audit effect generates a compliance log entry whenever a storage account without diagnostic settings is found, but it performs no deployment or modification. It only signals that the resource does not meet the policy condition, leaving the diagnostic setting absent. Because the requirement is to enforce automatic configuration, Audit alone cannot satisfy it—it lacks any mechanism to add the missing diagnostic setting.
Trap 2: Deny
Deny prevents the creation of resources that do not meet the policy condition. In this case, it would block the creation of a storage account that lacks diagnostic settings, which contradicts the requirement to allow creation and then automatically configure.
Trap 3: Append
Append is used to add additional fields or properties to an existing resource during creation or update, such as adding a tag. It cannot deploy a separate resource like a diagnostic setting, so it is not suitable for this scenario.
- A
DeployIfNotExists
DeployIfNotExists is the correct effect because it automatically deploys a diagnostic setting to any Azure Storage account that is missing one during policy evaluation. When the policy assignment's managed identity has the necessary Azure RBAC permissions (e.g., Storage Account Contributor or Monitor Contributor), it creates the diagnostic setting without blocking the storage account's creation. This effect also supports remediation tasks to fix existing non-compliant accounts, ensuring the policy requirement is enforced continuously.
- B
Audit
Why wrong: The Audit effect generates a compliance log entry whenever a storage account without diagnostic settings is found, but it performs no deployment or modification. It only signals that the resource does not meet the policy condition, leaving the diagnostic setting absent. Because the requirement is to enforce automatic configuration, Audit alone cannot satisfy it—it lacks any mechanism to add the missing diagnostic setting.
- C
Deny
Why wrong: Deny prevents the creation of resources that do not meet the policy condition. In this case, it would block the creation of a storage account that lacks diagnostic settings, which contradicts the requirement to allow creation and then automatically configure.
- D
Append
Why wrong: Append is used to add additional fields or properties to an existing resource during creation or update, such as adding a tag. It cannot deploy a separate resource like a diagnostic setting, so it is not suitable for this scenario.