Skip to content

Commit 69403f3

Browse files
Add support for creating custom static routes (#726)
* Automated update for ARM templates * Add support for specifying custom static routes Some automatic Bicep linting * Update deploy.bicep --------- Co-authored-by: SvenAelterman <SvenAelterman@users.noreply.github.com> Co-authored-by: Dany Contreras <78437433+danycontre@users.noreply.github.com>
1 parent 3a3c577 commit 69403f3

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

workload/bicep/deploy-baseline.bicep

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ param deploymentEnvironment string = 'Dev'
2727
param diskEncryptionKeyExpirationInDays int = 60
2828

2929
@sys.description('Required. Location where to deploy compute services.')
30-
param avdSessionHostLocation string
30+
param avdSessionHostLocation string
3131

3232
@sys.description('Required. Location where to deploy AVD management plane.')
33-
param avdManagementPlaneLocation string
33+
param avdManagementPlaneLocation string
3434

3535
@sys.description('AVD workload subscription ID, multiple subscriptions scenario. (Default: "")')
3636
param avdWorkloadSubsId string = ''
@@ -107,7 +107,7 @@ param hostPoolPublicNetworkAccess string = 'Enabled'
107107
])
108108
@sys.description('Default to Enabled. Enables or Disables public network access on the workspace.')
109109
param workspacePublicNetworkAccess string = 'Enabled'
110-
110+
111111
@allowed([
112112
'Automatic'
113113
'Direct'
@@ -511,6 +511,9 @@ param enableKvPurgeProtection bool = true
511511
@sys.description('Deploys anti malware extension on session hosts. (Default: true)')
512512
param deployAntiMalwareExt bool = true
513513

514+
@sys.description('Additional customer-provided static routes to be added to the route tables.')
515+
param customStaticRoutes array = []
516+
514517
// =========== //
515518
// Variable declaration //
516519
// =========== //
@@ -1093,7 +1096,9 @@ module networking './modules/networking/deploy.bicep' = if (createAvdVnet || cre
10931096
createVnet: createAvdVnet
10941097
deployAsg: (avdDeploySessionHosts || createAvdFslogixDeployment || varCreateMsixDeployment) ? true : false
10951098
existingAvdSubnetResourceId: existingVnetAvdSubnetResourceId
1096-
createPrivateDnsZones: (deployPrivateEndpointKeyvaultStorage || deployAvdPrivateLinkService) ? createPrivateDnsZones : false
1099+
createPrivateDnsZones: (deployPrivateEndpointKeyvaultStorage || deployAvdPrivateLinkService)
1100+
? createPrivateDnsZones
1101+
: false
10971102
applicationSecurityGroupName: varApplicationSecurityGroupName
10981103
computeObjectsRgName: varComputeObjectsRgName
10991104
networkObjectsRgName: varNetworkObjectsRgName
@@ -1125,6 +1130,7 @@ module networking './modules/networking/deploy.bicep' = if (createAvdVnet || cre
11251130
? monitoringDiagnosticSettings.outputs.avdAlaWorkspaceResourceId
11261131
: alaExistingWorkspaceResourceId)
11271132
: ''
1133+
customStaticRoutes: customStaticRoutes
11281134
}
11291135
dependsOn: [
11301136
baselineNetworkResourceGroup
@@ -1152,7 +1158,9 @@ module managementPLane './modules/avdManagementPlane/deploy.bicep' = {
11521158
preferredAppGroupType: (hostPoolPreferredAppGroupType == 'RemoteApp') ? 'RailApplications' : 'Desktop'
11531159
deployScalingPlan: varDeployScalingPlan
11541160
scalingPlanExclusionTag: varScalingPlanExclusionTag
1155-
scalingPlanSchedules: (avdHostPoolType == 'Pooled') ? varPooledScalingPlanSchedules : varPersonalScalingPlanSchedules
1161+
scalingPlanSchedules: (avdHostPoolType == 'Pooled')
1162+
? varPooledScalingPlanSchedules
1163+
: varPersonalScalingPlanSchedules
11561164
scalingPlanName: varScalingPlanName
11571165
hostPoolMaxSessions: hostPoolMaxSessions
11581166
personalAssignType: avdPersonalAssignType
@@ -1172,9 +1180,19 @@ module managementPLane './modules/avdManagementPlane/deploy.bicep' = {
11721180
deployAvdPrivateLinkService: deployAvdPrivateLinkService
11731181
hostPoolPublicNetworkAccess: hostPoolPublicNetworkAccess
11741182
workspacePublicNetworkAccess: workspacePublicNetworkAccess
1175-
privateEndpointSubnetResourceId: createAvdVnet ? '${networking.outputs.virtualNetworkResourceId}/subnets/${varVnetPrivateEndpointSubnetName}' : existingVnetPrivateEndpointSubnetResourceId
1176-
avdVnetPrivateDnsZoneDiscoveryResourceId: deployAvdPrivateLinkService ? (createPrivateDnsZones ? networking.outputs.avdDnsDiscoveryZoneResourceId : avdVnetPrivateDnsZoneDiscoveryResourceId) : ''
1177-
avdVnetPrivateDnsZoneConnectionResourceId: deployAvdPrivateLinkService ? (createPrivateDnsZones ? networking.outputs.avdDnsConnectionZoneResourceId : avdVnetPrivateDnsZoneConnectionResourceId) : ''
1183+
privateEndpointSubnetResourceId: createAvdVnet
1184+
? '${networking.outputs.virtualNetworkResourceId}/subnets/${varVnetPrivateEndpointSubnetName}'
1185+
: existingVnetPrivateEndpointSubnetResourceId
1186+
avdVnetPrivateDnsZoneDiscoveryResourceId: deployAvdPrivateLinkService
1187+
? (createPrivateDnsZones
1188+
? networking.outputs.avdDnsDiscoveryZoneResourceId
1189+
: avdVnetPrivateDnsZoneDiscoveryResourceId)
1190+
: ''
1191+
avdVnetPrivateDnsZoneConnectionResourceId: deployAvdPrivateLinkService
1192+
? (createPrivateDnsZones
1193+
? networking.outputs.avdDnsConnectionZoneResourceId
1194+
: avdVnetPrivateDnsZoneConnectionResourceId)
1195+
: ''
11781196
privateEndpointConnectionName: varPrivateEndPointConnectionName
11791197
privateEndpointDiscoveryName: varPrivateEndPointDiscoveryName
11801198
privateEndpointWorkspaceName: varPrivateEndPointWorkspaceName
@@ -1267,20 +1285,23 @@ module wrklKeyVault '../../avm/1.0.0/res/key-vault/vault/main.bicep' = {
12671285
ipRules: []
12681286
}
12691287
: {}
1270-
privateEndpoints: deployPrivateEndpointKeyvaultStorage? [
1288+
privateEndpoints: deployPrivateEndpointKeyvaultStorage
1289+
? [
12711290
{
12721291
name: varWrklKvPrivateEndpointName
12731292
subnetResourceId: createAvdVnet
12741293
? '${networking.outputs.virtualNetworkResourceId}/subnets/${varVnetPrivateEndpointSubnetName}'
12751294
: existingVnetPrivateEndpointSubnetResourceId
12761295
customNetworkInterfaceName: 'nic-01-${varWrklKvPrivateEndpointName}'
12771296
service: 'vault'
1278-
privateDnsZoneGroupName: createPrivateDnsZones ? split(networking.outputs.keyVaultDnsZoneResourceId, '/')[8] : split(avdVnetPrivateDnsZoneKeyvaultId, '/')[8]
1297+
privateDnsZoneGroupName: createPrivateDnsZones
1298+
? split(networking.outputs.keyVaultDnsZoneResourceId, '/')[8]
1299+
: split(avdVnetPrivateDnsZoneKeyvaultId, '/')[8]
12791300
privateDnsZoneResourceIds: [
1280-
createPrivateDnsZones ? networking.outputs.keyVaultDnsZoneResourceId : avdVnetPrivateDnsZoneKeyvaultId
1301+
createPrivateDnsZones ? networking.outputs.keyVaultDnsZoneResourceId : avdVnetPrivateDnsZoneKeyvaultId
12811302
]
12821303
}
1283-
]
1304+
]
12841305
: []
12851306
secrets: (avdIdentityServiceProvider != 'EntraID')
12861307
? [
@@ -1483,7 +1504,7 @@ module msixAzureFilesStorage './modules/storageAzureFiles/deploy.bicep' = if (va
14831504
}
14841505

14851506
// VMSS Flex
1486-
module vmScaleSetFlex './modules/avdSessionHosts/.bicep/vmScaleSet.bicep' = if (avdDeploySessionHosts && deployVmssFlex) {
1507+
module vmScaleSetFlex './modules/avdSessionHosts/.bicep/vmScaleSet.bicep' = if (avdDeploySessionHosts && deployVmssFlex) {
14871508
name: 'AVD-VMSS-Flex-${time}'
14881509
scope: resourceGroup('${avdWorkloadSubsId}', '${varComputeObjectsRgName}')
14891510
params: {

workload/bicep/modules/networking/deploy.bicep

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ param alaWorkspaceResourceId string
103103
@sys.description('Do not modify, used to set unique value for resource deployment')
104104
param time string = utcNow()
105105

106+
@sys.description('Additional customer-provided static routes to be added to the route tables.')
107+
param customStaticRoutes array = []
108+
106109
// =========== //
107110
// Variable declaration //
108111
// =========== //
@@ -153,7 +156,7 @@ var varWindowsActivationKMSPrefixesNsg = (varAzureCloudName == 'AzureCloud')
153156
]
154157
: []
155158
// https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/windows/custom-routes-enable-kms-activation#solution
156-
var varStaticRoutes = (varAzureCloudName == 'AzureCloud')
159+
var varDefaultStaticRoutes = (varAzureCloudName == 'AzureCloud')
157160
? [
158161
{
159162
name: 'AVDServiceTraffic'
@@ -283,6 +286,9 @@ var varStaticRoutes = (varAzureCloudName == 'AzureCloud')
283286
}
284287
]
285288
: []
289+
290+
var varStaticRoutes = union(varDefaultStaticRoutes, customStaticRoutes)
291+
286292
var privateDnsZoneNames = {
287293
AutomationAgentService: 'privatelink.agentsvc.azure-automation.${privateDnsZoneSuffixes_AzureAutomation[environment().name]}'
288294
Automation: 'privatelink.azure-automation.${privateDnsZoneSuffixes_AzureAutomation[environment().name]}'

0 commit comments

Comments
 (0)