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/common/dependencies.bicep b/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/dependencies.bicep new file mode 100644 index 0000000000..7371d4437b --- /dev/null +++ b/modules/Microsoft.DesktopVirtualization/hostpools/.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.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep b/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep new file mode 100644 index 0000000000..3d30cf70f5 --- /dev/null +++ b/modules/Microsoft.DesktopVirtualization/hostpools/.test/common/deploy.test.bicep @@ -0,0 +1,98 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for 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 = 'dvhpcom' + +// =========== // +// 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 eb05bc87f8..a465c8d643 100644 --- a/modules/Microsoft.DesktopVirtualization/hostpools/readme.md +++ b/modules/Microsoft.DesktopVirtualization/hostpools/readme.md @@ -265,7 +265,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

@@ -273,41 +273,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-dvhpcom' params: { // Required parameters - name: '<>-az-avdhp-x-001' + 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: '/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 @@ -335,26 +335,26 @@ module hostpools './Microsoft.DesktopVirtualization/hostpools/deploy.bicep' = { "parameters": { // Required parameters "name": { - "value": "<>-az-avdhp-x-001" + "value": "<>dvhpcom001" }, // 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" @@ -369,7 +369,7 @@ module hostpools './Microsoft.DesktopVirtualization/hostpools/deploy.bicep' = { "value": "BreadthFirst" }, "location": { - "value": "westeurope" + "value": "" }, "lock": { "value": "CanNotDelete" @@ -384,7 +384,7 @@ module hostpools './Microsoft.DesktopVirtualization/hostpools/deploy.bicep' = { "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } @@ -392,13 +392,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,