diff --git a/.github/workflows/ms.cache.redis.yml b/.github/workflows/ms.cache.redis.yml index 9666ec63c0..b956542d52 100644 --- a/.github/workflows/ms.cache.redis.yml +++ b/.github/workflows/ms.cache.redis.yml @@ -106,8 +106,7 @@ jobs: - name: 'Using test file [${{ matrix.moduleTestFilePaths }}]' uses: ./.github/actions/templates/validateModuleDeployment with: - templateFilePath: '${{ env.modulePath }}/deploy.bicep' - parameterFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' + templateFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' location: '${{ env.location }}' resourceGroupName: '${{ env.resourceGroupName }}' subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' diff --git a/modules/Microsoft.Cache/redis/.test/common/dependencies.bicep b/modules/Microsoft.Cache/redis/.test/common/dependencies.bicep new file mode 100644 index 0000000000..a0300f449e --- /dev/null +++ b/modules/Microsoft.Cache/redis/.test/common/dependencies.bicep @@ -0,0 +1,47 @@ +@description('Optional. The location to deploy resources to.') +param location string = resourceGroup().location + +@description('Required. The name of the Virtual Network to create.') +param virtualNetworkName string + +resource virtualNetwork 'Microsoft.Network/virtualNetworks@2022-01-01' = { + name: virtualNetworkName + location: location + properties: { + addressSpace: { + addressPrefixes: [ + '10.0.0.0/24' + ] + } + subnets: [ + { + name: 'defaultSubnet' + properties: { + addressPrefix: '10.0.0.0/24' + } + } + ] + } +} + +resource privateDNSZone 'Microsoft.Network/privateDnsZones@2020-06-01' = { + name: 'privatelink.azuresynapse.net' + location: 'global' + + resource virtualNetworkLinks 'virtualNetworkLinks@2020-06-01' = { + name: '${virtualNetwork.name}-vnetlink' + location: 'global' + properties: { + virtualNetwork: { + id: virtualNetwork.id + } + registrationEnabled: false + } + } +} + +@description('The resource ID of the created Virtual Network Subnet.') +output subnetResourceId string = virtualNetwork.properties.subnets[0].id + +@description('The resource ID of the created Private DNS Zone.') +output privateDNSResourceId string = privateDNSZone.id diff --git a/modules/Microsoft.Cache/redis/.test/common/deploy.test.bicep b/modules/Microsoft.Cache/redis/.test/common/deploy.test.bicep new file mode 100644 index 0000000000..05ebac680e --- /dev/null +++ b/modules/Microsoft.Cache/redis/.test/common/deploy.test.bicep @@ -0,0 +1,88 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for testing purposes.') +@maxLength(90) +param resourceGroupName string = 'ms.cache.redis-${serviceShort}-rg' + +@description('Optional. The location to deploy resources to.') +param location string = deployment().location + +@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.') +param serviceShort string = 'crcom' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +module resourceGroupResources 'dependencies.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, location)}-paramNested' + params: { + virtualNetworkName: 'dep-<>-vnet-${serviceShort}' + } +} + +// Diagnostics +// =========== +module diagnosticDependencies '../../../../.shared/dependencyConstructs/diagnostic.dependencies.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name, location)}-diagnosticDependencies' + params: { + storageAccountName: 'dep<>diasa${serviceShort}01' + logAnalyticsWorkspaceName: 'dep-<>-law-${serviceShort}' + eventHubNamespaceEventHubName: 'dep-<>-evh-${serviceShort}' + eventHubNamespaceName: 'dep-<>-evhns-${serviceShort}' + location: location + } +} + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: '<>${serviceShort}001' + capacity: 2 + diagnosticLogsRetentionInDays: 7 + diagnosticStorageAccountId: diagnosticDependencies.outputs.storageAccountResourceId + diagnosticWorkspaceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId + diagnosticEventHubAuthorizationRuleId: diagnosticDependencies.outputs.eventHubAuthorizationRuleId + diagnosticEventHubName: diagnosticDependencies.outputs.eventHubNamespaceEventHubName + diagnosticSettingsName: 'redisdiagnostics' + enableNonSslPort: true + lock: 'CanNotDelete' + minimumTlsVersion: '1.2' + privateEndpoints: [ + { + privateDnsZoneGroup: { + privateDNSResourceIds: [ + resourceGroupResources.outputs.privateDNSResourceId + ] + } + service: 'redisCache' + subnetResourceId: resourceGroupResources.outputs.subnetResourceId + } + ] + publicNetworkAccess: 'Enabled' + redisVersion: '6' + shardCount: 1 + skuName: 'Premium' + systemAssignedIdentity: true + tags: { + resourceType: 'Redis Cache' + } + } +} diff --git a/modules/Microsoft.Cache/redis/.test/min.parameters.json b/modules/Microsoft.Cache/redis/.test/min.parameters.json deleted file mode 100644 index 1c7bb6e809..0000000000 --- a/modules/Microsoft.Cache/redis/.test/min.parameters.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-redis-min-001" - } - } -} diff --git a/modules/Microsoft.Cache/redis/.test/min/deploy.test.bicep b/modules/Microsoft.Cache/redis/.test/min/deploy.test.bicep new file mode 100644 index 0000000000..c36896ba63 --- /dev/null +++ b/modules/Microsoft.Cache/redis/.test/min/deploy.test.bicep @@ -0,0 +1,37 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for testing purposes.') +@maxLength(90) +param resourceGroupName string = 'ms.cache.redis-${serviceShort}-rg' + +@description('Optional. The location to deploy resources to.') +param location string = deployment().location + +@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.') +param serviceShort string = 'crmin' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: '<>${serviceShort}001' + } +} diff --git a/modules/Microsoft.Cache/redis/.test/parameters.json b/modules/Microsoft.Cache/redis/.test/parameters.json deleted file mode 100644 index f9b301cde1..0000000000 --- a/modules/Microsoft.Cache/redis/.test/parameters.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-redis-full-001" - }, - "capacity": { - "value": 2 - }, - "diagnosticLogCategoriesToEnable": { - "value": [ - "ApplicationGatewayAccessLog", - "ApplicationGatewayFirewallLog" - ] - }, - "diagnosticMetricsToEnable": { - "value": [ - "AllMetrics" - ] - }, - "enableNonSslPort": { - "value": true - }, - "lock": { - "value": "CanNotDelete" - }, - "minimumTlsVersion": { - "value": "1.2" - }, - "diagnosticSettingsName": { - "value": "redisdiagnostics" - }, - "publicNetworkAccess": { - "value": "Enabled" - }, - "redisVersion": { - "value": "6" - }, - "skuName": { - "value": "Premium" - }, - "systemAssignedIdentity": { - "value": true - }, - "shardCount": { - "value": 1 - }, - "tags": { - "value": { - "resourceType": "Redis Cache" - } - }, - "privateEndpoints": { - "value": [ - { - "subnetResourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-005-privateEndpoints", - "service": "redisCache", - "privateDnsZoneGroup": { - "privateDNSResourceIds": [ - "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net" - ] - } - } - ] - } - } -} diff --git a/modules/Microsoft.Cache/redis/deploy.bicep b/modules/Microsoft.Cache/redis/deploy.bicep index 2278ab6f12..9daa4d2e36 100644 --- a/modules/Microsoft.Cache/redis/deploy.bicep +++ b/modules/Microsoft.Cache/redis/deploy.bicep @@ -119,14 +119,10 @@ param diagnosticEventHubName string = '' @description('Optional. The name of logs that will be streamed.') @allowed([ - 'ApplicationGatewayAccessLog' - 'ApplicationGatewayPerformanceLog' - 'ApplicationGatewayFirewallLog' + 'ConnectedClientList' ]) param diagnosticLogCategoriesToEnable array = [ - 'ApplicationGatewayAccessLog' - 'ApplicationGatewayPerformanceLog' - 'ApplicationGatewayFirewallLog' + 'ConnectedClientList' ] @description('Optional. The name of metrics that will be streamed.') diff --git a/modules/Microsoft.Cache/redis/readme.md b/modules/Microsoft.Cache/redis/readme.md index 94cc75db9d..67669e0e7b 100644 --- a/modules/Microsoft.Cache/redis/readme.md +++ b/modules/Microsoft.Cache/redis/readme.md @@ -34,7 +34,7 @@ This module deploys a Redis Cache service. | `capacity` | int | `1` | `[0, 1, 2, 3, 4, 5, 6]` | The size of the Redis cache to deploy. Valid values: for C (Basic/Standard) family (0, 1, 2, 3, 4, 5, 6), for P (Premium) family (1, 2, 3, 4). | | `diagnosticEventHubAuthorizationRuleId` | string | `''` | | Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to. | | `diagnosticEventHubName` | string | `''` | | Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. For security reasons, it is recommended to set diagnostic settings to send data to either storage account, log analytics workspace or event hub. | -| `diagnosticLogCategoriesToEnable` | array | `[ApplicationGatewayAccessLog, ApplicationGatewayFirewallLog, ApplicationGatewayPerformanceLog]` | `[ApplicationGatewayAccessLog, ApplicationGatewayFirewallLog, ApplicationGatewayPerformanceLog]` | The name of logs that will be streamed. | +| `diagnosticLogCategoriesToEnable` | array | `[ConnectedClientList]` | `[ConnectedClientList]` | The name of logs that will be streamed. | | `diagnosticLogsRetentionInDays` | int | `365` | | Specifies the number of days that logs will be kept for; a value of 0 will retain data indefinitely. | | `diagnosticMetricsToEnable` | array | `[AllMetrics]` | `[AllMetrics]` | The name of metrics that will be streamed. | | `diagnosticSettingsName` | string | `[format('{0}-diagnosticSettings', parameters('name'))]` | | The name of the diagnostic setting, if deployed. | @@ -336,7 +336,7 @@ The following module usage examples are retrieved from the content of the files >**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order. -

Example 1: Min

+

Example 1: Common

@@ -344,57 +344,18 @@ The following module usage examples are retrieved from the content of the files ```bicep module redis './Microsoft.Cache/redis/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Redis' - params: { - name: '<>-az-redis-min-001' - } -} -``` - -
-

- -

- -via JSON Parameter file - -```json -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-redis-min-001" - } - } -} -``` - -
-

- -

Example 2: Parameters

- -
- -via Bicep module - -```bicep -module redis './Microsoft.Cache/redis/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Redis' + name: '${uniqueString(deployment().name)}-test-crcom' params: { // Required parameters - name: '<>-az-redis-full-001' + name: '<>crcom001' // Non-required parameters capacity: 2 - diagnosticLogCategoriesToEnable: [ - 'ApplicationGatewayAccessLog' - 'ApplicationGatewayFirewallLog' - ] - diagnosticMetricsToEnable: [ - 'AllMetrics' - ] + diagnosticEventHubAuthorizationRuleId: '' + diagnosticEventHubName: '' + diagnosticLogsRetentionInDays: 7 diagnosticSettingsName: 'redisdiagnostics' + diagnosticStorageAccountId: '' + diagnosticWorkspaceId: '' enableNonSslPort: true lock: 'CanNotDelete' minimumTlsVersion: '1.2' @@ -402,11 +363,11 @@ module redis './Microsoft.Cache/redis/deploy.bicep' = { { privateDnsZoneGroup: { privateDNSResourceIds: [ - '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net' + '' ] } service: 'redisCache' - subnetResourceId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-005-privateEndpoints' + subnetResourceId: '' } ] publicNetworkAccess: 'Enabled' @@ -435,26 +396,30 @@ module redis './Microsoft.Cache/redis/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "<>-az-redis-full-001" + "value": "<>crcom001" }, // Non-required parameters "capacity": { "value": 2 }, - "diagnosticLogCategoriesToEnable": { - "value": [ - "ApplicationGatewayAccessLog", - "ApplicationGatewayFirewallLog" - ] + "diagnosticEventHubAuthorizationRuleId": { + "value": "" }, - "diagnosticMetricsToEnable": { - "value": [ - "AllMetrics" - ] + "diagnosticEventHubName": { + "value": "" + }, + "diagnosticLogsRetentionInDays": { + "value": 7 }, "diagnosticSettingsName": { "value": "redisdiagnostics" }, + "diagnosticStorageAccountId": { + "value": "" + }, + "diagnosticWorkspaceId": { + "value": "" + }, "enableNonSslPort": { "value": true }, @@ -469,11 +434,11 @@ module redis './Microsoft.Cache/redis/deploy.bicep' = { { "privateDnsZoneGroup": { "privateDNSResourceIds": [ - "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/privateDnsZones/privatelink.redis.cache.windows.net" + "" ] }, "service": "redisCache", - "subnetResourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-005-privateEndpoints" + "subnetResourceId": "" } ] }, @@ -503,3 +468,40 @@ module redis './Microsoft.Cache/redis/deploy.bicep' = {

+ +

Example 2: Min

+ +
+ +via Bicep module + +```bicep +module redis './Microsoft.Cache/redis/deploy.bicep' = { + name: '${uniqueString(deployment().name)}-test-crmin' + params: { + name: '<>crmin001' + } +} +``` + +
+

+ +

+ +via JSON Parameter file + +```json +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "name": { + "value": "<>crmin001" + } + } +} +``` + +
+