Skip to content

Commit

Permalink
fix: ensure that session host prefix does not exceed 11 chars (#135)
Browse files Browse the repository at this point in the history
* fix: ensure that session host prefix does not exceed 11 chars

---------

Co-authored-by: Vincent Balbarin <vbalbarin@microsoft.com>
Co-authored-by: Sven Aelterman <17446043+SvenAelterman@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 13, 2024
1 parent f08f734 commit f97496f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion research-hub/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'
Expand Down

0 comments on commit f97496f

Please sign in to comment.