From 09f234df5c3328ee57c72e7c6474f8dedd969ffd Mon Sep 17 00:00:00 2001 From: MrMCake Date: Tue, 30 Aug 2022 21:51:07 +0200 Subject: [PATCH 01/13] [Modules] Updated Network/NetworkInterfaces to new dependency approach --- .../ms.network.networkinterfaces.yml | 3 +- .../.test/default/dependencies.bicep | 68 ++++++++ .../.test/default/deploy.test.bicep | 100 +++++++++++ .../.test/min.parameters.json | 17 -- .../.test/min/dependencies.bicep | 28 ++++ .../.test/min/deploy.test.bicep | 51 ++++++ .../networkInterfaces/.test/parameters.json | 63 ------- .../networkInterfaces/readme.md | 156 +++++++++--------- utilities/tools/Set-ModuleReadMe.ps1 | 6 +- 9 files changed, 329 insertions(+), 163 deletions(-) create mode 100644 modules/Microsoft.Network/networkInterfaces/.test/default/dependencies.bicep create mode 100644 modules/Microsoft.Network/networkInterfaces/.test/default/deploy.test.bicep delete mode 100644 modules/Microsoft.Network/networkInterfaces/.test/min.parameters.json create mode 100644 modules/Microsoft.Network/networkInterfaces/.test/min/dependencies.bicep create mode 100644 modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep delete mode 100644 modules/Microsoft.Network/networkInterfaces/.test/parameters.json diff --git a/.github/workflows/ms.network.networkinterfaces.yml b/.github/workflows/ms.network.networkinterfaces.yml index 2a6533ecaf..5272fae199 100644 --- a/.github/workflows/ms.network.networkinterfaces.yml +++ b/.github/workflows/ms.network.networkinterfaces.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/networkInterfaces/.test/default/dependencies.bicep b/modules/Microsoft.Network/networkInterfaces/.test/default/dependencies.bicep new file mode 100644 index 0000000000..fae9929a7a --- /dev/null +++ b/modules/Microsoft.Network/networkInterfaces/.test/default/dependencies.bicep @@ -0,0 +1,68 @@ +@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 + +@description('Required. The name of the Managed Identity to create.') +param managedIdentityName string + +@description('Required. The name of the Application Security Group to create.') +param applicationSecurityGroupName string + +@description('Required. The name of the Load Balancer Backend Address Pool to create.') +param loadBalancerName 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 managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { + name: managedIdentityName + location: location +} + +resource applicationSecurityGroup 'Microsoft.Network/applicationSecurityGroups@2022-01-01' = { + name: applicationSecurityGroupName + location: location +} + +resource loadBalancer 'Microsoft.Network/loadBalancers@2022-01-01' = { + name: loadBalancerName + location: location + sku: { + name: 'Standard' + } + + resource backendPoolName 'backendAddressPools@2022-01-01' = { + name: 'default' + } +} + +@description('The resource ID of the created Virtual Network Subnet.') +output subnetResourceId string = virtualNetwork.properties.subnets[0].id + +@description('The principal ID of the created Managed Identity.') +output managedIdentityPrincipalId string = managedIdentity.properties.principalId + +@description('The resource ID of the created Application Security Group.') +output applicationSecurityGroupResourceId string = applicationSecurityGroup.id + +@description('The resource ID of the created Load Balancer Backend Pool Name.') +output loadBalancerBackendPoolResourceId string = loadBalancer::backendPoolName.id diff --git a/modules/Microsoft.Network/networkInterfaces/.test/default/deploy.test.bicep b/modules/Microsoft.Network/networkInterfaces/.test/default/deploy.test.bicep new file mode 100644 index 0000000000..b7bc1b22fc --- /dev/null +++ b/modules/Microsoft.Network/networkInterfaces/.test/default/deploy.test.bicep @@ -0,0 +1,100 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.network.networkinterfaces-${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 = 'nnidef' + +// =========== // +// 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}' + managedIdentityName: 'dep-<>-msi-${serviceShort}' + applicationSecurityGroupName: 'dep-<>-asg-${serviceShort}' + loadBalancerName: 'dep-<>-lb-${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' + ipConfigurations: [ + { + applicationSecurityGroups: [ + { + id: resourceGroupResources.outputs.applicationSecurityGroupResourceId + } + ] + loadBalancerBackendAddressPools: [ + { + id: resourceGroupResources.outputs.loadBalancerBackendPoolResourceId + } + ] + name: 'ipconfig01' + subnetResourceId: resourceGroupResources.outputs.subnetResourceId + } + { + subnetResourceId: resourceGroupResources.outputs.subnetResourceId + applicationSecurityGroups: [ + { + id: resourceGroupResources.outputs.applicationSecurityGroupResourceId + } + ] + } + ] + 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/networkInterfaces/.test/min.parameters.json b/modules/Microsoft.Network/networkInterfaces/.test/min.parameters.json deleted file mode 100644 index 070ae288cb..0000000000 --- a/modules/Microsoft.Network/networkInterfaces/.test/min.parameters.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-nic-min-001" - }, - "ipConfigurations": { - "value": [ - { - "name": "ipconfig01", - "subnetResourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001" - } - ] - } - } -} diff --git a/modules/Microsoft.Network/networkInterfaces/.test/min/dependencies.bicep b/modules/Microsoft.Network/networkInterfaces/.test/min/dependencies.bicep new file mode 100644 index 0000000000..91351ab840 --- /dev/null +++ b/modules/Microsoft.Network/networkInterfaces/.test/min/dependencies.bicep @@ -0,0 +1,28 @@ +@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' + } + } + ] + } +} + +@description('The resource ID of the created Virtual Network Subnet.') +output subnetResourceId string = virtualNetwork.properties.subnets[0].id diff --git a/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep b/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep new file mode 100644 index 0000000000..06a1568fac --- /dev/null +++ b/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep @@ -0,0 +1,51 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.network.networkinterfaces-${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 = 'nnimin' + +// =========== // +// 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}' + } +} + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: '<>${serviceShort}001' + ipConfigurations: [ + { + name: 'ipconfig01' + subnetResourceId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001' + } + ] + } +} diff --git a/modules/Microsoft.Network/networkInterfaces/.test/parameters.json b/modules/Microsoft.Network/networkInterfaces/.test/parameters.json deleted file mode 100644 index 9b22bf25de..0000000000 --- a/modules/Microsoft.Network/networkInterfaces/.test/parameters.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-nic-x-001" - }, - "lock": { - "value": "CanNotDelete" - }, - "roleAssignments": { - "value": [ - { - "roleDefinitionIdOrName": "Reader", - "principalIds": [ - "<>" - ] - } - ] - }, - "ipConfigurations": { - "value": [ - { - "name": "ipconfig01", - "subnetResourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001", - "loadBalancerBackendAddressPools": [ - { - "id": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/loadBalancers/adp-<>-az-lb-internal-001/backendAddressPools/servers" - } - ], - "applicationSecurityGroups": [ - { - "id": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/applicationSecurityGroups/adp-<>-az-asg-x-001" - } - ] - }, - { - "subnetResourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001", - "applicationSecurityGroups": [ - { - "id": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/applicationSecurityGroups/adp-<>-az-asg-x-001" - } - ] - } - ] - }, - "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" - } - } -} diff --git a/modules/Microsoft.Network/networkInterfaces/readme.md b/modules/Microsoft.Network/networkInterfaces/readme.md index a5c2794158..6719154e04 100644 --- a/modules/Microsoft.Network/networkInterfaces/readme.md +++ b/modules/Microsoft.Network/networkInterfaces/readme.md @@ -188,106 +188,53 @@ The following module usage examples are retrieved from the content of the files >**Note**: The name of each example is based on the name of the file from which it is taken. >**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order. -

Example 1: Min

+

Example 1: Default

via Bicep module ```bicep -module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-networkInterfaces' - params: { - // Required parameters - ipConfigurations: [ - { - name: 'ipconfig01' - subnetResourceId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001' - } - ] - name: '<>-az-nic-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": { - // Required parameters - "ipConfigurations": { - "value": [ - { - "name": "ipconfig01", - "subnetResourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001" - } - ] - }, - "name": { - "value": "<>-az-nic-min-001" - } - } -} -``` - -
-

- -

Example 2: Parameters

- -
- -via Bicep module - -```bicep -module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-networkInterfaces' +module Networkinterfaces './Microsoft.Network/Networkinterfaces/deploy.bicep' = { + name: '${uniqueString(deployment().name)}-test-nnidef' params: { // Required parameters ipConfigurations: [ { applicationSecurityGroups: [ { - id: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/applicationSecurityGroups/adp-<>-az-asg-x-001' + id: '' } ] loadBalancerBackendAddressPools: [ { - id: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/loadBalancers/adp-<>-az-lb-internal-001/backendAddressPools/servers' + id: '' } ] name: 'ipconfig01' - subnetResourceId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001' + subnetResourceId: '' } { applicationSecurityGroups: [ { - id: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/applicationSecurityGroups/adp-<>-az-asg-x-001' + id: '' } ] - subnetResourceId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001' + subnetResourceId: '' } ] - name: '<>-az-nic-x-001' + name: '<>nnidef001' // 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' } @@ -314,45 +261,45 @@ module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = { "applicationSecurityGroups": [ { - "id": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/applicationSecurityGroups/adp-<>-az-asg-x-001" + "id": "" } ], "loadBalancerBackendAddressPools": [ { - "id": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/loadBalancers/adp-<>-az-lb-internal-001/backendAddressPools/servers" + "id": "" } ], "name": "ipconfig01", - "subnetResourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001" + "subnetResourceId": "" }, { "applicationSecurityGroups": [ { - "id": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/applicationSecurityGroups/adp-<>-az-asg-x-001" + "id": "" } ], - "subnetResourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001" + "subnetResourceId": "" } ] }, "name": { - "value": "<>-az-nic-x-001" + "value": "<>nnidef001" }, // 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" @@ -361,7 +308,7 @@ module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } @@ -373,3 +320,56 @@ module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' =

+ +

Example 2: Min

+ +
+ +via Bicep module + +```bicep +module Networkinterfaces './Microsoft.Network/Networkinterfaces/deploy.bicep' = { + name: '${uniqueString(deployment().name)}-test-nnimin' + params: { + // Required parameters + ipConfigurations: [ + { + name: 'ipconfig01' + subnetResourceId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001' + } + ] + name: '<>nnimin001' + } +} +``` + +
+

+ +

+ +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 + "ipConfigurations": { + "value": [ + { + "name": "ipconfig01", + "subnetResourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001" + } + ] + }, + "name": { + "value": "<>nnimin001" + } + } +} +``` + +
+

diff --git a/utilities/tools/Set-ModuleReadMe.ps1 b/utilities/tools/Set-ModuleReadMe.ps1 index a1074fed21..6b922d65e8 100644 --- a/utilities/tools/Set-ModuleReadMe.ps1 +++ b/utilities/tools/Set-ModuleReadMe.ps1 @@ -883,9 +883,10 @@ function Set-DeploymentExamplesSection { '' ) + $TextInfo = (Get-Culture -Name 'en-US').TextInfo $moduleRoot = Split-Path $TemplateFilePath -Parent - $resourceTypeIdentifier = $moduleRoot.Replace('\', '/').Split('/modules/')[1].TrimStart('/') - $resourceType = $resourceTypeIdentifier.Split('/')[1] + $resourceTypeIdentifier = $TextInfo.ToTitleCase($moduleRoot.Replace('\', '/').Split('/modules/')[1].TrimStart('/')) + $resourceType = $TextInfo.ToTitleCase($resourceTypeIdentifier.Split('/')[1]) $testFilePaths = Get-ModuleTestFileList -ModulePath $moduleRoot | ForEach-Object { Join-Path $moduleRoot $_ } $RequiredParametersList = $TemplateFileContent.parameters.Keys | Where-Object { $TemplateFileContent.parameters[$_].Keys -notcontains 'defaultValue' } | Sort-Object @@ -906,7 +907,6 @@ function Set-DeploymentExamplesSection { } else { $exampleTitle = ((Split-Path $testFilePath -LeafBase) -replace '\.', ' ') -replace ' parameters', '' } - $TextInfo = (Get-Culture -Name 'en-US').TextInfo $exampleTitle = $TextInfo.ToTitleCase($exampleTitle) $SectionContent += @( '

Example {0}: {1}

' -f $pathIndex, $exampleTitle From 80b356eb4b020171cc422ed6167fb3fde0d4c9ac Mon Sep 17 00:00:00 2001 From: MrMCake Date: Thu, 1 Sep 2022 11:35:55 +0200 Subject: [PATCH 02/13] Update to latest --- .../networkInterfaces/readme.md | 59 +------------------ 1 file changed, 3 insertions(+), 56 deletions(-) diff --git a/modules/Microsoft.Network/networkInterfaces/readme.md b/modules/Microsoft.Network/networkInterfaces/readme.md index b6706d1f26..a679ca2bfa 100644 --- a/modules/Microsoft.Network/networkInterfaces/readme.md +++ b/modules/Microsoft.Network/networkInterfaces/readme.md @@ -195,61 +195,8 @@ The following module usage examples are retrieved from the content of the files via Bicep module ```bicep -module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-NetworkInterfaces' - params: { - // Required parameters - ipConfigurations: [ - { - name: 'ipconfig01' - subnetResourceId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001' - } - ] - name: '<>-az-nic-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": { - // Required parameters - "ipConfigurations": { - "value": [ - { - "name": "ipconfig01", - "subnetResourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001" - } - ] - }, - "name": { - "value": "<>-az-nic-min-001" - } - } -} -``` - -
-

- -

Example 2: Parameters

- -
- -via Bicep module - -```bicep -module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-NetworkInterfaces' +module NetworkInterfaces './Microsoft.Network/NetworkInterfaces/deploy.bicep' = { + name: '${uniqueString(deployment().name)}-test-nnidef' params: { // Required parameters ipConfigurations: [ @@ -381,7 +328,7 @@ module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = via Bicep module ```bicep -module Networkinterfaces './Microsoft.Network/Networkinterfaces/deploy.bicep' = { +module NetworkInterfaces './Microsoft.Network/NetworkInterfaces/deploy.bicep' = { name: '${uniqueString(deployment().name)}-test-nnimin' params: { // Required parameters From 4c16d6473d402c8a6779446b3764bc49d0548cc5 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Mon, 5 Sep 2022 20:28:48 +0200 Subject: [PATCH 03/13] Updated docs --- modules/Microsoft.Network/networkInterfaces/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/Microsoft.Network/networkInterfaces/readme.md b/modules/Microsoft.Network/networkInterfaces/readme.md index a679ca2bfa..489c8cf7b9 100644 --- a/modules/Microsoft.Network/networkInterfaces/readme.md +++ b/modules/Microsoft.Network/networkInterfaces/readme.md @@ -195,7 +195,7 @@ The following module usage examples are retrieved from the content of the files via Bicep module ```bicep -module NetworkInterfaces './Microsoft.Network/NetworkInterfaces/deploy.bicep' = { +module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = { name: '${uniqueString(deployment().name)}-test-nnidef' params: { // Required parameters @@ -328,7 +328,7 @@ module NetworkInterfaces './Microsoft.Network/NetworkInterfaces/deploy.bicep' = via Bicep module ```bicep -module NetworkInterfaces './Microsoft.Network/NetworkInterfaces/deploy.bicep' = { +module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = { name: '${uniqueString(deployment().name)}-test-nnimin' params: { // Required parameters From 21647b61694a02ccd53b06cf2350df45cf790c11 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Thu, 8 Sep 2022 19:11:59 +0200 Subject: [PATCH 04/13] Updated folder default to common. --- .../.test/{default => common}/dependencies.bicep | 0 .../.test/{default => common}/deploy.test.bicep | 0 modules/Microsoft.Network/networkInterfaces/readme.md | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename modules/Microsoft.Network/networkInterfaces/.test/{default => common}/dependencies.bicep (100%) rename modules/Microsoft.Network/networkInterfaces/.test/{default => common}/deploy.test.bicep (100%) diff --git a/modules/Microsoft.Network/networkInterfaces/.test/default/dependencies.bicep b/modules/Microsoft.Network/networkInterfaces/.test/common/dependencies.bicep similarity index 100% rename from modules/Microsoft.Network/networkInterfaces/.test/default/dependencies.bicep rename to modules/Microsoft.Network/networkInterfaces/.test/common/dependencies.bicep diff --git a/modules/Microsoft.Network/networkInterfaces/.test/default/deploy.test.bicep b/modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep similarity index 100% rename from modules/Microsoft.Network/networkInterfaces/.test/default/deploy.test.bicep rename to modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep diff --git a/modules/Microsoft.Network/networkInterfaces/readme.md b/modules/Microsoft.Network/networkInterfaces/readme.md index 489c8cf7b9..b8610dc578 100644 --- a/modules/Microsoft.Network/networkInterfaces/readme.md +++ b/modules/Microsoft.Network/networkInterfaces/readme.md @@ -188,7 +188,7 @@ The following module usage examples are retrieved from the content of the files >**Note**: The name of each example is based on the name of the file from which it is taken. >**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order. -

Example 1: Default

+

Example 1: Common

From eaa653d7eb45c34dfe8a018a111ee04107967279 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 12:51:32 +0200 Subject: [PATCH 05/13] Update to latest --- .../networkInterfaces/.test/common/deploy.test.bicep | 4 ++-- .../networkInterfaces/.test/min/deploy.test.bicep | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep b/modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep index b7bc1b22fc..3928343a29 100644 --- a/modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep @@ -10,8 +10,8 @@ param resourceGroupName string = 'ms.network.networkinterfaces-${serviceShort}-r @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 = 'nnidef' +@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 = 'nnicom' // =========== // // Deployments // diff --git a/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep b/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep index 06a1568fac..1b7d00e87e 100644 --- a/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep @@ -10,7 +10,7 @@ param resourceGroupName string = 'ms.network.networkinterfaces-${serviceShort}-r @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 = 'nnimin' // =========== // From fe1dd3289501ac7784fa43fc7cdeba11216fccbc Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 13:04:35 +0200 Subject: [PATCH 06/13] Update to latest --- .../networkInterfaces/.test/common/deploy.test.bicep | 6 +++--- .../networkInterfaces/.test/min/deploy.test.bicep | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep b/modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep index 3928343a29..1f0279fda8 100644 --- a/modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep @@ -3,14 +3,14 @@ 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 a testing purposes.') @maxLength(90) param resourceGroupName string = 'ms.network.networkinterfaces-${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 = 'nnicom' // =========== // diff --git a/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep b/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep index 1b7d00e87e..fe120eae83 100644 --- a/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep @@ -3,14 +3,14 @@ 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 a testing purposes.') @maxLength(90) param resourceGroupName string = 'ms.network.networkinterfaces-${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 = 'nnimin' // =========== // From f938a739edc354ed61eddf3e1ab45e7265fd6e6c Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 13:55:01 +0200 Subject: [PATCH 07/13] Update to latest --- modules/Microsoft.Network/networkInterfaces/readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.Network/networkInterfaces/readme.md b/modules/Microsoft.Network/networkInterfaces/readme.md index e09f48aaba..2bdc8c0c0b 100644 --- a/modules/Microsoft.Network/networkInterfaces/readme.md +++ b/modules/Microsoft.Network/networkInterfaces/readme.md @@ -197,7 +197,7 @@ The following module usage examples are retrieved from the content of the files ```bicep module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-test-nnidef' + name: '${uniqueString(deployment().name)}-test-nnicom' params: { // Required parameters ipConfigurations: [ @@ -224,7 +224,7 @@ module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = subnetResourceId: '' } ] - name: '<>nnidef001' + name: '<>nnicom001' // Non-required parameters diagnosticEventHubAuthorizationRuleId: '' diagnosticEventHubName: '' @@ -284,7 +284,7 @@ module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = ] }, "name": { - "value": "<>nnidef001" + "value": "<>nnicom001" }, // Non-required parameters "diagnosticEventHubAuthorizationRuleId": { From 9051ef64c11a89a4d0ad2fa4c5e20c3d7a6841af Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 19 Sep 2022 20:02:18 +0200 Subject: [PATCH 08/13] Update modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep --- .../networkInterfaces/.test/min/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep b/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep index fe120eae83..42f939ec84 100644 --- a/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/networkInterfaces/.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.networkinterfaces-${serviceShort}-rg' From 9ab8d29fe43d7bec6caf38897a0632a43809768c Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 19 Sep 2022 20:02:39 +0200 Subject: [PATCH 09/13] Update modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep --- .../networkInterfaces/.test/common/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep b/modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep index 1f0279fda8..23bf6eb503 100644 --- a/modules/Microsoft.Network/networkInterfaces/.test/common/deploy.test.bicep +++ b/modules/Microsoft.Network/networkInterfaces/.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.networkinterfaces-${serviceShort}-rg' From fa699e1a64a9171b3a81c91305530257d924f0e2 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Mon, 19 Sep 2022 21:20:01 +0200 Subject: [PATCH 10/13] Update to latest --- utilities/tools/Set-ModuleReadMe.ps1 | 7 ------- 1 file changed, 7 deletions(-) diff --git a/utilities/tools/Set-ModuleReadMe.ps1 b/utilities/tools/Set-ModuleReadMe.ps1 index 6469605289..25923c3d62 100644 --- a/utilities/tools/Set-ModuleReadMe.ps1 +++ b/utilities/tools/Set-ModuleReadMe.ps1 @@ -896,13 +896,6 @@ function Set-DeploymentExamplesSection { '' ) -<<<<<<< HEAD - $TextInfo = (Get-Culture -Name 'en-US').TextInfo - $moduleRoot = Split-Path $TemplateFilePath -Parent - $fullIdentifier = $moduleRoot.Replace('\', '/').Split('/modules/')[1].TrimStart('/') - -======= ->>>>>>> main # Get resource type and make first letter upper case. Requires manual handling as ToTitleCase lowercases everything but the first letter $providerNamespace = ($fullModuleIdentifier.Split('/')[0] -split '\.' | ForEach-Object { $_.Substring(0, 1).ToUpper() + $_.Substring(1) }) -join '.' $resourceType = $fullModuleIdentifier.Split('/')[1] From 5900552950bf667c03aec4686e2f7dad380a1e80 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 21 Oct 2022 13:18:24 +0200 Subject: [PATCH 11/13] Fixed infinite deployment & updated resource ref --- .../inboundNatRules/deploy.bicep | 2 +- .../.test/common/dependencies.bicep | 47 ++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.Network/loadBalancers/inboundNatRules/deploy.bicep b/modules/Microsoft.Network/loadBalancers/inboundNatRules/deploy.bicep index b9ee9ec006..f06dc422ea 100644 --- a/modules/Microsoft.Network/loadBalancers/inboundNatRules/deploy.bicep +++ b/modules/Microsoft.Network/loadBalancers/inboundNatRules/deploy.bicep @@ -72,7 +72,7 @@ resource inboundNatRule 'Microsoft.Network/loadBalancers/inboundNatRules@2021-08 frontendPort: frontendPort backendPort: backendPort backendAddressPool: !empty(backendAddressPoolName) ? { - id: az.resourceId('Microsoft.Network/loadBalancers/backendAddressPools', name, backendAddressPoolName) + id: '${loadBalancer.id}/backendAddressPools/${backendAddressPoolName}' } : null enableFloatingIP: enableFloatingIP enableTcpReset: enableTcpReset diff --git a/modules/Microsoft.Network/networkInterfaces/.test/common/dependencies.bicep b/modules/Microsoft.Network/networkInterfaces/.test/common/dependencies.bicep index fae9929a7a..a6c15600bc 100644 --- a/modules/Microsoft.Network/networkInterfaces/.test/common/dependencies.bicep +++ b/modules/Microsoft.Network/networkInterfaces/.test/common/dependencies.bicep @@ -50,11 +50,54 @@ resource loadBalancer 'Microsoft.Network/loadBalancers@2022-01-01' = { name: 'Standard' } - resource backendPoolName 'backendAddressPools@2022-01-01' = { + properties: { + frontendIPConfigurations: [ + { + name: 'privateIPConfig1' + properties: { + subnet: { + id: virtualNetwork.properties.subnets[0].id + } + } + } + ] + } + + resource backendPool 'backendAddressPools@2022-01-01' = { name: 'default' } } +resource inboundNatRule 'Microsoft.Network/loadBalancers/inboundNatRules@2021-08-01' = { + name: 'inboundNatRule1' + properties: { + frontendPort: 443 + backendPort: 443 + enableFloatingIP: false + enableTcpReset: false + frontendIPConfiguration: { + id: loadBalancer.properties.frontendIPConfigurations[0].id + } + idleTimeoutInMinutes: 4 + protocol: 'Tcp' + } + parent: loadBalancer +} + +resource inboundNatRule2 'Microsoft.Network/loadBalancers/inboundNatRules@2021-08-01' = { + name: 'inboundNatRule2' + properties: { + frontendPort: 3389 + backendPort: 3389 + frontendIPConfiguration: { + id: loadBalancer.properties.frontendIPConfigurations[0].id + } + idleTimeoutInMinutes: 4 + protocol: 'Tcp' + } + parent: loadBalancer +} + @description('The resource ID of the created Virtual Network Subnet.') output subnetResourceId string = virtualNetwork.properties.subnets[0].id @@ -65,4 +108,4 @@ output managedIdentityPrincipalId string = managedIdentity.properties.principalI output applicationSecurityGroupResourceId string = applicationSecurityGroup.id @description('The resource ID of the created Load Balancer Backend Pool Name.') -output loadBalancerBackendPoolResourceId string = loadBalancer::backendPoolName.id +output loadBalancerBackendPoolResourceId string = loadBalancer::backendPool.id From 9b0f5949d238a5de2383d83e73ddc47044847ab2 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Fri, 21 Oct 2022 22:29:17 +0200 Subject: [PATCH 12/13] Update modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> --- .../networkInterfaces/.test/min/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep b/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep index 42f939ec84..a6ceca3ffa 100644 --- a/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep +++ b/modules/Microsoft.Network/networkInterfaces/.test/min/deploy.test.bicep @@ -44,7 +44,7 @@ module testDeployment '../../deploy.bicep' = { ipConfigurations: [ { name: 'ipconfig01' - subnetResourceId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001' + subnetResourceId: resourceGroupResources.outputs.subnetResourceId } ] } From b8814de98491eab770d4b2ea044a53cd363d7e35 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 21 Oct 2022 22:30:22 +0200 Subject: [PATCH 13/13] Updated readme --- modules/Microsoft.Network/networkInterfaces/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/Microsoft.Network/networkInterfaces/readme.md b/modules/Microsoft.Network/networkInterfaces/readme.md index b1fdac818f..78388600e0 100644 --- a/modules/Microsoft.Network/networkInterfaces/readme.md +++ b/modules/Microsoft.Network/networkInterfaces/readme.md @@ -338,7 +338,7 @@ module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = ipConfigurations: [ { name: 'ipconfig01' - subnetResourceId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001' + subnetResourceId: '' } ] name: '<>nnimin001' @@ -363,7 +363,7 @@ module networkInterfaces './Microsoft.Network/networkInterfaces/deploy.bicep' = "value": [ { "name": "ipconfig01", - "subnetResourceId": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<>-az-vnet-x-001/subnets/<>-az-subnet-x-001" + "subnetResourceId": "" } ] },