diff --git a/modules/cache/redis/.test/common/main.test.bicep b/modules/cache/redis/.test/common/main.test.bicep index 83aa08f07f..6caf65ac07 100644 --- a/modules/cache/redis/.test/common/main.test.bicep +++ b/modules/cache/redis/.test/common/main.test.bicep @@ -73,6 +73,8 @@ module testDeployment '../../main.bicep' = { enableNonSslPort: true lock: 'CanNotDelete' minimumTlsVersion: '1.2' + zoneRedundant: true + zones: [ 1, 2 ] privateEndpoints: [ { privateDnsZoneGroup: { diff --git a/modules/cache/redis/README.md b/modules/cache/redis/README.md index 6af7ae16c6..d38422843b 100644 --- a/modules/cache/redis/README.md +++ b/modules/cache/redis/README.md @@ -62,6 +62,8 @@ This module deploys a Redis Cache. | `tags` | object | `{object}` | | Tags of the resource. | | `tenantSettings` | object | `{object}` | | A dictionary of tenant settings. | | `userAssignedIdentities` | object | `{object}` | | The ID(s) to assign to the resource. | +| `zoneRedundant` | bool | `True` | | When true, replicas will be provisioned in availability zones specified in the zones parameter. | +| `zones` | array | `[]` | | If the zoneRedundant parameter is true, replicas will be provisioned in the availability zones specified here. Otherwise, the service will choose where replicas are deployed. | ### Parameter Usage: `roleAssignments` @@ -404,6 +406,11 @@ module redis './cache/redis/main.bicep' = { tags: { resourceType: 'Redis Cache' } + zoneRedundant: true + zones: [ + 1 + 2 + ] } } ``` @@ -494,6 +501,15 @@ module redis './cache/redis/main.bicep' = { "value": { "resourceType": "Redis Cache" } + }, + "zoneRedundant": { + "value": true + }, + "zones": { + "value": [ + 1, + 2 + ] } } } diff --git a/modules/cache/redis/main.bicep b/modules/cache/redis/main.bicep index d886a4fc3e..5452d68507 100644 --- a/modules/cache/redis/main.bicep +++ b/modules/cache/redis/main.bicep @@ -94,6 +94,12 @@ param subnetId string = '' @description('Optional. A dictionary of tenant settings.') param tenantSettings object = {} +@description('Optional. When true, replicas will be provisioned in availability zones specified in the zones parameter.') +param zoneRedundant bool = true + +@description('Optional. If the zoneRedundant parameter is true, replicas will be provisioned in the availability zones specified here. Otherwise, the service will choose where replicas are deployed.') +param zones array = [] + @description('Optional. Configuration details for private endpoints. For security reasons, it is recommended to use private endpoints whenever possible.') param privateEndpoints array = [] @@ -137,6 +143,8 @@ param diagnosticMetricsToEnable array = [ @description('Optional. Enable telemetry via a Globally Unique Identifier (GUID).') param enableDefaultTelemetry bool = true +var availabilityZones = skuName == 'Premium' ? zoneRedundant ? !empty(zones) ? zones : pickZones('Microsoft.Cache', 'redis', location, 3) : [] : [] + var diagnosticsLogsSpecified = [for category in filter(diagnosticLogCategoriesToEnable, item => item != 'allLogs'): { category: category enabled: true @@ -211,7 +219,7 @@ resource redisCache 'Microsoft.Cache/redis@2021-06-01' = { subnetId: !empty(subnetId) ? subnetId : null tenantSettings: tenantSettings } - zones: skuName == 'Premium' ? pickZones('Microsoft.Cache', 'redis', location, 1) : null + zones: availabilityZones } resource redisCache_lock 'Microsoft.Authorization/locks@2020-05-01' = if (!empty(lock)) {