Skip to content

Commit 4cd6372

Browse files
Merge pull request #65 from microsoft/issue-template-folder-add
updating deployment script for new max length
2 parents 00d471e + 8f4977a commit 4cd6372

File tree

2 files changed

+57
-70
lines changed

2 files changed

+57
-70
lines changed

infra/main.bicep

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
@minLength(3)
22
@maxLength(20)
33
@description('Prefix for all resources created by this template. This prefix will be used to create unique names for all resources. The prefix must be unique within the resource group.')
4-
param ResourcePrefix string
4+
param Prefix string
5+
56

67
@allowed([
78
'australiaeast'
@@ -32,20 +33,8 @@ param ResourcePrefix string
3233
param AiLocation string // The location used for all deployed resources. This location must be in the same region as the resource group.
3334
param capacity int = 5
3435

35-
36-
@description('A unique prefix for all resources in this deployment. This should be 3-10 characters long:')
37-
//param environmentName string
38-
var randomString = substring(uniqueString(resourceGroup().id), 0, 4)
39-
@description('The location used for all deployed resources')
40-
// Generate a unique string based on the base name and a unique identifier
41-
//var uniqueSuffix = uniqueString(resourceGroup().id, ResourcePrefix)
42-
43-
// Take the first 4 characters of the unique string to use as a suffix
44-
//var randomSuffix = substring(ResourcePrefix, 0, min(10, length(ResourcePrefix)))
45-
46-
// Combine the base name with the random suffix
47-
var finalName = '${ResourcePrefix}-${randomString}'
48-
36+
var uniqueId = toLower(uniqueString(subscription().id, Prefix, resourceGroup().location))
37+
var ResourcePrefix = 'cm${padLeft(take(uniqueId, 12), 12, '0')}'
4938
var imageVersion = 'rc1'
5039
var location = resourceGroup().location
5140
var dblocation = resourceGroup().location
@@ -56,11 +45,10 @@ var cosmosdbLogContainer = 'cmsalog'
5645
var deploymentType = 'GlobalStandard'
5746
var containerName = 'appstorage'
5847
var llmModel = 'gpt-4o'
59-
var prefixCleaned = replace(toLower(finalName), '-', '')
6048
var storageSkuName = 'Standard_LRS'
61-
var storageContainerName = '${prefixCleaned}ctstor'
49+
var storageContainerName = '${ResourcePrefix}ctstor'
6250
var gptModelVersion = '2024-08-06'
63-
var aiServicesName = '${prefixCleaned}-aiservices'
51+
var aiServicesName = '${ResourcePrefix}-aiservices'
6452

6553

6654

@@ -116,7 +104,7 @@ resource aiServicesDeployments 'Microsoft.CognitiveServices/accounts/deployments
116104
module managedIdentityModule 'deploy_managed_identity.bicep' = {
117105
name: 'deploy_managed_identity'
118106
params: {
119-
solutionName: prefixCleaned
107+
solutionName: ResourcePrefix
120108
solutionLocation: location
121109
}
122110
scope: resourceGroup(resourceGroup().name)
@@ -127,7 +115,7 @@ module managedIdentityModule 'deploy_managed_identity.bicep' = {
127115
module kvault 'deploy_keyvault.bicep' = {
128116
name: 'deploy_keyvault'
129117
params: {
130-
solutionName: prefixCleaned
118+
solutionName: ResourcePrefix
131119
solutionLocation: location
132120
managedIdentityObjectId:managedIdentityModule.outputs.managedIdentityOutput.objectId
133121
}
@@ -139,7 +127,7 @@ module kvault 'deploy_keyvault.bicep' = {
139127
module aifoundry 'deploy_ai_foundry.bicep' = {
140128
name: 'deploy_ai_foundry'
141129
params: {
142-
solutionName: prefixCleaned
130+
solutionName: ResourcePrefix
143131
solutionLocation: AiLocation
144132
keyVaultName: kvault.outputs.keyvaultName
145133
gptModelName: llmModel
@@ -153,21 +141,21 @@ module aifoundry 'deploy_ai_foundry.bicep' = {
153141
}
154142

155143
module containerAppsEnvironment 'br/public:avm/res/app/managed-environment:0.9.1' = {
156-
name: toLower('${prefixCleaned}conAppsEnv')
144+
name: toLower('${ResourcePrefix}conAppsEnv')
157145
params: {
158146
logAnalyticsWorkspaceResourceId: aifoundry.outputs.logAnalyticsId
159-
name: toLower('${prefixCleaned}manenv')
147+
name: toLower('${ResourcePrefix}manenv')
160148
location: location
161149
zoneRedundant: false
162150
managedIdentities: managedIdentityModule
163151
}
164152
}
165153

166154
module databaseAccount 'br/public:avm/res/document-db/database-account:0.9.0' = {
167-
name: toLower('${prefixCleaned}database')
155+
name: toLower('${ResourcePrefix}database')
168156
params: {
169157
// Required parameters
170-
name: toLower('${prefixCleaned}databaseAccount')
158+
name: toLower('${ResourcePrefix}databaseAccount')
171159
// Non-required parameters
172160
enableAnalyticalStorage: true
173161
location: dblocation
@@ -231,7 +219,7 @@ module databaseAccount 'br/public:avm/res/document-db/database-account:0.9.0' =
231219
}
232220

233221
module containerAppFrontend 'br/public:avm/res/app/container-app:0.13.0' = {
234-
name: toLower('${prefixCleaned}containerAppFrontend')
222+
name: toLower('${ResourcePrefix}Frontend')
235223
params: {
236224
managedIdentities: {
237225
systemAssigned: true
@@ -261,15 +249,15 @@ module containerAppFrontend 'br/public:avm/res/app/container-app:0.13.0' = {
261249
scaleMinReplicas: 1
262250
scaleMaxReplicas: 1
263251
environmentResourceId: containerAppsEnvironment.outputs.resourceId
264-
name: toLower('${prefixCleaned}containerFrontend')
252+
name: toLower('${ResourcePrefix}Frontend')
265253
// Non-required parameters
266254
location: location
267255
}
268256
}
269257

270258

271259
resource containerAppBackend 'Microsoft.App/containerApps@2023-05-01' = {
272-
name: toLower('${prefixCleaned}containerBackend')
260+
name: toLower('${ResourcePrefix}Backend')
273261
location: location
274262
identity: {
275263
type: 'SystemAssigned'

0 commit comments

Comments
 (0)