From 12940b89643d48c2699a4eea4c7ac9212a351c60 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Sat, 3 Sep 2022 14:40:01 +0200 Subject: [PATCH 1/6] Updated DesktopVirtualization HostPools to new dependency approach --- .../ms.desktopvirtualization.hostpools.yml | 3 +- .../.test/default/dependencies.bicep | 14 +++ .../hostpools/.test/default/deploy.test.bicep | 98 +++++++++++++++++++ .../hostpools/.test/parameters.json | 80 --------------- .../hostpools/readme.md | 40 ++++---- 5 files changed, 133 insertions(+), 102 deletions(-) create mode 100644 modules/Microsoft.DesktopVirtualization/hostpools/.test/default/dependencies.bicep create mode 100644 modules/Microsoft.DesktopVirtualization/hostpools/.test/default/deploy.test.bicep delete mode 100644 modules/Microsoft.DesktopVirtualization/hostpools/.test/parameters.json diff --git a/.github/workflows/ms.desktopvirtualization.hostpools.yml b/.github/workflows/ms.desktopvirtualization.hostpools.yml index 99d3a057a6..f36e967efa 100644 --- a/.github/workflows/ms.desktopvirtualization.hostpools.yml +++ b/.github/workflows/ms.desktopvirtualization.hostpools.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.DesktopVirtualization/hostpools/.test/default/dependencies.bicep b/modules/Microsoft.DesktopVirtualization/hostpools/.test/default/dependencies.bicep new file mode 100644 index 0000000000..7371d4437b --- /dev/null +++ b/modules/Microsoft.DesktopVirtualization/hostpools/.test/default/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.DesktopVirtualization/hostpools/.test/default/deploy.test.bicep b/modules/Microsoft.DesktopVirtualization/hostpools/.test/default/deploy.test.bicep new file mode 100644 index 0000000000..5ccf0e77bd --- /dev/null +++ b/modules/Microsoft.DesktopVirtualization/hostpools/.test/default/deploy.test.bicep @@ -0,0 +1,98 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for a testing purposes') +@maxLength(90) +param resourceGroupName string = 'ms.desktopvirtualization.hostpools-${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 = 'dvhpdef' + +// =========== // +// 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 // +// ============== // + +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: '<>${serviceShort}001' + customRdpProperty: 'audiocapturemode:i:1;audiomode:i:0;drivestoredirect:s:;redirectclipboard:i:1;redirectcomports:i:1;redirectprinters:i:1;redirectsmartcards:i:1;screen mode id:i:2;' + diagnosticLogsRetentionInDays: 7 + diagnosticStorageAccountId: diagnosticDependencies.outputs.storageAccountResourceId + diagnosticWorkspaceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId + diagnosticEventHubAuthorizationRuleId: diagnosticDependencies.outputs.eventHubAuthorizationRuleId + diagnosticEventHubName: diagnosticDependencies.outputs.eventHubNamespaceEventHubName + hostpoolDescription: 'My first AVD Host Pool' + hostpoolFriendlyName: 'AVDv2' + hostpoolType: 'Pooled' + loadBalancerType: 'BreadthFirst' + location: location + lock: 'CanNotDelete' + maxSessionLimit: 99999 + personalDesktopAssignmentType: 'Automatic' + roleAssignments: [ + { + principalIds: [ + resourceGroupResources.outputs.managedIdentityPrincipalId + ] + roleDefinitionIdOrName: 'Reader' + } + ] + vmTemplate: { + customImageId: null + domain: 'domainname.onmicrosoft.com' + galleryImageOffer: 'office-365' + galleryImagePublisher: 'microsoftwindowsdesktop' + galleryImageSKU: '20h1-evd-o365pp' + imageType: 'Gallery' + imageUri: null + namePrefix: 'avdv2' + osDiskType: 'StandardSSD_LRS' + useManagedDisks: true + vmSize: { + cores: 2 + id: 'Standard_D2s_v3' + ram: 8 + } + } + } +} diff --git a/modules/Microsoft.DesktopVirtualization/hostpools/.test/parameters.json b/modules/Microsoft.DesktopVirtualization/hostpools/.test/parameters.json deleted file mode 100644 index 076213824f..0000000000 --- a/modules/Microsoft.DesktopVirtualization/hostpools/.test/parameters.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-avdhp-x-001" - }, - "lock": { - "value": "CanNotDelete" - }, - "location": { - "value": "westeurope" - }, - "hostpoolFriendlyName": { - "value": "AVDv2" - }, - "hostpoolDescription": { - "value": "My first AVD Host Pool" - }, - "hostpoolType": { - "value": "Pooled" - }, - "personalDesktopAssignmentType": { - "value": "Automatic" - }, - "maxSessionLimit": { - "value": 99999 - }, - "loadBalancerType": { - "value": "BreadthFirst" - }, - "customRdpProperty": { - "value": "audiocapturemode:i:1;audiomode:i:0;drivestoredirect:s:;redirectclipboard:i:1;redirectcomports:i:1;redirectprinters:i:1;redirectsmartcards:i:1;screen mode id:i:2;" - }, - "vmTemplate": { - "value": { - "domain": "domainname.onmicrosoft.com", - "galleryImageOffer": "office-365", - "galleryImagePublisher": "microsoftwindowsdesktop", - "galleryImageSKU": "20h1-evd-o365pp", - "imageType": "Gallery", - "imageUri": null, - "customImageId": null, - "namePrefix": "avdv2", - "osDiskType": "StandardSSD_LRS", - "useManagedDisks": true, - "vmSize": { - "id": "Standard_D2s_v3", - "cores": 2, - "ram": 8 - } - } - }, - "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" - } - } -} diff --git a/modules/Microsoft.DesktopVirtualization/hostpools/readme.md b/modules/Microsoft.DesktopVirtualization/hostpools/readme.md index 780e708ef4..8cf227406d 100644 --- a/modules/Microsoft.DesktopVirtualization/hostpools/readme.md +++ b/modules/Microsoft.DesktopVirtualization/hostpools/readme.md @@ -264,7 +264,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: Parameters

+

Example 1: Default

@@ -272,41 +272,41 @@ The following module usage examples are retrieved from the content of the files ```bicep module hostpools './Microsoft.DesktopVirtualization/hostpools/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Hostpools' + name: '${uniqueString(deployment().name)}-test-dvhpdef' params: { // Required parameters - name: '<>-az-avdhp-x-001' + name: '<>dvhpdef001' // Non-required parameters customRdpProperty: 'audiocapturemode:i:1;audiomode:i:0;drivestoredirect:s:;redirectclipboard:i:1;redirectcomports:i:1;redirectprinters:i:1;redirectsmartcards:i:1;screen mode id:i:2;' - 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: '' hostpoolDescription: 'My first AVD Host Pool' hostpoolFriendlyName: 'AVDv2' hostpoolType: 'Pooled' loadBalancerType: 'BreadthFirst' - location: 'westeurope' + location: '' lock: 'CanNotDelete' maxSessionLimit: 99999 personalDesktopAssignmentType: 'Automatic' roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } ] vmTemplate: { - customImageId: null + customImageId: '' domain: 'domainname.onmicrosoft.com' galleryImageOffer: 'office-365' galleryImagePublisher: 'microsoftwindowsdesktop' galleryImageSKU: '20h1-evd-o365pp' imageType: 'Gallery' - imageUri: null + imageUri: '' namePrefix: 'avdv2' osDiskType: 'StandardSSD_LRS' useManagedDisks: true @@ -334,26 +334,26 @@ module hostpools './Microsoft.DesktopVirtualization/hostpools/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "<>-az-avdhp-x-001" + "value": "<>dvhpdef001" }, // Non-required parameters "customRdpProperty": { "value": "audiocapturemode:i:1;audiomode:i:0;drivestoredirect:s:;redirectclipboard:i:1;redirectcomports:i:1;redirectprinters:i:1;redirectsmartcards:i:1;screen mode id:i:2;" }, "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": "" }, "hostpoolDescription": { "value": "My first AVD Host Pool" @@ -368,7 +368,7 @@ module hostpools './Microsoft.DesktopVirtualization/hostpools/deploy.bicep' = { "value": "BreadthFirst" }, "location": { - "value": "westeurope" + "value": "" }, "lock": { "value": "CanNotDelete" @@ -383,7 +383,7 @@ module hostpools './Microsoft.DesktopVirtualization/hostpools/deploy.bicep' = { "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } @@ -391,13 +391,13 @@ module hostpools './Microsoft.DesktopVirtualization/hostpools/deploy.bicep' = { }, "vmTemplate": { "value": { - "customImageId": null, + "customImageId": "", "domain": "domainname.onmicrosoft.com", "galleryImageOffer": "office-365", "galleryImagePublisher": "microsoftwindowsdesktop", "galleryImageSKU": "20h1-evd-o365pp", "imageType": "Gallery", - "imageUri": null, + "imageUri": "", "namePrefix": "avdv2", "osDiskType": "StandardSSD_LRS", "useManagedDisks": true, From 445d40d06ff45da27e242f8c5b0896b237e274c7 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Thu, 8 Sep 2022 19:06:15 +0200 Subject: [PATCH 2/6] Updated folder default to common. --- .../hostpools/.test/{default => common}/dependencies.bicep | 0 .../hostpools/.test/{default => common}/deploy.test.bicep | 0 modules/Microsoft.DesktopVirtualization/hostpools/readme.md | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename modules/Microsoft.DesktopVirtualization/hostpools/.test/{default => common}/dependencies.bicep (100%) rename modules/Microsoft.DesktopVirtualization/hostpools/.test/{default => common}/deploy.test.bicep (100%) diff --git a/modules/Microsoft.DesktopVirtualization/hostpools/.test/default/dependencies.bicep b/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/dependencies.bicep similarity index 100% rename from modules/Microsoft.DesktopVirtualization/hostpools/.test/default/dependencies.bicep rename to modules/Microsoft.DesktopVirtualization/hostpools/.test/common/dependencies.bicep diff --git a/modules/Microsoft.DesktopVirtualization/hostpools/.test/default/deploy.test.bicep b/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep similarity index 100% rename from modules/Microsoft.DesktopVirtualization/hostpools/.test/default/deploy.test.bicep rename to modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep diff --git a/modules/Microsoft.DesktopVirtualization/hostpools/readme.md b/modules/Microsoft.DesktopVirtualization/hostpools/readme.md index 8cf227406d..d5ab4f6cc7 100644 --- a/modules/Microsoft.DesktopVirtualization/hostpools/readme.md +++ b/modules/Microsoft.DesktopVirtualization/hostpools/readme.md @@ -264,7 +264,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 5ef5c6c929dbaff63075bfc7b3fdfe60978d782d Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 12:50:49 +0200 Subject: [PATCH 3/6] Update to latest --- .../hostpools/.test/common/deploy.test.bicep | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep b/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep index 5ccf0e77bd..a19e891141 100644 --- a/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep +++ b/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep @@ -10,8 +10,8 @@ param resourceGroupName string = 'ms.desktopvirtualization.hostpools-${serviceSh @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 = 'dvhpdef' +@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 = 'dvhpcom' // =========== // // Deployments // From 97a90237fc56043ee22f5dfe99dc8b66bb699307 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 13:03:47 +0200 Subject: [PATCH 4/6] Update to latest --- .../hostpools/.test/common/deploy.test.bicep | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep b/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep index a19e891141..42f5f2d872 100644 --- a/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep +++ b/modules/Microsoft.DesktopVirtualization/hostpools/.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.desktopvirtualization.hostpools-${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 = 'dvhpcom' // =========== // From c5f931843d4cea986726376e2a5475856403f68d Mon Sep 17 00:00:00 2001 From: MrMCake Date: Fri, 9 Sep 2022 13:44:10 +0200 Subject: [PATCH 5/6] Update to latest --- modules/Microsoft.DesktopVirtualization/hostpools/readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.DesktopVirtualization/hostpools/readme.md b/modules/Microsoft.DesktopVirtualization/hostpools/readme.md index aec29cc6db..a465c8d643 100644 --- a/modules/Microsoft.DesktopVirtualization/hostpools/readme.md +++ b/modules/Microsoft.DesktopVirtualization/hostpools/readme.md @@ -273,10 +273,10 @@ The following module usage examples are retrieved from the content of the files ```bicep module hostpools './Microsoft.DesktopVirtualization/hostpools/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-test-dvhpdef' + name: '${uniqueString(deployment().name)}-test-dvhpcom' params: { // Required parameters - name: '<>dvhpdef001' + name: '<>dvhpcom001' // Non-required parameters customRdpProperty: 'audiocapturemode:i:1;audiomode:i:0;drivestoredirect:s:;redirectclipboard:i:1;redirectcomports:i:1;redirectprinters:i:1;redirectsmartcards:i:1;screen mode id:i:2;' diagnosticEventHubAuthorizationRuleId: '' @@ -335,7 +335,7 @@ module hostpools './Microsoft.DesktopVirtualization/hostpools/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "<>dvhpdef001" + "value": "<>dvhpcom001" }, // Non-required parameters "customRdpProperty": { From 1b1d9548755d323bf0438613399b1b53f65cad4a Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 19 Sep 2022 08:16:28 +0200 Subject: [PATCH 6/6] Update modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep --- .../hostpools/.test/common/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep b/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep index 42f5f2d872..3d30cf70f5 100644 --- a/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep +++ b/modules/Microsoft.DesktopVirtualization/hostpools/.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.desktopvirtualization.hostpools-${serviceShort}-rg'