Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 33 additions & 35 deletions infra/main.bicep
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 = {}
Expand All @@ -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'
Expand All @@ -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')
Expand All @@ -96,7 +95,6 @@ resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' = {
}
}


var aiModelDeployments = [
{
name: gptModelVersion
Expand All @@ -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)
}
Expand All @@ -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
Expand Down Expand Up @@ -196,7 +196,7 @@ resource cosmos 'Microsoft.DocumentDB/databaseAccounts@2024-05-15' = {
locationName: location
}
]
capabilities: [ { name: 'EnableServerless' } ]
capabilities: [{ name: 'EnableServerless' }]
}

resource contributorRoleDefinition 'sqlRoleDefinitions' existing = {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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' = {
Expand Down Expand Up @@ -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'
}
]
}
}
Expand Down Expand Up @@ -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'
Expand Down
Loading