-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmain.bicep
123 lines (109 loc) · 3.44 KB
/
main.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
targetScope = 'subscription'
@minLength(1)
@maxLength(64)
@description('Name of the the environment which is used to generate a short unique hash used in all resources.')
param environmentName string
@minLength(1)
@description('Location for the OpenAI resource')
// https://learn.microsoft.com/azure/ai-services/openai/concepts/models?tabs=python-secure%2Cglobal-standard%2Cstandard-chat-completions#models-by-deployment-type
@allowed([
'australiaeast'
'brazilsouth'
'canadaeast'
'eastus'
'eastus2'
'francecentral'
'germanywestcentral'
'japaneast'
'koreacentral'
'northcentralus'
'norwayeast'
'polandcentral'
'southafricanorth'
'southcentralus'
'southindia'
'spaincentral'
'swedencentral'
'switzerlandnorth'
'uksouth'
'westeurope'
'westus'
'westus3'
])
@metadata({
azd: {
type: 'location'
}
})
param location string
@description('Name of the GPT model to deploy')
param gptModelName string = 'gpt-4o-mini'
@description('Version of the GPT model to deploy')
// See version availability in this table:
// https://learn.microsoft.com/azure/ai-services/openai/concepts/models?tabs=python-secure%2Cglobal-standard%2Cstandard-chat-completions#models-by-deployment-type
param gptModelVersion string = '2024-07-18'
@description('Name of the model deployment (can be different from the model name)')
param gptDeploymentName string = 'gpt-4o-mini'
@description('Capacity of the GPT deployment')
// You can increase this, but capacity is limited per model/region, so you will get errors if you go over
// https://learn.microsoft.com/en-us/azure/ai-services/openai/quotas-limits
param gptDeploymentCapacity int = 30
@description('Id of the user or app to assign application roles')
param principalId string = ''
@description('Non-empty if the deployment is running on GitHub Actions')
param runningOnGitHub string = ''
var principalType = empty(runningOnGitHub) ? 'User' : 'ServicePrincipal'
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
var prefix = '${environmentName}${resourceToken}'
var tags = { 'azd-env-name': environmentName }
// Organize resources in a resource group
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: '${prefix}-rg'
location: location
tags: tags
}
var openAiServiceName = '${prefix}-openai'
module openAi 'br/public:avm/res/cognitive-services/account:0.7.1' = {
name: 'openai'
scope: resourceGroup
params: {
name: openAiServiceName
location: location
tags: tags
kind: 'OpenAI'
sku: 'S0'
customSubDomainName: openAiServiceName
networkAcls: {
defaultAction: 'Allow'
bypass: 'AzureServices'
}
deployments: [
{
name: gptDeploymentName
model: {
format: 'OpenAI'
name: gptModelName
version: gptModelVersion
}
sku: {
name: 'GlobalStandard'
capacity: gptDeploymentCapacity
}
}
]
roleAssignments: [
{
principalId: principalId
roleDefinitionIdOrName: 'Cognitive Services OpenAI User'
principalType: principalType
}
]
}
}
output AZURE_LOCATION string = location
output AZURE_TENANT_ID string = tenant().tenantId
output AZURE_RESOURCE_GROUP string = resourceGroup.name
// Specific to Azure OpenAI
output AZURE_OPENAI_SERVICE string = openAi.outputs.name
output AZURE_OPENAI_GPT_MODEL string = gptModelName
output AZURE_OPENAI_GPT_DEPLOYMENT string = gptDeploymentName