From f97496fe10038e053549df3e6ab1ba2ea1989fe5 Mon Sep 17 00:00:00 2001 From: Vincent Balbarin Date: Wed, 13 Nov 2024 16:57:19 -0500 Subject: [PATCH] fix: ensure that session host prefix does not exceed 11 chars (#135) * fix: ensure that session host prefix does not exceed 11 chars --------- Co-authored-by: Vincent Balbarin Co-authored-by: Sven Aelterman <17446043+SvenAelterman@users.noreply.github.com> --- research-hub/main.bicep | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/research-hub/main.bicep b/research-hub/main.bicep index e2efc21..cb11ca3 100644 --- a/research-hub/main.bicep +++ b/research-hub/main.bicep @@ -422,6 +422,12 @@ module avdJumpBoxModule '../shared-modules/virtualDesktop/avd.bicep' = if (!rese } } +// Construct the session hosts' VM name prefix using the pattern "SH-{workloadName}-{sequence}", +// taking into account that the max length of the vmNamePrefix is 11 characters +var vmNamePrefixLead = 'sh-' +var vmNamePrefixWorkloadName = take(workloadName, 11 - length(string(sequence)) - length('sh-')) +var vmNamePrefix = '${vmNamePrefixLead}${vmNamePrefixWorkloadName}${sequence}' + module avdJumpBoxSessionHostModule '../shared-modules/virtualDesktop/sessionHosts.bicep' = if (!researchVmsAreSessionHosts && jumpBoxSessionHostCount > 0) { scope: avdRg name: take(replace(deploymentNameStructure, '{rtype}', 'avd-sh'), 64) @@ -447,7 +453,8 @@ module avdJumpBoxSessionHostModule '../shared-modules/virtualDesktop/sessionHost vmCount: jumpBoxSessionHostCount vmLocalAdminUsername: sessionHostLocalAdminUsername vmLocalAdminPassword: sessionHostLocalAdminPassword - vmNamePrefix: 'sh-${workloadName}${sequence}' + #disable-next-line BCP335 // Bicep can't figure out that we've ensured that the max length won't exceed 11 + vmNamePrefix: vmNamePrefix vmSize: jumpBoxSessionHostVmSize ADDomainInfo: logonType == 'ad'