diff --git a/.github/workflows/ms.desktopvirtualization.workspaces.yml b/.github/workflows/ms.desktopvirtualization.workspaces.yml index 5b55277835..9ddd91422e 100644 --- a/.github/workflows/ms.desktopvirtualization.workspaces.yml +++ b/.github/workflows/ms.desktopvirtualization.workspaces.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/workspaces/.test/common/dependencies.bicep b/modules/Microsoft.DesktopVirtualization/workspaces/.test/common/dependencies.bicep new file mode 100644 index 0000000000..6120c25d3d --- /dev/null +++ b/modules/Microsoft.DesktopVirtualization/workspaces/.test/common/dependencies.bicep @@ -0,0 +1,41 @@ +@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 + +@description('Required. The name of the Application Group to create.') +param applicationGroupName string + +@description('Required. The name of the Host Pool to create.') +param hostPoolName string + +resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { + name: managedIdentityName + location: location +} + +resource hostPool 'Microsoft.DesktopVirtualization/hostPools@2021-07-12' = { + name: hostPoolName + location: location + properties: { + hostPoolType: 'Pooled' + loadBalancerType: 'BreadthFirst' + preferredAppGroupType: 'Desktop' + } +} + +resource applicationGroup 'Microsoft.DesktopVirtualization/applicationGroups@2021-07-12' = { + name: applicationGroupName + location: location + properties: { + applicationGroupType: 'Desktop' + hostPoolArmPath: hostPool.id + } +} + +@description('The principal ID of the created Managed Identity.') +output managedIdentityPrincipalId string = managedIdentity.properties.principalId + +@description('The resource ID of the created Application Group.') +output applicationGroupResourceId string = applicationGroup.id diff --git a/modules/Microsoft.DesktopVirtualization/workspaces/.test/common/deploy.test.bicep b/modules/Microsoft.DesktopVirtualization/workspaces/.test/common/deploy.test.bicep new file mode 100644 index 0000000000..7a93cc7b2d --- /dev/null +++ b/modules/Microsoft.DesktopVirtualization/workspaces/.test/common/deploy.test.bicep @@ -0,0 +1,81 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for testing purposes.') +@maxLength(90) +param resourceGroupName string = 'ms.desktopvirtualization.workspaces-${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 = 'dvwcom' + +// =========== // +// 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}' + applicationGroupName: 'dep-<>-appGroup-${serviceShort}' + hostPoolName: 'dep-<>-hp-${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' + appGroupResourceIds: [ + resourceGroupResources.outputs.applicationGroupResourceId + ] + diagnosticLogsRetentionInDays: 7 + diagnosticStorageAccountId: diagnosticDependencies.outputs.storageAccountResourceId + diagnosticWorkspaceId: diagnosticDependencies.outputs.logAnalyticsWorkspaceResourceId + diagnosticEventHubAuthorizationRuleId: diagnosticDependencies.outputs.eventHubAuthorizationRuleId + diagnosticEventHubName: diagnosticDependencies.outputs.eventHubNamespaceEventHubName + location: location + lock: 'CanNotDelete' + roleAssignments: [ + { + principalIds: [ + resourceGroupResources.outputs.managedIdentityPrincipalId + ] + roleDefinitionIdOrName: 'Reader' + } + ] + workspaceDescription: 'This is my first AVD Workspace' + workspaceFriendlyName: 'My first AVD Workspace' + } +} diff --git a/modules/Microsoft.DesktopVirtualization/workspaces/.test/min/deploy.test.bicep b/modules/Microsoft.DesktopVirtualization/workspaces/.test/min/deploy.test.bicep new file mode 100644 index 0000000000..fa5ba4c120 --- /dev/null +++ b/modules/Microsoft.DesktopVirtualization/workspaces/.test/min/deploy.test.bicep @@ -0,0 +1,37 @@ +targetScope = 'subscription' + +// ========== // +// Parameters // +// ========== // +@description('Optional. The name of the resource group to deploy for testing purposes.') +@maxLength(90) +param resourceGroupName string = 'ms.desktopvirtualization.workspaces-${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 = 'dvwmin' + +// =========== // +// Deployments // +// =========== // + +// General resources +// ================= +resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { + name: resourceGroupName + location: location +} + +// ============== // +// Test Execution // +// ============== // + +module testDeployment '../../deploy.bicep' = { + scope: resourceGroup + name: '${uniqueString(deployment().name)}-test-${serviceShort}' + params: { + name: '<>${serviceShort}001' + } +} diff --git a/modules/Microsoft.DesktopVirtualization/workspaces/.test/parameters.json b/modules/Microsoft.DesktopVirtualization/workspaces/.test/parameters.json deleted file mode 100644 index 5ffb007078..0000000000 --- a/modules/Microsoft.DesktopVirtualization/workspaces/.test/parameters.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "value": "<>-az-avdws-x-001" - }, - "lock": { - "value": "CanNotDelete" - }, - "location": { - "value": "westeurope" - }, - "appGroupResourceIds": { - "value": [ - "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.DesktopVirtualization/applicationgroups/adp-<>-az-avdag-x-001" - ] - }, - "workspaceFriendlyName": { - "value": "My first AVD Workspace" - }, - "workspaceDescription": { - "value": "This is my first AVD Workspace" - }, - "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/workspaces/deploy.bicep b/modules/Microsoft.DesktopVirtualization/workspaces/deploy.bicep index 8879c53f78..170d25415e 100644 --- a/modules/Microsoft.DesktopVirtualization/workspaces/deploy.bicep +++ b/modules/Microsoft.DesktopVirtualization/workspaces/deploy.bicep @@ -4,7 +4,7 @@ param name string @description('Optional. Location for all resources.') param location string = resourceGroup().location -@description('Required. Resource IDs for the existing Application groups this workspace will group together.') +@description('Optional. Resource IDs for the existing Application groups this workspace will group together.') param appGroupResourceIds array = [] @description('Optional. The friendly name of the Workspace to be created.') diff --git a/modules/Microsoft.DesktopVirtualization/workspaces/readme.md b/modules/Microsoft.DesktopVirtualization/workspaces/readme.md index c93260f1e0..5ff787971b 100644 --- a/modules/Microsoft.DesktopVirtualization/workspaces/readme.md +++ b/modules/Microsoft.DesktopVirtualization/workspaces/readme.md @@ -25,13 +25,13 @@ This module deploys an Azure virtual desktop workspace. | Parameter Name | Type | Description | | :-- | :-- | :-- | -| `appGroupResourceIds` | array | Resource IDs for the existing Application groups this workspace will group together. | | `name` | string | The name of the workspace to be attach to new Application Group. | **Optional parameters** | Parameter Name | Type | Default Value | Allowed Values | Description | | :-- | :-- | :-- | :-- | :-- | +| `appGroupResourceIds` | array | `[]` | | Resource IDs for the existing Application groups this workspace will group together. | | `diagnosticEventHubAuthorizationRuleId` | string | `''` | | Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to. | | `diagnosticEventHubName` | string | `''` | | Name of the diagnostic event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category. | | `diagnosticLogCategoriesToEnable` | array | `[Checkpoint, Error, Feed, Management]` | `[Checkpoint, Error, Feed, Management]` | The name of logs that will be streamed. | @@ -168,7 +168,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

@@ -176,25 +176,25 @@ The following module usage examples are retrieved from the content of the files ```bicep module workspaces './Microsoft.DesktopVirtualization/workspaces/deploy.bicep' = { - name: '${uniqueString(deployment().name)}-Workspaces' + name: '${uniqueString(deployment().name)}-test-dvwcom' params: { // Required parameters - name: '<>-az-avdws-x-001' + name: '<>dvwcom001' // Non-required parameters appGroupResourceIds: [ - '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.DesktopVirtualization/applicationgroups/adp-<>-az-avdag-x-001' + '' ] - 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' - location: 'westeurope' + diagnosticStorageAccountId: '' + diagnosticWorkspaceId: '' + location: '' lock: 'CanNotDelete' roleAssignments: [ { principalIds: [ - '<>' + '' ] roleDefinitionIdOrName: 'Reader' } @@ -219,31 +219,31 @@ module workspaces './Microsoft.DesktopVirtualization/workspaces/deploy.bicep' = "parameters": { // Required parameters "name": { - "value": "<>-az-avdws-x-001" + "value": "<>dvwcom001" }, // Non-required parameters "appGroupResourceIds": { "value": [ - "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.DesktopVirtualization/applicationgroups/adp-<>-az-avdag-x-001" + "" ] }, "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": "" }, "location": { - "value": "westeurope" + "value": "" }, "lock": { "value": "CanNotDelete" @@ -252,7 +252,7 @@ module workspaces './Microsoft.DesktopVirtualization/workspaces/deploy.bicep' = "value": [ { "principalIds": [ - "<>" + "" ], "roleDefinitionIdOrName": "Reader" } @@ -270,3 +270,40 @@ module workspaces './Microsoft.DesktopVirtualization/workspaces/deploy.bicep' =

+ +

Example 2: Min

+ +
+ +via Bicep module + +```bicep +module workspaces './Microsoft.DesktopVirtualization/workspaces/deploy.bicep' = { + name: '${uniqueString(deployment().name)}-test-dvwmin' + params: { + name: '<>dvwmin001' + } +} +``` + +
+

+ +

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