diff --git a/infra/main.bicep b/infra/main.bicep index 918a3276..25d88d17 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -1,6 +1,6 @@ targetScope = 'resourceGroup' @description('Location for all resources.') -param location string = 'EastUS2' //Fixed for model availability, change back to resourceGroup().location +param location string @allowed([ 'australiaeast' @@ -33,7 +33,7 @@ param azureOpenAILocation string = 'eastus2' // The location used for all deploy @minLength(3) @maxLength(20) @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.') -param prefix string = take('macaeo-${uniqueString(resourceGroup().id)}', 10) +param prefix string @description('Tags to apply to all deployed resources') param tags object = {} @@ -56,12 +56,11 @@ param resourceSize { maxReplicas: 1 } } -param capacity int = 10 - +param capacity int = 40 var modelVersion = '2024-08-06' var aiServicesName = '${prefix}-aiservices' -var deploymentType = 'GlobalStandard' +var deploymentType = 'GlobalStandard' var gptModelVersion = 'gpt-4o' var appVersion = 'fnd01' var resgistryName = 'biabcontainerreg' @@ -72,7 +71,7 @@ var backendDockerImageURL = '${resgistryName}.azurecr.io/macaebackend:${appVersi var frontendDockerImageURL = '${resgistryName}.azurecr.io/macaefrontend:${appVersion}' var uniqueNameFormat = '${prefix}-{0}-${uniqueString(resourceGroup().id, prefix)}' -var aoaiApiVersion = '2024-08-01-preview' +var aoaiApiVersion = '2025-01-01-preview' resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-09-01' = { name: format(uniqueNameFormat, 'logs') @@ -96,7 +95,6 @@ resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' = { } } - var aiModelDeployments = [ { name: gptModelVersion @@ -120,34 +118,36 @@ resource aiServices 'Microsoft.CognitiveServices/accounts@2024-04-01-preview' = properties: { customSubDomainName: aiServicesName apiProperties: { - statisticsEnabled: false + //statisticsEnabled: false } } } -resource aiServicesDeployments 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = [for aiModeldeployment in aiModelDeployments: { - parent: aiServices //aiServices_m - name: aiModeldeployment.name - properties: { - model: { - format: 'OpenAI' - name: aiModeldeployment.model - version: aiModeldeployment.version +resource aiServicesDeployments 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = [ + for aiModeldeployment in aiModelDeployments: { + parent: aiServices //aiServices_m + name: aiModeldeployment.name + properties: { + model: { + format: 'OpenAI' + name: aiModeldeployment.model + version: aiModeldeployment.version + } + raiPolicyName: aiModeldeployment.raiPolicyName + } + sku: { + name: aiModeldeployment.sku.name + capacity: aiModeldeployment.sku.capacity } - raiPolicyName: aiModeldeployment.raiPolicyName - } - sku:{ - name: aiModeldeployment.sku.name - capacity: aiModeldeployment.sku.capacity } -}] +] module kvault 'deploy_keyvault.bicep' = { name: 'deploy_keyvault' params: { solutionName: prefix solutionLocation: location - managedIdentityObjectId:managedIdentityModule.outputs.managedIdentityOutput.objectId + managedIdentityObjectId: managedIdentityModule.outputs.managedIdentityOutput.objectId } scope: resourceGroup(resourceGroup().name) } @@ -160,7 +160,7 @@ module aifoundry 'deploy_ai_foundry.bicep' = { keyVaultName: kvault.outputs.keyvaultName gptModelName: gptModelVersion gptModelVersion: gptModelVersion - managedIdentityObjectId:managedIdentityModule.outputs.managedIdentityOutput.objectId + managedIdentityObjectId: managedIdentityModule.outputs.managedIdentityOutput.objectId aiServicesEndpoint: aiServices.properties.endpoint aiServicesKey: aiServices.listKeys().key1 aiServicesId: aiServices.id @@ -196,7 +196,7 @@ resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = { locationName: location } ] - capabilities: [ { name: 'EnableServerless' } ] + capabilities: [{ name: 'EnableServerless' }] } resource contributorRoleDefinition 'sqlRoleDefinitions' existing = { @@ -231,14 +231,11 @@ resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = { } // Define existing ACR resource - resource pullIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-07-31-preview' = { name: format(uniqueNameFormat, 'containerapp-pull') location: location } - - resource containerAppEnv 'Microsoft.App/managedEnvironments@2024-03-01' = { name: format(uniqueNameFormat, 'containerapp') location: location @@ -335,7 +332,7 @@ resource containerApp 'Microsoft.App/containerApps@2024-03-01' = { } { name: 'AZURE_OPENAI_ENDPOINT' - value: aiServices.properties.endpoint + value: replace(aiServices.properties.endpoint, 'cognitiveservices.azure.com', 'openai.azure.com') } { name: 'AZURE_OPENAI_MODEL_NAME' @@ -377,15 +374,12 @@ resource containerApp 'Microsoft.App/containerApps@2024-03-01' = { name: 'FRONTEND_SITE_NAME' value: 'https://${format(uniqueNameFormat, 'frontend')}.azurewebsites.net' } - ] } ] } - - } - } +} resource frontendAppServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = { name: format(uniqueNameFormat, 'frontend-plan') location: location @@ -398,7 +392,7 @@ resource frontendAppServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = { properties: { reserved: true } - kind: 'linux' // Add this line to support Linux containers + kind: 'linux' // Add this line to support Linux containers } resource frontendAppService 'Microsoft.Web/sites@2021-02-01' = { @@ -428,6 +422,10 @@ resource frontendAppService 'Microsoft.Web/sites@2021-02-01' = { name: 'BACKEND_API_URL' value: 'https://${containerApp.properties.configuration.ingress.fqdn}' } + { + name: 'AUTH_ENABLED' + value: 'false' + } ] } } @@ -457,7 +455,7 @@ resource aiDeveloperAccessProj 'Microsoft.Authorization/roleAssignments@2022-04- } } -var cosmosAssignCli = 'az cosmosdb sql role assignment create --resource-group "${resourceGroup().name}" --account-name "${cosmos.name}" --role-definition-id "${cosmos::contributorRoleDefinition.id}" --scope "${cosmos.id}" --principal-id "${containerApp.identity.principalId}"' +var cosmosAssignCli = 'az cosmosdb sql role assignment create --resource-group "${resourceGroup().name}" --account-name "${cosmos.name}" --role-definition-id "${cosmos::contributorRoleDefinition.id}" --scope "${cosmos.id}" --principal-id "${containerApp.identity.principalId}"' module managedIdentityModule 'deploy_managed_identity.bicep' = { name: 'deploy_managed_identity'