11@minLength (3 )
2- @maxLength (10 )
2+ @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
3233param AiLocation string // The location used for all deployed resources. This location must be in the same region as the resource group.
3334param 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' )}'
4938var imageVersion = 'rc1'
5039var location = resourceGroup ().location
5140var dblocation = resourceGroup ().location
@@ -56,11 +45,10 @@ var cosmosdbLogContainer = 'cmsalog'
5645var deploymentType = 'GlobalStandard'
5746var containerName = 'appstorage'
5847var llmModel = 'gpt-4o'
59- var prefixCleaned = replace (toLower (finalName ), '-' , '' )
6048var storageSkuName = 'Standard_LRS'
61- var storageContainerName = '${prefixCleaned }ctstor'
49+ var storageContainerName = '${ResourcePrefix }ctstor'
6250var 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
116104module 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' = {
127115module 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' = {
139127module 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
155143module 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
166154module 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
233221module 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
271259resource 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