Skip to content

[Bug Report]: Microsoft.Cache/redis Premium deploys all replicas in Zone 1 #1793

@DanielLarsenNZ

Description

@DanielLarsenNZ

Describe the bug

I think this is an oversight:

zones: skuName == 'Premium' ? pickZones('Microsoft.Cache', 'redis', location, 1) : null

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

When the target region has AZ's enabled, and Premium cache is selected, all replicas are deployed to Zone 1. A user should be able to choose which zones to use when opting for zone redundancy. Or they should be able to opt out of ZR and let the service decide where the replicas are deployed (I suspect replicas are deployed in an availability set when zones is not set).

Line 206 could be changed to:

zones: skuName == 'Premium' ? pickZones('Microsoft.Cache', 'redis', location, 3) : null

However, this will error if there are less than 3 zones in the Region (unlikely, but feasible). Also, some users may want all of their replicas in a particular zone or zones. I suggest that zones is converted to a param, i.e.

param zones array = []

// ...

zones: zones

When zones is set, ZR is enabled and the specified zones are used. When zones is not set (defaults to []) ZR is not enabled.

To reproduce

This bicep:

module redisCacheModule 'modules/Microsoft.Cache/redis/deploy.bicep' = {
  name: redis
  params: {
    name: redis
    location: 'westus2'
    skuName: 'Premium'
    capacity: 1
    replicasPerMaster: 2
    replicasPerPrimary: 2
    tags: tags
  }
}

Results in this deployment:

"instances": [
            {
                "sslPort": 15000,
                "zone": "1",
                "shardId": 0,
                "isMaster": false
            },
            {
                "sslPort": 15001,
                "zone": "1",
                "shardId": 0,
                "isMaster": true
            },
            {
                "sslPort": 15002,
                "zone": "1",
                "shardId": 0,
                "isMaster": false
            }
        ]
"zones": [
        "1"
    ]

Note that all replicas are deployed to zone 1.

Code snippet

No response

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

[cat] modulescategory: modulesbugSomething isn't working

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions