11@minLength (3 )
2-
32@maxLength (10 )
43@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.' )
54param ResourcePrefix string
65var abbrs = loadJsonContent ('./abbreviations.json' )
76
8-
97@allowed ([
108 'australiaeast'
119 'brazilsouth'
@@ -32,13 +30,24 @@ var abbrs = loadJsonContent('./abbreviations.json')
3230 'westus3'
3331])
3432@description ('Location for all Ai services resources. This location can be different from the resource group location.' )
35- param AzureAiServiceLocation string // The location used for all deployed resources. This location must be in the same region as the resource group.
33+ param AiLocation string // The location used for all deployed resources. This location must be in the same region as the resource group.
3634param capacity int = 5
3735
38- var uniqueId = toLower (uniqueString (subscription ().id , safePrefix , resourceGroup ().location ))
39- var UniquePrefix = 'cm${padLeft (take (uniqueId , 12 ), 12 , '0' )}'
40- var ResourcePrefix = take ('cm${safePrefix }${UniquePrefix }' , 15 )
41- var imageVersion = 'latest'
36+
37+ @description ('A unique prefix for all resources in this deployment. This should be 3-10 characters long:' )
38+ //param environmentName string
39+ var randomString = substring (uniqueString (resourceGroup ().id ), 0 , 4 )
40+ @description ('The location used for all deployed resources' )
41+ // Generate a unique string based on the base name and a unique identifier
42+ //var uniqueSuffix = uniqueString(resourceGroup().id, ResourcePrefix)
43+
44+ // Take the first 4 characters of the unique string to use as a suffix
45+ //var randomSuffix = substring(ResourcePrefix, 0, min(10, length(ResourcePrefix)))
46+
47+ // Combine the base name with the random suffix
48+ var finalName = '${ResourcePrefix }-${randomString }'
49+
50+ var imageVersion = 'rc1'
4251var location = resourceGroup ().location
4352var dblocation = resourceGroup ().location
4453var cosmosdbDatabase = 'cmsadb'
@@ -48,15 +57,14 @@ var cosmosdbLogContainer = 'cmsalog'
4857var deploymentType = 'GlobalStandard'
4958var containerName = 'appstorage'
5059var llmModel = 'gpt-4o'
60+ var prefixCleaned = replace (toLower (finalName ), '-' , '' )
5161var storageSkuName = 'Standard_LRS'
52-
5362var storageContainerName = '${abbrs .storage .storageAccount }${prefixCleaned }'
5463var gptModelVersion = '2024-08-06'
5564var aiServicesName = '${abbrs .ai .aiServices }${prefixCleaned }'
5665
5766
5867
59-
6068var aiModelDeployments = [
6169 {
6270 name : llmModel
@@ -70,26 +78,24 @@ var aiModelDeployments = [
7078 }
7179]
7280
73- resource azureAiServices 'Microsoft.CognitiveServices/accounts@2024-04-01-preview' = {
74- name : azureAiServicesName
81+ resource aiServices 'Microsoft.CognitiveServices/accounts@2024-04-01-preview' = {
82+ name : aiServicesName
7583 location : location
7684 sku : {
7785 name : 'S0'
7886 }
7987 kind : 'AIServices'
8088 properties : {
81-
8289 customSubDomainName : aiServicesName
8390 apiProperties : {
8491 // statisticsEnabled: false
8592 }
86-
8793 }
8894}
8995
9096@batchSize (1 )
91- resource azureAiServicesDeployments 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = [for aiModeldeployment in aiModelDeployments : {
92- parent : azureAiServices //aiServices_m
97+ resource aiServicesDeployments 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = [for aiModeldeployment in aiModelDeployments : {
98+ parent : aiServices //aiServices_m
9399 name : aiModeldeployment .name
94100 properties : {
95101 model : {
@@ -111,10 +117,8 @@ resource azureAiServicesDeployments 'Microsoft.CognitiveServices/accounts/deploy
111117module managedIdentityModule 'deploy_managed_identity.bicep' = {
112118 name : 'deploy_managed_identity'
113119 params : {
114-
115120 miName :'${abbrs .security .managedIdentity }${prefixCleaned }'
116121 solutionName : prefixCleaned
117-
118122 solutionLocation : location
119123 }
120124 scope : resourceGroup (resourceGroup ().name )
@@ -125,10 +129,8 @@ module managedIdentityModule 'deploy_managed_identity.bicep' = {
125129module kvault 'deploy_keyvault.bicep' = {
126130 name : 'deploy_keyvault'
127131 params : {
128-
129132 keyvaultName : '${abbrs .security .keyVault }${prefixCleaned }'
130133 solutionName : prefixCleaned
131-
132134 solutionLocation : location
133135 managedIdentityObjectId :managedIdentityModule .outputs .managedIdentityOutput .objectId
134136 }
@@ -137,40 +139,38 @@ module kvault 'deploy_keyvault.bicep' = {
137139
138140
139141// ==========AI Foundry and related resources ========== //
140- module azureAifoundry 'deploy_ai_foundry.bicep' = {
142+ module aifoundry 'deploy_ai_foundry.bicep' = {
141143 name : 'deploy_ai_foundry'
142144 params : {
143- solutionName : ResourcePrefix
144- solutionLocation : AzureAiServiceLocation
145+ solutionName : prefixCleaned
146+ solutionLocation : AiLocation
145147 keyVaultName : kvault .outputs .keyvaultName
146148 gptModelName : llmModel
147149 gptModelVersion : gptModelVersion
148150 managedIdentityObjectId :managedIdentityModule .outputs .managedIdentityOutput .objectId
149- aiServicesEndpoint : azureAiServices .properties .endpoint
150- aiServicesKey : azureAiServices .listKeys ().key1
151- aiServicesId : azureAiServices .id
151+ aiServicesEndpoint : aiServices .properties .endpoint
152+ aiServicesKey : aiServices .listKeys ().key1
153+ aiServicesId : aiServices .id
152154 }
153155 scope : resourceGroup (resourceGroup ().name )
154156}
155157
156158module containerAppsEnvironment 'br/public:avm/res/app/managed-environment:0.9.1' = {
157- name : toLower ('${ResourcePrefix }conAppsEnv' )
159+ name : toLower ('${prefixCleaned }conAppsEnv' )
158160 params : {
159- logAnalyticsWorkspaceResourceId : azureAifoundry .outputs .logAnalyticsId
160- name : toLower ('${ResourcePrefix }manenv' )
161+ logAnalyticsWorkspaceResourceId : aifoundry .outputs .logAnalyticsId
162+ name : toLower ('${prefixCleaned }manenv' )
161163 location : location
162164 zoneRedundant : false
163165 managedIdentities : managedIdentityModule
164166 }
165167}
166168
167169module databaseAccount 'br/public:avm/res/document-db/database-account:0.9.0' = {
168- name : toLower ('${ResourcePrefix }cosmos ' )
170+ name : toLower ('${prefixCleaned }database ' )
169171 params : {
170172 // Required parameters
171-
172173 name : toLower ('${abbrs .databases .cosmosDBDatabase }${prefixCleaned }databaseAccount' )
173-
174174 // Non-required parameters
175175 enableAnalyticalStorage : true
176176 location : dblocation
@@ -234,9 +234,7 @@ module databaseAccount 'br/public:avm/res/document-db/database-account:0.9.0' =
234234}
235235
236236module containerAppFrontend 'br/public:avm/res/app/container-app:0.13.0' = {
237-
238237 name : toLower ('${abbrs .containers .containerApp }${prefixCleaned }containerAppFrontend' )
239-
240238 params : {
241239 managedIdentities : {
242240 systemAssigned : true
@@ -266,19 +264,15 @@ module containerAppFrontend 'br/public:avm/res/app/container-app:0.13.0' = {
266264 scaleMinReplicas : 1
267265 scaleMaxReplicas : 1
268266 environmentResourceId : containerAppsEnvironment .outputs .resourceId
269-
270267 name : toLower ('${abbrs .containers .containerApp }${prefixCleaned }containerFrontend' )
271-
272268 // Non-required parameters
273269 location : location
274270 }
275271}
276272
277273
278274resource containerAppBackend 'Microsoft.App/containerApps@2023-05-01' = {
279-
280275 name : toLower ('${abbrs .containers .containerApp }${prefixCleaned }containerBackend' )
281-
282276 location : location
283277 identity : {
284278 type : 'SystemAssigned'
@@ -331,7 +325,7 @@ resource containerAppBackend 'Microsoft.App/containerApps@2023-05-01' = {
331325 }
332326 {
333327 name : 'AZURE_OPENAI_ENDPOINT'
334- value : 'https://${azureAifoundry .outputs .aiServicesName }.openai.azure.com/'
328+ value : 'https://${aifoundry .outputs .aiServicesName }.openai.azure.com/'
335329 }
336330 {
337331 name : 'MIGRATOR_AGENT_MODEL_DEPLOY'
@@ -361,26 +355,6 @@ resource containerAppBackend 'Microsoft.App/containerApps@2023-05-01' = {
361355 name : 'TERMINATION_MODEL_DEPLOY'
362356 value : llmModel
363357 }
364- {
365- name : 'AZURE_AI_AGENT_MODEL_DEPLOYMENT_NAME'
366- value : llmModel
367- }
368- {
369- name : 'AZURE_AI_AGENT_PROJECT_NAME'
370- value : azureAifoundry .outputs .aiProjectName
371- }
372- {
373- name : 'AZURE_AI_AGENT_RESOURCE_GROUP_NAME'
374- value : resourceGroup ().name
375- }
376- {
377- name : 'AZURE_AI_AGENT_SUBSCRIPTION_ID'
378- value : subscription ().subscriptionId
379- }
380- {
381- name : 'AZURE_AI_AGENT_PROJECT_CONNECTION_STRING'
382- value : azureAifoundry .outputs .projectConnectionString
383- }
384358 ]
385359 resources : {
386360 cpu : 1
@@ -454,7 +428,7 @@ var openAiContributorRoleId = 'a001fd3d-188f-4b5d-821b-7da978bf7442' // Fixed R
454428
455429resource openAiRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
456430 name : guid (containerAppBackend .id , openAiContributorRoleId )
457- scope : azureAiServices
431+ scope : aiServices
458432 properties : {
459433 roleDefinitionId : subscriptionResourceId ('Microsoft.Authorization/roleDefinitions' , openAiContributorRoleId ) // OpenAI Service Contributor
460434 principalId : containerAppBackend .identity .principalId
@@ -471,25 +445,9 @@ resource containers 'Microsoft.Storage/storageAccounts/blobServices/containers@2
471445 properties : {
472446 publicAccess : 'None'
473447 }
474- dependsOn : [azureAifoundry ]
448+ dependsOn : [aifoundry ]
475449}]
476450
477- resource aiHubProject 'Microsoft.MachineLearningServices/workspaces@2024-01-01-preview' existing = {
478- name : '${ResourcePrefix }-prj' // aiProjectName must be calculated - available at main start.
479- }
480-
481- resource aiDeveloper 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
482- name : '64702f94-c441-49e6-a78b-ef80e0188fee'
483- }
484-
485- resource aiDeveloperAccessProj 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
486- name : guid (containerAppBackend .name , aiHubProject .id , aiDeveloper .id )
487- scope : aiHubProject
488- properties : {
489- roleDefinitionId : aiDeveloper .id
490- principalId : containerAppBackend .identity .principalId
491- }
492- }
493451
494452resource contributorRoleDefinition 'Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions@2021-06-15' existing = {
495453 name : '${databaseAccount .name }/00000000-0000-0000-0000-000000000002'
0 commit comments