Skip to content

Commit 5095d47

Browse files
authored
Added AVD agent update schedule Azure#2946 (Azure#2947)
1 parent 9f9b5ea commit 5095d47

File tree

8 files changed

+511
-0
lines changed

8 files changed

+511
-0
lines changed

docs/CHANGELOG-v1.md

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ What's changed since pre-release v1.38.0-B0011:
3939
- Azure Kubernetes Service:
4040
- Added check to automatically upgrade AKS cluster node image by @sharmilamusunuru.
4141
[#2445](https://github.com/Azure/PSRule.Rules.Azure/issues/2445)
42+
- Azure Virtual Desktop:
43+
- Added check for scheduled agent updates on host pools by @BernieWhite.
44+
[#2946](https://github.com/Azure/PSRule.Rules.Azure/issues/2946)
4245
- Engineering:
4346
- Quality updates to rule documentation by @BernieWhite.
4447
[#2570](https://github.com/Azure/PSRule.Rules.Azure/issues/2570)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
reviewed: 2024-06-18
3+
severity: Important
4+
pillar: Reliability
5+
category: RE:04 Target metrics
6+
resource: Azure Virtual Desktop
7+
online version: https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.AVD.ScheduleAgentUpdate/
8+
---
9+
10+
# Schedule agent updates for host pools
11+
12+
## SYNOPSIS
13+
14+
Define a windows for agent updates to minimize disruptions to users.
15+
16+
## DESCRIPTION
17+
18+
Azure Virtual Desktop (AVD) regularly provide updates to the agent software that runs on host pools.
19+
The agent software is responsible for managing user sessions and providing access to resources.
20+
These updates provide new functionality and fixes.
21+
While the update process is designed to minimize disruptions, updates should be applied outside of peak load times.
22+
23+
By default, agent updates are applied automatically when they become available.
24+
If you have configured a maintenance window, updates are only applied during the maintenance window that you specify.
25+
Each host pool can configure up to two maintenance windows per week.
26+
27+
## RECOMMENDATION
28+
29+
Consider defining a maintenance window for agent updates to minimize disruptions to users on AVD host pools.
30+
31+
## EXAMPLES
32+
33+
### Configure with Azure template
34+
35+
To deploy host pools that pass this rule:
36+
37+
- Set the `properties.agentUpdate.type` property to `Scheduled`. _AND_
38+
- Configure one or more maintenance windows in the `properties.agentUpdate.maintenanceWindows` property.
39+
40+
For example:
41+
42+
```json
43+
{
44+
"type": "Microsoft.DesktopVirtualization/hostPools",
45+
"apiVersion": "2024-04-03",
46+
"name": "[parameters('name')]",
47+
"location": "[parameters('location')]",
48+
"identity": {
49+
"type": "SystemAssigned"
50+
},
51+
"properties": {
52+
"hostPoolType": "Pooled",
53+
"loadBalancerType": "DepthFirst",
54+
"preferredAppGroupType": "Desktop",
55+
"maxSessionLimit": 10,
56+
"agentUpdate": {
57+
"type": "Scheduled",
58+
"maintenanceWindowTimeZone": "AUS Eastern Standard Time",
59+
"maintenanceWindows": [
60+
{
61+
"dayOfWeek": "Sunday",
62+
"hour": 1
63+
}
64+
]
65+
}
66+
}
67+
}
68+
```
69+
70+
### Configure with Bicep
71+
72+
To deploy host pools that pass this rule:
73+
74+
- Set the `properties.agentUpdate.type` property to `Scheduled`. _AND_
75+
- Configure one or more maintenance windows in the `properties.agentUpdate.maintenanceWindows` property.
76+
77+
For example:
78+
79+
```bicep
80+
resource pool 'Microsoft.DesktopVirtualization/hostPools@2024-04-03' = {
81+
name: name
82+
location: location
83+
identity: {
84+
type: 'SystemAssigned'
85+
}
86+
properties: {
87+
hostPoolType: 'Pooled'
88+
loadBalancerType: 'DepthFirst'
89+
preferredAppGroupType: 'Desktop'
90+
maxSessionLimit: 10
91+
agentUpdate: {
92+
type: 'Scheduled'
93+
maintenanceWindowTimeZone: 'AUS Eastern Standard Time'
94+
maintenanceWindows: [
95+
{
96+
dayOfWeek: 'Sunday'
97+
hour: 1
98+
}
99+
]
100+
}
101+
}
102+
}
103+
```
104+
105+
<!-- external:avm avm/res/desktop-virtualization/host-pool agentUpdate -->
106+
107+
## LINKS
108+
109+
- [RE:04 Target metrics](https://learn.microsoft.com/azure/well-architected/reliability/metrics)
110+
- [Get started with the Azure Virtual Desktop Agent](https://learn.microsoft.com/azure/virtual-desktop/agent-overview#agent-update-process)
111+
- [Scheduled Agent Updates for Azure Virtual Desktop host pools](https://learn.microsoft.com/azure/virtual-desktop/scheduled-agent-updates)
112+
- [What's new in the Azure Virtual Desktop Agent?](https://learn.microsoft.com/azure/virtual-desktop/whats-new-agent)
113+
- [Azure deployment reference](https://learn.microsoft.com/azure/templates/microsoft.desktopvirtualization/hostpools)

docs/examples-avd.bicep

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
@description('The name of the resource.')
5+
param name string
6+
7+
@description('The location resources will be deployed.')
8+
param location string = resourceGroup().location
9+
10+
// An example pooled desktop host pool using depth first load balancing.
11+
resource pool 'Microsoft.DesktopVirtualization/hostPools@2024-04-03' = {
12+
name: name
13+
location: location
14+
identity: {
15+
type: 'SystemAssigned'
16+
}
17+
properties: {
18+
hostPoolType: 'Pooled'
19+
loadBalancerType: 'DepthFirst'
20+
preferredAppGroupType: 'Desktop'
21+
maxSessionLimit: 10
22+
agentUpdate: {
23+
type: 'Scheduled'
24+
maintenanceWindowTimeZone: 'AUS Eastern Standard Time'
25+
maintenanceWindows: [
26+
{
27+
dayOfWeek: 'Sunday'
28+
hour: 1
29+
}
30+
]
31+
}
32+
}
33+
}
34+
35+
// An example scaling plan for a host pool.
36+
resource scaling 'Microsoft.DesktopVirtualization/scalingPlans@2024-04-03' = {
37+
name: name
38+
location: location
39+
properties: {
40+
timeZone: 'E. Australia Standard Time'
41+
hostPoolType: 'Pooled'
42+
hostPoolReferences: [
43+
{
44+
hostPoolArmPath: pool.id
45+
scalingPlanEnabled: true
46+
}
47+
]
48+
schedules: [
49+
{
50+
rampUpStartTime: {
51+
hour: 8
52+
minute: 0
53+
}
54+
peakStartTime: {
55+
hour: 9
56+
minute: 0
57+
}
58+
rampDownStartTime: {
59+
hour: 18
60+
minute: 0
61+
}
62+
offPeakStartTime: {
63+
hour: 22
64+
minute: 0
65+
}
66+
name: 'weekdays_schedule'
67+
daysOfWeek: [
68+
'Monday'
69+
'Tuesday'
70+
'Wednesday'
71+
'Thursday'
72+
'Friday'
73+
]
74+
rampUpLoadBalancingAlgorithm: 'BreadthFirst'
75+
rampUpMinimumHostsPct: 20
76+
rampUpCapacityThresholdPct: 60
77+
peakLoadBalancingAlgorithm: 'DepthFirst'
78+
rampDownLoadBalancingAlgorithm: 'DepthFirst'
79+
rampDownMinimumHostsPct: 10
80+
rampDownCapacityThresholdPct: 90
81+
rampDownForceLogoffUsers: true
82+
rampDownWaitTimeMinutes: 30
83+
rampDownNotificationMessage: 'You will be logged off in 30 min. Make sure to save your work.'
84+
rampDownStopHostsWhen: 'ZeroSessions'
85+
offPeakLoadBalancingAlgorithm: 'DepthFirst'
86+
}
87+
]
88+
}
89+
}

docs/examples-avd.json

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"metadata": {
5+
"_generator": {
6+
"name": "bicep",
7+
"version": "0.28.1.47646",
8+
"templateHash": "18117889941546285249"
9+
}
10+
},
11+
"parameters": {
12+
"name": {
13+
"type": "string",
14+
"metadata": {
15+
"description": "The name of the resource."
16+
}
17+
},
18+
"location": {
19+
"type": "string",
20+
"defaultValue": "[resourceGroup().location]",
21+
"metadata": {
22+
"description": "The location resources will be deployed."
23+
}
24+
}
25+
},
26+
"resources": [
27+
{
28+
"type": "Microsoft.DesktopVirtualization/hostPools",
29+
"apiVersion": "2024-04-03",
30+
"name": "[parameters('name')]",
31+
"location": "[parameters('location')]",
32+
"identity": {
33+
"type": "SystemAssigned"
34+
},
35+
"properties": {
36+
"hostPoolType": "Pooled",
37+
"loadBalancerType": "DepthFirst",
38+
"preferredAppGroupType": "Desktop",
39+
"maxSessionLimit": 10,
40+
"agentUpdate": {
41+
"type": "Scheduled",
42+
"maintenanceWindowTimeZone": "AUS Eastern Standard Time",
43+
"maintenanceWindows": [
44+
{
45+
"dayOfWeek": "Sunday",
46+
"hour": 1
47+
}
48+
]
49+
}
50+
}
51+
},
52+
{
53+
"type": "Microsoft.DesktopVirtualization/scalingPlans",
54+
"apiVersion": "2024-04-03",
55+
"name": "[parameters('name')]",
56+
"location": "[parameters('location')]",
57+
"properties": {
58+
"timeZone": "E. Australia Standard Time",
59+
"hostPoolType": "Pooled",
60+
"hostPoolReferences": [
61+
{
62+
"hostPoolArmPath": "[resourceId('Microsoft.DesktopVirtualization/hostPools', parameters('name'))]",
63+
"scalingPlanEnabled": true
64+
}
65+
],
66+
"schedules": [
67+
{
68+
"rampUpStartTime": {
69+
"hour": 8,
70+
"minute": 0
71+
},
72+
"peakStartTime": {
73+
"hour": 9,
74+
"minute": 0
75+
},
76+
"rampDownStartTime": {
77+
"hour": 18,
78+
"minute": 0
79+
},
80+
"offPeakStartTime": {
81+
"hour": 22,
82+
"minute": 0
83+
},
84+
"name": "weekdays_schedule",
85+
"daysOfWeek": [
86+
"Monday",
87+
"Tuesday",
88+
"Wednesday",
89+
"Thursday",
90+
"Friday"
91+
],
92+
"rampUpLoadBalancingAlgorithm": "BreadthFirst",
93+
"rampUpMinimumHostsPct": 20,
94+
"rampUpCapacityThresholdPct": 60,
95+
"peakLoadBalancingAlgorithm": "DepthFirst",
96+
"rampDownLoadBalancingAlgorithm": "DepthFirst",
97+
"rampDownMinimumHostsPct": 10,
98+
"rampDownCapacityThresholdPct": 90,
99+
"rampDownForceLogoffUsers": true,
100+
"rampDownWaitTimeMinutes": 30,
101+
"rampDownNotificationMessage": "You will be logged off in 30 min. Make sure to save your work.",
102+
"rampDownStopHostsWhen": "ZeroSessions",
103+
"offPeakLoadBalancingAlgorithm": "DepthFirst"
104+
}
105+
]
106+
},
107+
"dependsOn": [
108+
"[resourceId('Microsoft.DesktopVirtualization/hostPools', parameters('name'))]"
109+
]
110+
}
111+
]
112+
}

pipeline.build.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ task Rules Dependencies, {
345345
As = 'Summary'
346346
Outcome = 'Problem'
347347
}
348+
Import-Module PSRule -RequiredVersion 2.9.0;
348349
Import-Module (Join-Path -Path $PWD -ChildPath out/modules/PSRule.Rules.Azure) -Force;
349350
Assert-PSRule @assertParams -InputPath $PWD -Module PSRule.Rules.MSFT.OSS -Format File -OutputPath reports/ps-rule-file.xml;
350351

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
#
5+
# Validation rules for Azure Virtual Desktop
6+
#
7+
8+
#region Rules
9+
10+
---
11+
# Synopsis: Define a windows for agent updates to minimize disruptions to users.
12+
apiVersion: github.com/microsoft/PSRule/v1
13+
kind: Rule
14+
metadata:
15+
name: Azure.AVD.ScheduleAgentUpdate
16+
ref: AZR-000437
17+
tags:
18+
release: GA
19+
ruleSet: 2024_06
20+
Azure.WAF/pillar: Reliability
21+
spec:
22+
type:
23+
- Microsoft.DesktopVirtualization/hostPools
24+
condition:
25+
allOf:
26+
- field: properties.agentUpdate.type
27+
equals: Scheduled
28+
29+
- field: properties.agentUpdate.maintenanceWindows
30+
greaterOrEquals: 1
31+
32+
#endregion Rules

0 commit comments

Comments
 (0)