Skip to content
Draft
4 changes: 4 additions & 0 deletions Backend/bicep/abbreviations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"keyVaultVaults": "kv-",
"resourcesResourceGroups": "rg-"
}
50 changes: 50 additions & 0 deletions Backend/bicep/ai.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
param name string
param location string
param deployments array = [
{
name: 'chat'
model: {
format: 'OpenAI'
name: 'gpt-4'
version: '0613'
}
sku: {
capacity: 1000
}
}
]

@description('')
resource azureOpenAiResource 'Microsoft.CognitiveServices/accounts@2023-10-01-preview' = {
name: name
location: location
sku: {
name: 'S0'
}
kind: 'OpenAI'
tags: {}
properties: {
// customSubDomainName: needed?
networkAcls: {
defaultAction: 'Allow'
virtualNetworkRules: []
ipRules: []
}
publicNetworkAccess: 'Enabled'
}
}

resource modelDeployments 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = [for item in deployments: {
parent: azureOpenAiResource
name: item.name
sku: (contains(item, 'sku') ? item.sku : {
name: 'Standard'
capacity: item.capacity
})
properties: {
model: item.model
raiPolicyName: (contains(item, 'raiPolicyName') ? item.raiPolicyName : null)
}
}]

output endpoint string = azureOpenAiResource.properties.endpoint
54 changes: 54 additions & 0 deletions Backend/bicep/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
targetScope='subscription'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: rename "bicep" directory to "infra", align with azd standard

// The main bicep module to provision Azure resources.
// For a more complete walkthrough to understand how this file works with azd,
// see https://learn.microsoft.com/azure/developer/azure-developer-cli/make-azd-compatible?pivots=azd-create

var abbrs = loadJsonContent('./abbreviations.json')

// Optional parameters to override the default azd resource naming conventions.
// Add the following to main.parameters.json to provide values:
// "resourceGroupName": {
// "value": "myGroupName"
// }
param resourceGroupName string = ''
param azureOpenAIServiceName string = ''

@minLength(1)
@maxLength(64)
@description('Name of the environment which is used to generate a short, unique hash used in all resources.')
// For an overview on this and other key Azure concepts,
// see https://learn.microsoft.com/azure/deployment-environments/concept-environments-key-concepts#environments
param environmentName string

// tags that will be applied to all resources.
var tags = {
// Tag all resources with the environment name.
'azd-env-name': environmentName
}

@description('Location of all resources')
param location string

// Generate a unique token to be used in naming resources.
// Remove linter suppression after using.
#disable-next-line no-unused-vars
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))

// Resources are organized in a resource group
resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: !empty(resourceGroupName) ? resourceGroupName : '${abbrs.resourcesResourceGroups}${environmentName}'
location: location
tags: tags
}

module azureOpenAi 'ai.bicep' = {
name: 'azureOpenAi'
params: {
name: !empty(azureOpenAIServiceName) ? azureOpenAIServiceName : 'aoai-${resourceToken}'
location: location
}
scope: rg
}

output AZURE_OPENAI_ENDPOINT string = azureOpenAi.outputs.endpoint
18 changes: 18 additions & 0 deletions Backend/bicep/main.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"environmentName": {
"value": "${AZURE_ENV_NAME}"
},
"location": {
"value": "${AZURE_LOCATION}"
},
"resourceGroupName": {
"value": "${AZURE_RESOURCE_GROUP}"
},
"openAiServiceName": {
"value": "${AZURE_OPENAI_SERVICE}"
}
}
}