Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report]: Microsoft.Cache/redis - privateDnsZoneGroups was provided an invalid value #1795

Closed
DanielLarsenNZ opened this issue Aug 19, 2022 · 2 comments
Assignees
Labels
bug Something isn't working [cat] modules category: modules

Comments

@DanielLarsenNZ
Copy link
Contributor

Describe the bug

When deploying Azure Redis Cache with a private endpoint and the privateDnsZoneGroups param is not set, the deployment fails with:

Template parameter 'privateDnsZoneGroups' was provided an invalid value. Expected a value of type 'Array', but received a value of type 'Object'

The problem is that line 256 defaults to an empty object instead of an empty array:

privateDnsZoneGroup: contains(privateEndpoint, 'privateDnsZoneGroup') ? privateEndpoint.privateDnsZoneGroup : {}

https://github.com/Azure/ResourceModules/blob/main/modules/Microsoft.Cache/redis/deploy.bicep#L256

The line should be changed to:

privateDnsZoneGroup: contains(privateEndpoint, 'privateDnsZoneGroup') ? privateEndpoint.privateDnsZoneGroup : []

To reproduce

Run this bicep:

module vnetModule 'modules/Microsoft.Network/virtualNetworks/deploy.bicep' = {
  name: 'vnet'
  params: {
    location: location
    addressPrefixes: [
      '10.0.0.0/16'
    ]
    name: vnet
    subnets: [
      {
        addressPrefix: '10.0.4.0/24'
        name: 'redis'
        privateEndpointNetworkPolicies: 'Disabled'
        privateLinkServiceNetworkPolicies: 'Enabled'
      }
    ]
  }
}

module privateRedisDnsZone 'modules/Microsoft.Network/privateDnsZones/deploy.bicep' = {
  name: 'privateRedisDnsZone'
  params: {
    name: 'privatelink.redis.cache.windows.net'
  }
}

module redisCacheModule 'modules/Microsoft.Cache/redis/deploy.bicep' = {
  name: redis
  params: {
    name: redis
    location: location
    skuName: 'Premium'
    capacity: 1
    privateEndpoints: [
      {
        name: '${redis}-pep'
        subnetResourceId: vnetModule.outputs.subnetResourceIds[4]
        service: 'redisCache'
        privateDnsZoneResourceIds: [
          privateRedisDnsZone.outputs.resourceId
        ]
      }
    ]
    publicNetworkAccess: 'Disabled'
  }
}

Deployment will throw "'Template parameter 'privateDnsZoneGroups' was provided an invalid value. Expected a value of type 'Array', but received a value of type 'Object'."

Code snippet

No response

Relevant log output

{"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"Conflict","message":"{\r\n  \"status\": \"Failed\",\r\n  \"error\": {\r\n    \"code\": \"ResourceDeploymentFailure\",\r\n    \"message\": \"The resource operation completed with terminal provisioning state 'Failed'.\",\r\n    \"details\": [\r\n      {\r\n        \"code\": \"DeploymentFailed\",\r\n        \"message\": \"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.\",\r\n        \"details\": [\r\n          {\r\n            \"code\": \"BadRequest\",\r\n            \"message\": \"{\\r\\n  \\\"error\\\": {\\r\\n    \\\"code\\\": \\\"InvalidTemplate\\\",\\r\\n    \\\"message\\\": \\\"Deployment template validation failed: 'Template parameter 'privateDnsZoneGroups' was provided an invalid value. Expected a value of type 'Array', but received a value of type 'Object'. Please see https://aka.ms/resource-manager-parameter-files for usage details.'.\\\",\\r\\n    \\\"additionalInfo\\\": [\\r\\n      {\\r\\n        \\\"type\\\": \\\"TemplateViolation\\\",\\r\\n        \\\"info\\\": {\\r\\n          \\\"lineNumber\\\": 1,\\r\\n          \\\"linePosition\\\": 1668,\\r\\n          \\\"path\\\": \\\"properties.template.parameters.privateDnsZoneGroups\\\"\\r\\n        }\\r\\n      }\\r\\n    ]\\r\\n  }\\r\\n}\"\r\n          }\r\n        ]\r\n      }\r\n    ]\r\n  }\r\n}"}]}}
@DanielLarsenNZ DanielLarsenNZ added the bug Something isn't working label Aug 19, 2022
@DanielLarsenNZ
Copy link
Contributor Author

I will create a PR for this.

DanielLarsenNZ added a commit to DanielLarsenNZ/ResourceModules that referenced this issue Aug 23, 2022
@AlexanderSehr AlexanderSehr added the [cat] modules category: modules label Aug 25, 2022
@eriqua
Copy link
Contributor

eriqua commented Oct 24, 2022

Closing as agreed in PR #1799. The issue was caused by incorrect parameter usage documentation and fixed by PR #1805

@eriqua eriqua closed this as completed Oct 24, 2022
@rahalan rahalan moved this to Closed in Bug board Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working [cat] modules category: modules
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

4 participants