From c449cd1b7e4e909415c4aaa5d1c1d2481a63ecf1 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 16 Sep 2022 12:05:06 +0200 Subject: [PATCH 1/6] Update Network TrafficmanagerProfiles to new dependency approach --- .../ms.network.trafficmanagerprofiles.yml | 3 +- .../.test/common/dependencies.bicep | 14 ++++ .../.test/common/deploy.test.bicep | 74 +++++++++++++++++++ .../.test/min/deploy.test.bicep | 38 ++++++++++ .../.test/parameters.json | 40 ---------- 5 files changed, 127 insertions(+), 42 deletions(-) create mode 100644 modules/Microsoft.Network/trafficmanagerprofiles/.test/common/dependencies.bicep create mode 100644 modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep create mode 100644 modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep delete mode 100644 modules/Microsoft.Network/trafficmanagerprofiles/.test/parameters.json diff --git a/.github/workflows/ms.network.trafficmanagerprofiles.yml b/.github/workflows/ms.network.trafficmanagerprofiles.yml index 8df0887502..24e3f0f239 100644 --- a/.github/workflows/ms.network.trafficmanagerprofiles.yml +++ b/.github/workflows/ms.network.trafficmanagerprofiles.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.Network/trafficmanagerprofiles/.test/common/dependencies.bicep b/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/dependencies.bicep new file mode 100644 index 0000000000..7371d4437b --- /dev/null +++ b/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/dependencies.bicep @@ -0,0 +1,14 @@ +@description('Optional. The location to deploy to.') +param location string = resourceGroup().location + +@description('Required. The name of the Managed Identity to create.') +param managedIdentityName string + +resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { + name: managedIdentityName + location: location +} + +@description('The principal ID of the created Managed Identity.') +output managedIdentityPrincipalId string = managedIdentity.properties.principalId + diff --git a/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep b/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep new file mode 100644 index 0000000000..7e00c28c16 --- /dev/null +++ b/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep @@ -0,0 +1,74 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.network.trafficmanagerprofiles-${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 = 'ntmpcom' + +// =========== // +// 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: { + managedIdentityName: 'dep-<>-msi-${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 // +// ============== // +var resourceName = '<>${serviceShort}001' +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: resourceName + relativeName: resourceName + diagnosticLogsRetentionInDays: 7 + diagnosticStorageAccountId: diagnosticDependencies.outputs.storageAccountResourceId + diagnosticWorkspaceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId + diagnosticEventHubAuthorizationRuleId: diagnosticDependencies.outputs.eventHubAuthorizationRuleId + diagnosticEventHubName: diagnosticDependencies.outputs.eventHubNamespaceEventHubName + lock: 'CanNotDelete' + roleAssignments: [ + { + principalIds: [ + resourceGroupResources.outputs.managedIdentityPrincipalId + ] + roleDefinitionIdOrName: 'Reader' + } + ] + } +} diff --git a/modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep b/modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep new file mode 100644 index 0000000000..8b9d031d78 --- /dev/null +++ b/modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep @@ -0,0 +1,38 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.network.trafficmanagerprofiles-${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 = 'ntmpmin' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +// ============== // +// Test Execution // +// ============== // +var resourceName = '<>${serviceShort}001' +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: resourceName + relativeName: resourceName + } +} diff --git a/modules/Microsoft.Network/trafficmanagerprofiles/.test/parameters.json b/modules/Microsoft.Network/trafficmanagerprofiles/.test/parameters.json deleted file mode 100644 index 220f646c39..0000000000 --- a/modules/Microsoft.Network/trafficmanagerprofiles/.test/parameters.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "tm-000001" - }, - "lock": { - "value": "CanNotDelete" - }, - "relativeName": { - "value": "tm-000001" - }, - "roleAssignments": { - "value": [ - { - "roleDefinitionIdOrName": "Reader", - "principalIds": [ - "<>" - ] - } - ] - }, - "diagnosticLogsRetentionInDays": { - "value": 7 - }, - "diagnosticStorageAccountId": { - "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsax001" - }, - "diagnosticWorkspaceId": { - "value": "/subscriptions/<>/resourcegroups/validation-rg/providers/microsoft.operationalinsights/workspaces/adp-<>-az-law-x-001" - }, - "diagnosticEventHubAuthorizationRuleId": { - "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.EventHub/namespaces/adp-<>-az-evhns-x-001/AuthorizationRules/RootManageSharedAccessKey" - }, - "diagnosticEventHubName": { - "value": "adp-<>-az-evh-x-001" - } - } -} From da1fc2dd0c137ed19c3757077c5343d588c2d1e6 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 16 Sep 2022 12:56:58 +0200 Subject: [PATCH 2/6] Updated ReadMe --- .../trafficmanagerprofiles/readme.md | 75 +++++++++++++++---- 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/modules/Microsoft.Network/trafficmanagerprofiles/readme.md b/modules/Microsoft.Network/trafficmanagerprofiles/readme.md index 93ab65d388..6b1b5f88ec 100644 --- a/modules/Microsoft.Network/trafficmanagerprofiles/readme.md +++ b/modules/Microsoft.Network/trafficmanagerprofiles/readme.md @@ -260,7 +260,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: Parameters

+

Example 1: Common

@@ -268,22 +268,22 @@ The following module usage examples are retrieved from the content of the files ```bicep module trafficmanagerprofiles './Microsoft.Network/trafficmanagerprofiles/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Trafficmanagerprofiles' + name: '${uniqueString(deployment().name)}-test-ntmpcom' params: { // Required parameters - name: 'tm-000001' - relativeName: 'tm-000001' + name: '' + relativeName: '' // Non-required parameters - diagnosticEventHubAuthorizationRuleId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.EventHub/namespaces/adp-<>-az-evhns-x-001/AuthorizationRules/RootManageSharedAccessKey' - diagnosticEventHubName: 'adp-<>-az-evh-x-001' + diagnosticEventHubAuthorizationRuleId: '' + diagnosticEventHubName: '' diagnosticLogsRetentionInDays: 7 - diagnosticStorageAccountId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsax001' - diagnosticWorkspaceId: '/subscriptions/<>/resourcegroups/validation-rg/providers/microsoft.operationalinsights/workspaces/adp-<>-az-law-x-001' + diagnosticStorageAccountId: '' + diagnosticWorkspaceId: '' lock: 'CanNotDelete' roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } @@ -306,26 +306,26 @@ module trafficmanagerprofiles './Microsoft.Network/trafficmanagerprofiles/deploy "parameters": { // Required parameters "name": { - "value": "tm-000001" + "value": "" }, "relativeName": { - "value": "tm-000001" + "value": "" }, // Non-required parameters "diagnosticEventHubAuthorizationRuleId": { - "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.EventHub/namespaces/adp-<>-az-evhns-x-001/AuthorizationRules/RootManageSharedAccessKey" + "value": "" }, "diagnosticEventHubName": { - "value": "adp-<>-az-evh-x-001" + "value": "" }, "diagnosticLogsRetentionInDays": { "value": 7 }, "diagnosticStorageAccountId": { - "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsax001" + "value": "" }, "diagnosticWorkspaceId": { - "value": "/subscriptions/<>/resourcegroups/validation-rg/providers/microsoft.operationalinsights/workspaces/adp-<>-az-law-x-001" + "value": "" }, "lock": { "value": "CanNotDelete" @@ -334,7 +334,7 @@ module trafficmanagerprofiles './Microsoft.Network/trafficmanagerprofiles/deploy "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } @@ -346,3 +346,46 @@ module trafficmanagerprofiles './Microsoft.Network/trafficmanagerprofiles/deploy

+ +

Example 2: Min

+ +
+ +via Bicep module + +```bicep +module trafficmanagerprofiles './Microsoft.Network/trafficmanagerprofiles/deploy.bicep' = { + name: '${uniqueString(deployment().name)}-test-ntmpmin' + params: { + // Required parameters + name: '' + relativeName: '' + } +} +``` + +
+

+ +

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

From 4fc5ae75a2232147fc69af7f8c5b1ca15c671cdb Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Sun, 18 Sep 2022 23:41:42 +0200 Subject: [PATCH 3/6] Update modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep --- .../trafficmanagerprofiles/.test/common/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep b/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep index 7e00c28c16..fa41a975e4 100644 --- a/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep @@ -3,7 +3,7 @@ targetScope = 'subscription' // ========== // // Parameters // // ========== // -@description('Optional. The name of the resource group to deploy for a testing purposes') +@description('Optional. The name of the resource group to deploy for testing purposes') @maxLength(90) param resourceGroupName string = 'ms.network.trafficmanagerprofiles-${serviceShort}-rg' From 707b5c8dd9de4592677a264572e3849fc3dd4043 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Sun, 18 Sep 2022 23:42:00 +0200 Subject: [PATCH 4/6] Update modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep --- .../trafficmanagerprofiles/.test/min/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep b/modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep index 8b9d031d78..f92e340e7d 100644 --- a/modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep @@ -3,7 +3,7 @@ targetScope = 'subscription' // ========== // // Parameters // // ========== // -@description('Optional. The name of the resource group to deploy for a testing purposes') +@description('Optional. The name of the resource group to deploy for testing purposes') @maxLength(90) param resourceGroupName string = 'ms.network.trafficmanagerprofiles-${serviceShort}-rg' From 7611c66866df0840eea327248a4f469254105c5d Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 26 Sep 2022 19:59:53 +0200 Subject: [PATCH 5/6] Update modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> --- .../trafficmanagerprofiles/.test/common/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep b/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep index fa41a975e4..64eac50f72 100644 --- a/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep @@ -3,7 +3,7 @@ targetScope = 'subscription' // ========== // // Parameters // // ========== // -@description('Optional. The name of the resource group to deploy for testing purposes') +@description('Optional. The name of the resource group to deploy for testing purposes.') @maxLength(90) param resourceGroupName string = 'ms.network.trafficmanagerprofiles-${serviceShort}-rg' From 25b676cab365603d48fb25bf4697ed6265993261 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Wed, 5 Oct 2022 21:24:26 +0200 Subject: [PATCH 6/6] Update to latest --- .../trafficmanagerprofiles/.test/common/deploy.test.bicep | 4 ++-- .../trafficmanagerprofiles/.test/min/deploy.test.bicep | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep b/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep index 64eac50f72..85309e76a2 100644 --- a/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/trafficmanagerprofiles/.test/common/deploy.test.bicep @@ -7,10 +7,10 @@ targetScope = 'subscription' @maxLength(90) param resourceGroupName string = 'ms.network.trafficmanagerprofiles-${serviceShort}-rg' -@description('Optional. The location to deploy resources to') +@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') +@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 = 'ntmpcom' // =========== // diff --git a/modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep b/modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep index f92e340e7d..e7e74b8751 100644 --- a/modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/trafficmanagerprofiles/.test/min/deploy.test.bicep @@ -3,14 +3,14 @@ targetScope = 'subscription' // ========== // // Parameters // // ========== // -@description('Optional. The name of the resource group to deploy for testing purposes') +@description('Optional. The name of the resource group to deploy for testing purposes.') @maxLength(90) param resourceGroupName string = 'ms.network.trafficmanagerprofiles-${serviceShort}-rg' -@description('Optional. The location to deploy resources to') +@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') +@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 = 'ntmpmin' // =========== //