From d6da2851461fea398fdf31a1da4a7265f1e513b7 Mon Sep 17 00:00:00 2001 From: Joe Thompson Date: Fri, 18 Aug 2023 23:46:07 -0700 Subject: [PATCH] 3523 hosts pools ScheduledAgentUpdates issue (#3582) * ignore working files * scheduled agent update fix * scheduled agent update fix * [Bug Report]: Agent scheduled updates gives error 404 after deploying AVD host pool with host-pools module Fixes #3523 * Update modules/desktop-virtualization/host-pools/main.bicep Co-authored-by: Alexander Sehr * Update modules/desktop-virtualization/host-pools/main.bicep Co-authored-by: Alexander Sehr * Update modules/desktop-virtualization/host-pools/main.bicep Removing comments from template Co-authored-by: Alexander Sehr --------- Co-authored-by: Alexander Sehr --- .gitignore | 3 + .../host-pools/README.md | 6 ++ .../host-pools/main.bicep | 46 ++++++++++- .../host-pools/main.json | 82 +++++++++++++++++-- 4 files changed, 128 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index f872e29525..6485ad8af1 100644 --- a/.gitignore +++ b/.gitignore @@ -388,3 +388,6 @@ FodyWeavers.xsd # MacOS .DS_Store + +# Do not include files in workloads folder +/workloads diff --git a/modules/desktop-virtualization/host-pools/README.md b/modules/desktop-virtualization/host-pools/README.md index 9753846268..e272081c66 100644 --- a/modules/desktop-virtualization/host-pools/README.md +++ b/modules/desktop-virtualization/host-pools/README.md @@ -32,6 +32,12 @@ This module deploys an Azure Virtual Desktop (AVD) Host Pool. | Parameter Name | Type | Default Value | Allowed Values | Description | | :-- | :-- | :-- | :-- | :-- | | `agentUpdate` | object | `{object}` | | The session host configuration for updating agent, monitoring agent, and stack component. | +| `agentUpdateMaintenanceWindowDayOfWeek` | string | `'Sunday'` | `[Friday, Monday, Saturday, Sunday, Thursday, Tuesday, Wednesday]` | Update day for scheduled agent updates. | +| `agentUpdateMaintenanceWindowHour` | int | `22` | | Update hour for scheduled agent updates. | +| `agentUpdateMaintenanceWindows` | array | `[System.Management.Automation.OrderedHashtable]` | | List of maintenance windows for scheduled agent updates. | +| `agentUpdateMaintenanceWindowTimeZone` | string | `'Central Standard Time'` | | Time zone for scheduled agent updates. | +| `agentUpdateType` | string | `'Default'` | `[Default, Scheduled]` | Enable scheduled agent updates, Default means agent updates will automatically be installed by AVD when they become available. | +| `agentUpdateUseSessionHostLocalTime` | bool | `False` | | Whether to use localTime of the virtual machine for scheduled agent updates. | | `customRdpProperty` | string | `'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;'` | | Host Pool RDP properties. | | `description` | string | `''` | | The description of the Host Pool to be created. | | `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. | diff --git a/modules/desktop-virtualization/host-pools/main.bicep b/modules/desktop-virtualization/host-pools/main.bicep index de40d9729e..2d089de365 100644 --- a/modules/desktop-virtualization/host-pools/main.bicep +++ b/modules/desktop-virtualization/host-pools/main.bicep @@ -101,11 +101,53 @@ param startVMOnConnect bool = false @sys.description('Optional. Array of role assignment objects that contain the \'roleDefinitionIdOrName\' and \'principalIds\' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: \'/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11\'.') param roleAssignments array = [] +@sys.description('Optional. Enable scheduled agent updates, Default means agent updates will automatically be installed by AVD when they become available.') +@allowed([ + 'Default' + 'Scheduled' +]) +param agentUpdateType string = 'Default' + +@sys.description('Optional. Update hour for scheduled agent updates.') +@minValue(1) +@maxValue(23) +param agentUpdateMaintenanceWindowHour int = 22 + +@sys.description('Optional. Update day for scheduled agent updates.') +@allowed([ + 'Sunday' + 'Monday' + 'Tuesday' + 'Wednesday' + 'Thursday' + 'Friday' + 'Saturday' +]) +param agentUpdateMaintenanceWindowDayOfWeek string = 'Sunday' + +@sys.description('Optional. List of maintenance windows for scheduled agent updates.') +param agentUpdateMaintenanceWindows array = [ + { + hour: agentUpdateMaintenanceWindowHour + dayOfWeek: agentUpdateMaintenanceWindowDayOfWeek + } +] + +@sys.description('Optional. Time zone for scheduled agent updates.') +param agentUpdateMaintenanceWindowTimeZone string = 'Central Standard Time' + +@sys.description('Optional. Whether to use localTime of the virtual machine for scheduled agent updates.') +param agentUpdateUseSessionHostLocalTime bool = false + @sys.description('Optional. The session host configuration for updating agent, monitoring agent, and stack component.') param agentUpdate object = { - useSessionHostLocalTime: true + type: agentUpdateType + maintenanceWindows: agentUpdateMaintenanceWindows + maintenanceWindowTimeZone: agentUpdateMaintenanceWindowTimeZone + useSessionHostLocalTime: agentUpdateUseSessionHostLocalTime } + @sys.description('Optional. The ring number of HostPool.') param ring int = -1 @@ -203,7 +245,7 @@ resource hostPool 'Microsoft.DesktopVirtualization/hostPools@2022-09-09' = { registrationTokenOperation: 'Update' } vmTemplate: ((!empty(vmTemplate)) ? null : string(vmTemplate)) - agentUpdate: agentUpdate + agentUpdate: (agentUpdateType == 'Scheduled') ? agentUpdate : null ring: ring != -1 ? ring : null ssoadfsAuthority: ssoadfsAuthority ssoClientId: ssoClientId diff --git a/modules/desktop-virtualization/host-pools/main.json b/modules/desktop-virtualization/host-pools/main.json index 86ed50c500..afe03f458b 100644 --- a/modules/desktop-virtualization/host-pools/main.json +++ b/modules/desktop-virtualization/host-pools/main.json @@ -4,9 +4,12 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.19.5.34762", - "templateHash": "15864651736629560577" - } + "version": "0.18.4.5664", + "templateHash": "8022860912421276738" + }, + "name": "Azure Virtual Desktop (AVD) Host Pools", + "description": "This module deploys an Azure Virtual Desktop (AVD) Host Pool.", + "owner": "Azure/module-maintainers" }, "parameters": { "name": { @@ -203,10 +206,75 @@ "description": "Optional. Array of role assignment objects that contain the 'roleDefinitionIdOrName' and 'principalIds' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'." } }, + "agentUpdateType": { + "type": "string", + "defaultValue": "Default", + "allowedValues": [ + "Default", + "Scheduled" + ], + "metadata": { + "description": "Optional. Enable scheduled agent updates, Default means agent updates will automatically be installed by AVD when they become available." + } + }, + "agentUpdateMaintenanceWindowHour": { + "type": "int", + "defaultValue": 22, + "maxValue": 23, + "minValue": 1, + "metadata": { + "description": "Optional. Update hour for scheduled agent updates." + } + }, + "agentUpdateMaintenanceWindowDayOfWeek": { + "type": "string", + "defaultValue": "Sunday", + "allowedValues": [ + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday" + ], + "metadata": { + "description": "Optional. Update day for scheduled agent updates." + } + }, + "agentUpdateMaintenanceWindows": { + "type": "array", + "defaultValue": [ + { + "hour": "[parameters('agentUpdateMaintenanceWindowHour')]", + "dayOfWeek": "[parameters('agentUpdateMaintenanceWindowDayOfWeek')]" + } + ], + "metadata": { + "description": "Optional. List of maintenance windows for scheduled agent updates." + } + }, + "agentUpdateMaintenanceWindowTimeZone": { + "type": "string", + "defaultValue": "Central Standard Time", + "metadata": { + "description": "Optional. Time zone for scheduled agent updates." + } + }, + "agentUpdateUseSessionHostLocalTime": { + "type": "bool", + "defaultValue": false, + "metadata": { + "description": "Optional. Whether to use localTime of the virtual machine for scheduled agent updates." + } + }, "agentUpdate": { "type": "object", "defaultValue": { - "useSessionHostLocalTime": true + "type": "[parameters('agentUpdateType')]", + "maintenanceWindows": "[parameters('agentUpdateMaintenanceWindows')]", + "maintenanceWindowTimeZone": "[parameters('agentUpdateMaintenanceWindowTimeZone')]", + "useSessionHostLocalTime": "[parameters('agentUpdateUseSessionHostLocalTime')]" }, "metadata": { "description": "Optional. The session host configuration for updating agent, monitoring agent, and stack component." @@ -337,7 +405,7 @@ "registrationTokenOperation": "Update" }, "vmTemplate": "[if(not(empty(parameters('vmTemplate'))), null(), string(parameters('vmTemplate')))]", - "agentUpdate": "[parameters('agentUpdate')]", + "agentUpdate": "[if(equals(parameters('agentUpdateType'), 'Scheduled'), parameters('agentUpdate'), null())]", "ring": "[if(not(equals(parameters('ring'), -1)), parameters('ring'), null())]", "ssoadfsAuthority": "[parameters('ssoadfsAuthority')]", "ssoClientId": "[parameters('ssoClientId')]", @@ -410,8 +478,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.19.5.34762", - "templateHash": "10241186313653123794" + "version": "0.18.4.5664", + "templateHash": "14279396732857224845" } }, "parameters": {