Private DNS zones require location explicitly set to deploy
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Bicep version**
0.42.1
**Describe the bug**
When creating private dns zone location specification required.
**To Reproduce**
I have a policy which resticts deployment to the following regions 'uksouth', 'northeurope' or 'global'
When deploying a private dns zone.
{"code": "InvalidTemplateDeployment", "message": "The template deployment failed because of policy violation. Please see details for more information."}
Inner Errors:
{"code": "RequestDisallowedByPolicy", "target": "REDACTED", "message": "Resource 'REDACTED' was disallowed by policy. Reasons: 'This region is not supported. Please contact IT Operations.'. See error details for policy resource IDs.", "additionalInfo": [{"type": "PolicyViolation", "info": {"evaluationDetails": {"evaluatedExpressions": [{"result": "True", "expressionKind": "Field", "expression": "location", "path": "location", "targetValue": ["northeurope", "uksouth", "global"], "operator": "NotIn"}, {"result": "True", "expressionKind": "Field", "expression": "location", "path": "location", "targetValue": "global", "operator": "NotEquals"}, {"result": "True", "expressionKind": "Field", "expression": "type", "path": "type", "expressionValue": "Microsoft.Sql/servers/databases", "targetValue": "Microsoft.AzureActiveDirectory/b2cDirectories", "operator": "NotEquals"}], "reason": "This region is not supported. Please contact IT Operations."}, "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/e56962a6-4747-49cd-b67b-bf8b01975c4c", "policyDefinitionName": "e56962a6-4747-49cd-b67b-bf8b01975c4c", "policyDefinitionDisplayName": "Allowed locations", "policyDefinitionVersion": "1.1.0", "policyDefinitionEffect": "Deny", "policyAssignmentId": "REDACTED", "policyAssignmentName": "1ebfb4d5e8a34f899b8c4f4e", "policyAssignmentDisplayName": "Allowed locations", "policyAssignmentScope": "/providers/microsoft.management/managementgroups/nccmanagementgroup", "policyAssignmentParameters": {"listOfAllowedLocations": ["northeurope", "uksouth", "global"]}, "policyExemptionIds": [], "policyEnrollmentIds": []}}]}
Private DNS zones are always created in global however bicep required me to specify the location explicitly in the file to process this.
However the following az command worked
az network private-dns zone create ` --resource-group rg-bus-systems-dev-01 ` --name privatelink.test.local
however in bicep i needed to specify the location so.
For example:
resource blobDns 'Microsoft.Network/privateDnsZones@2024-06-01' = {
name: 'privatelink.blob.core.windows.net'
tags: union(tags, {
ResourceType: 'Private DNS Zone'
})
}
does not work but specifying
resource blobDns 'Microsoft.Network/privateDnsZones@2024-06-01' = {
name: 'privatelink.blob.core.windows.net'
location: 'global'
tags: union(tags, {
ResourceType: 'Private DNS Zone'
})
}
Does work.
I shouldn't need to specify this in the bicep file as all private dns zones are created in global.
**Additional context**
Add any other context about the problem here.
Contributor guide
Research direction
Start with the Microsoft.Network/privateDnsZones@2024-06-01 resource behavior and compare the Bicep declaration without location against the working Azure CLI command. Done means a private DNS zone can omit location while deploying as global under the stated allowed-location policy, with a regression test covering the declaration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100