1.3 Design governance
1.You have an Azure subscription containing a resource group named 'RG-App1'. You need to ensure that when users create resources in 'RG-App1', a tag named 'CostCenter' with a value of '101' is automatically added if the user does not specify it. If the user specifies a different value, that value should be preserved. Which Azure Policy effect should you use?
- A.Deny
- B.Append
- C.Modify
- D.AuditIfNotExists
Show answer & explanation
Correct answer: B — Append
- A. Incorrect. The 'Deny' effect would block the creation or update of any resource that does not already have the 'CostCenter' tag. The requirement is to automatically add the tag if it's missing, not to prevent the resource's creation.
- B. Correct. The 'Append' effect is specifically designed for this scenario. It adds specified fields, such as a tag, to a resource during creation or update if that field is missing. Crucially, it does not overwrite an existing value if the user provides one, thus preserving any user-specified 'CostCenter' tag value.
- C. Incorrect. The 'Modify' effect can add, update, or remove properties on a resource. While it could be used to add a tag, it is more commonly used to enforce a specific value by overwriting whatever the user provides. 'Append' is the more precise and less intrusive effect for adding a tag only when it is absent.
- D. Incorrect. The 'AuditIfNotExists' effect does not alter resources. It is used to audit and report on resources that lack a specified property or configuration, creating a non-compliance event. It does not add or modify tags.