Deploying OpenAI Models to Azure with Bicep

Deploying an Azure OpenAI Service with GPT Models is pretty straight forward. However, I ran into an issue where deploying two models at the same time resulted in the following error most of the time:

Another operation is being performed on the parent resource ‘/subscriptions/xxxxxxxxxxxxxxxx/resourceGroups/openaibiceptest/providers/Microsoft.CognitiveServices/accounts/mlbiceptest’. Please try again later.”

Turns out Azure does not like deploying multiple models simultaneously to OpenAI, so we need to make sure these run in sqeuence. Luckily this is pretty straight forward to do with bicep. Only thing we need to add is a dependency (here in line 37) from one model to the other to await the deployment before starting the next one.

You could also add even more models like this by just making sure you have a chain of models deployed in sqeuence.

param openAIAccountName string
param location string
resource openAIAccount 'Microsoft.CognitiveServices/accounts@2024-04-01-preview' = {
name: openAIAccountName
location: location
sku: {
name: 'S0'
}
kind: 'OpenAI'
properties: {
publicNetworkAccess: 'Enabled'
}
}
resource gpt4 'Microsoft.CognitiveServices/accounts/deployments@2024-04-01-preview' = {
parent: openAIAccount
name: '${openAIAccountName}GPT4'
sku: {
name: 'Standard'
capacity: 10
}
properties: {
model: {
format: 'OpenAI'
name: 'gpt-4'
version: '0613'
}
versionUpgradeOption: 'OnceNewDefaultVersionAvailable'
currentCapacity: 10
raiPolicyName: 'Microsoft.Default'
}
}
resource gpt3_5 'Microsoft.CognitiveServices/accounts/deployments@2024-04-01-preview' = {
parent: openAIAccount
dependsOn: [gpt4]
name: '${openAIAccountName}GPT35'
sku: {
name: 'Standard'
capacity: 120
}
properties: {
model: {
format: 'OpenAI'
name: 'gpt-35-turbo'
version: '0301'
}
versionUpgradeOption: 'OnceNewDefaultVersionAvailable'
currentCapacity: 120
raiPolicyName: 'Microsoft.Default'
}
}
view raw openai.bicep hosted with ❤ by GitHub

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.