11targetScope = 'resourceGroup'
2+ @description ('Location for all resources.' )
3+ param location string = resourceGroup ().location
24
35@allowed ([
46 'australiaeast'
@@ -26,23 +28,16 @@ targetScope = 'resourceGroup'
2628 'westus3'
2729])
2830@description ('Location for all Ai services resources. This location can be different from the resource group location.' )
29- param azureOpenAILocation string
31+ param azureOpenAILocation string = 'eastus2' // The location used for all deployed resources. This location must be in the same region as the resource group.
3032
3133@minLength (3 )
3234@maxLength (20 )
3335@description ('A unique prefix for all resources in this deployment. This should be 3-20 characters long:' )
3436param environmentName string
35-
36- @description ('Set this if you want to deploy to a different region than the resource group. Otherwise, it will use the resource group location by default.' )
37- param AZURE_LOCATION string
38- var solutionLocation = empty (AZURE_LOCATION ) ? resourceGroup ().location : AZURE_LOCATION
39-
40- var uniqueId = toLower (uniqueString (subscription ().id , environmentName , solutionLocation ))
37+
38+ var uniqueId = toLower (uniqueString (subscription ().id , environmentName , resourceGroup ().location ))
4139var solutionPrefix = 'ma${padLeft (take (uniqueId , 12 ), 12 , '0' )}'
4240
43- // Load the abbrevations file required to name the azure resources.
44- var abbrs = loadJsonContent ('./abbreviations.json' )
45-
4641@description ('Tags to apply to all deployed resources' )
4742param tags object = {}
4843
@@ -67,23 +62,23 @@ param resourceSize {
6762param capacity int = 140
6863
6964var modelVersion = '2024-08-06'
70- var aiServicesName = '${abbrs . ai . aiServices }${ solutionPrefix }'
65+ var aiServicesName = '${solutionPrefix }-aiservices '
7166var deploymentType = 'GlobalStandard'
7267var gptModelVersion = 'gpt-4o'
73- var appVersion = 'fnd01 '
68+ var appVersion = 'latest '
7469var resgistryName = 'biabcontainerreg'
7570var dockerRegistryUrl = 'https://${resgistryName }.azurecr.io'
7671
7772@description ('URL for frontend docker image' )
7873var backendDockerImageURL = '${resgistryName }.azurecr.io/macaebackend:${appVersion }'
7974var frontendDockerImageURL = '${resgistryName }.azurecr.io/macaefrontend:${appVersion }'
8075
81- // var uniqueNameFormat = '${solutionPrefix}-{0}-${uniqueString(resourceGroup().id, solutionPrefix)}'
76+ var uniqueNameFormat = '${solutionPrefix }-{0}-${uniqueString (resourceGroup ().id , solutionPrefix )}'
8277var aoaiApiVersion = '2025-01-01-preview'
8378
8479resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
85- name : '${ abbrs . managementGovernance . logAnalyticsWorkspace }${ solutionPrefix }'
86- location : solutionLocation
80+ name : format ( uniqueNameFormat , 'logs' )
81+ location : location
8782 tags : tags
8883 properties : {
8984 retentionInDays : 30
@@ -94,8 +89,8 @@ resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
9489}
9590
9691resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' = {
97- name : '${ abbrs . managementGovernance . applicationInsights }${ solutionPrefix }'
98- location : solutionLocation
92+ name : format ( uniqueNameFormat , 'appins' )
93+ location : location
9994 kind : 'web'
10095 properties : {
10196 Application_Type : 'web'
@@ -118,7 +113,7 @@ var aiModelDeployments = [
118113
119114resource aiServices 'Microsoft.CognitiveServices/accounts@2024-04-01-preview' = {
120115 name : aiServicesName
121- location : azureOpenAILocation
116+ location : location
122117 sku : {
123118 name : 'S0'
124119 }
@@ -128,8 +123,7 @@ resource aiServices 'Microsoft.CognitiveServices/accounts@2024-04-01-preview' =
128123 apiProperties : {
129124 //statisticsEnabled: false
130125 }
131- disableLocalAuth : true
132- publicNetworkAccess : 'Enabled'
126+ //disableLocalAuth: true
133127 }
134128}
135129
@@ -155,9 +149,9 @@ resource aiServicesDeployments 'Microsoft.CognitiveServices/accounts/deployments
155149module kvault 'deploy_keyvault.bicep' = {
156150 name : 'deploy_keyvault'
157151 params : {
158- solutionLocation : solutionLocation
152+ solutionName : solutionPrefix
153+ solutionLocation : location
159154 managedIdentityObjectId : managedIdentityModule .outputs .managedIdentityOutput .objectId
160- keyvaultName : '${abbrs .security .keyVault }${solutionPrefix }'
161155 }
162156 scope : resourceGroup (resourceGroup ().name )
163157}
@@ -197,8 +191,8 @@ resource acaAoaiRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-
197191}
198192
199193resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = {
200- name : '${ abbrs . databases . cosmosDBDatabase }${ solutionPrefix }'
201- location : solutionLocation
194+ name : format ( uniqueNameFormat , 'cosmos' )
195+ location : location
202196 tags : tags
203197 kind : 'GlobalDocumentDB'
204198 properties : {
@@ -207,7 +201,7 @@ resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = {
207201 locations : [
208202 {
209203 failoverPriority : 0
210- locationName : solutionLocation
204+ locationName : location
211205 }
212206 ]
213207 capabilities : [{ name : 'EnableServerless' }]
@@ -247,13 +241,13 @@ resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = {
247241// Define existing ACR resource
248242
249243resource pullIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-07-31-preview' = {
250- name : '${ abbrs . security . managedIdentity }${ solutionPrefix }- containerapp-pull'
251- location : solutionLocation
244+ name : format ( uniqueNameFormat , ' containerapp-pull')
245+ location : location
252246}
253247
254248resource containerAppEnv 'Microsoft.App/managedEnvironments@2024-03-01' = {
255- name : '${ abbrs . containers . containerAppsEnvironment }${ solutionPrefix }'
256- location : solutionLocation
249+ name : format ( uniqueNameFormat , 'containerapp' )
250+ location : location
257251 tags : tags
258252 properties : {
259253 daprAIConnectionString : appInsights .properties .ConnectionString
@@ -285,8 +279,8 @@ resource acaCosomsRoleAssignment 'Microsoft.DocumentDB/databaseAccounts/sqlRoleA
285279
286280@description ('' )
287281resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {
288- name : '${abbrs . containers . containerApp }${ solutionPrefix }-backend'
289- location : solutionLocation
282+ name : '${solutionPrefix }-backend'
283+ location : location
290284 tags : tags
291285 identity : {
292286 type : 'SystemAssigned, UserAssigned'
@@ -302,8 +296,8 @@ resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {
302296 external : true
303297 corsPolicy : {
304298 allowedOrigins : [
305- 'https://${abbrs . compute . webApp }${ solutionPrefix }- frontend.azurewebsites.net'
306- 'http://${abbrs . compute . webApp }${ solutionPrefix }- frontend.azurewebsites.net'
299+ 'https://${format ( uniqueNameFormat , ' frontend' )} .azurewebsites.net'
300+ 'http://${format ( uniqueNameFormat , ' frontend' )} .azurewebsites.net'
307301 ]
308302 }
309303 }
@@ -387,7 +381,7 @@ resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {
387381 }
388382 {
389383 name : 'FRONTEND_SITE_NAME'
390- value : 'https://${abbrs . compute . webApp }${ solutionPrefix }- frontend.azurewebsites.net'
384+ value : 'https://${format ( uniqueNameFormat , ' frontend' )} .azurewebsites.net'
391385 }
392386 ]
393387 }
@@ -396,13 +390,13 @@ resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {
396390 }
397391}
398392resource frontendAppServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = {
399- name : '${ abbrs . compute . appServicePlan }${ solutionPrefix }- frontend'
400- location : solutionLocation
393+ name : format ( uniqueNameFormat , ' frontend-plan' )
394+ location : location
401395 tags : tags
402396 sku : {
403- name : 'B2 '
397+ name : 'P1v2 '
404398 capacity : 1
405- tier : 'Basic '
399+ tier : 'PremiumV2 '
406400 }
407401 properties : {
408402 reserved : true
@@ -411,8 +405,8 @@ resource frontendAppServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = {
411405}
412406
413407resource frontendAppService 'Microsoft.Web/sites@2021-02-01' = {
414- name : '${ abbrs . compute . webApp }${ solutionPrefix }- frontend'
415- location : solutionLocation
408+ name : format ( uniqueNameFormat , ' frontend')
409+ location : location
416410 tags : tags
417411 kind : 'app,linux,container'
418412 properties : {
@@ -446,15 +440,15 @@ resource frontendAppService 'Microsoft.Web/sites@2021-02-01' = {
446440 }
447441 dependsOn : [containerApp ]
448442 identity : {
449- type : 'SystemAssigned, UserAssigned'
443+ type : 'SystemAssigned,UserAssigned'
450444 userAssignedIdentities : {
451445 '${pullIdentity .id }' : {}
452446 }
453447 }
454448}
455449
456450resource aiHubProject 'Microsoft.MachineLearningServices/workspaces@2024-01-01-preview' existing = {
457- name : '${abbrs . ai . aiHubProject }${ solutionPrefix }' // aiProjectName must be calculated - available at main start.
451+ name : '${solutionPrefix }-aiproject ' // aiProjectName must be calculated - available at main start.
458452}
459453
460454resource aiDeveloper 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
@@ -475,11 +469,11 @@ var cosmosAssignCli = 'az cosmosdb sql role assignment create --resource-group "
475469module managedIdentityModule 'deploy_managed_identity.bicep' = {
476470 name : 'deploy_managed_identity'
477471 params : {
472+ solutionName : solutionPrefix
478473 //solutionLocation: location
479474 managedIdentityId : pullIdentity .id
480475 managedIdentityPropPrin : pullIdentity .properties .principalId
481476 managedIdentityLocation : pullIdentity .location
482- miName : '${abbrs .security .managedIdentity }${solutionPrefix }'
483477 }
484478 scope : resourceGroup (resourceGroup ().name )
485479}
@@ -492,7 +486,7 @@ module deploymentScriptCLI 'br/public:avm/res/resources/deployment-script:0.5.1'
492486 name : 'rdsmin001'
493487 // Non-required parameters
494488 azCliVersion : '2.69.0'
495- location : solutionLocation
489+ location : location
496490 managedIdentities : {
497491 userAssignedResourceIds : [
498492 managedIdentityModule .outputs .managedIdentityId
0 commit comments