-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathopenai.bicep
105 lines (98 loc) · 3.75 KB
/
openai.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
import { roleAssignmentInfo } from '../security/managed-identity.bicep'
@description('Name of the resource.')
param name string
@description('Location to deploy the resource. Defaults to the location of the resource group.')
param location string = resourceGroup().location
@description('Tags for the resource.')
param tags object = {}
@export()
@description('Information about a model deployment for an OpenAI resource.')
type modelDeploymentInfo = {
@description('Name for the model deployment. Must be unique within the OpenAI resource.')
name: string
@description('Information about the model to deploy.')
model: {
@description('Format of the model. Expects "OpenAI".')
format: string
@description('ID of the model, e.g., gpt-35-turbo. For more information on model IDs: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models')
name: string
@description('Version of the model, e.g., 0125. For more information on model versions: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models')
version: string
}?
@description('Name of the content filter policy to apply to the model deployment.')
raiPolicyName: string?
@description('Sizing for the model deployment.')
sku: {
@description('Name of the SKU. Expects "Standard".')
name: string
@description('TPM quota allocation for the model deployment. For more information on model quota limits per region: https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models')
capacity: int
}?
}
@description('List of model deployments.')
param deployments modelDeploymentInfo[] = []
@description('Whether to enable public network access. Defaults to Enabled.')
@allowed([
'Enabled'
'Disabled'
])
param publicNetworkAccess string = 'Enabled'
@description('Whether to disable local (key-based) authentication. Defaults to true.')
param disableLocalAuth bool = true
@description('Role assignments to create for the OpenAI resource.')
param roleAssignments roleAssignmentInfo[] = []
resource openAI 'Microsoft.CognitiveServices/accounts@2024-04-01-preview' = {
name: name
location: location
tags: tags
kind: 'OpenAI'
properties: {
customSubDomainName: toLower(name)
disableLocalAuth: disableLocalAuth
publicNetworkAccess: publicNetworkAccess
networkAcls: {
defaultAction: 'Allow'
ipRules: []
virtualNetworkRules: []
}
}
sku: {
name: 'S0'
}
}
@batchSize(1)
resource deployment 'Microsoft.CognitiveServices/accounts/deployments@2024-04-01-preview' = [
for deployment in deployments: {
parent: openAI
name: deployment.name
properties: {
model: deployment.?model ?? null
raiPolicyName: deployment.?raiPolicyName ?? null
}
sku: deployment.?sku ?? {
name: 'Standard'
capacity: 20
}
}
]
resource assignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = [
for roleAssignment in roleAssignments: {
name: guid(openAI.id, roleAssignment.principalId, roleAssignment.roleDefinitionId)
scope: openAI
properties: {
principalId: roleAssignment.principalId
roleDefinitionId: roleAssignment.roleDefinitionId
principalType: roleAssignment.principalType
}
}
]
@description('The deployed OpenAI resource.')
output resource resource = openAI
@description('ID for the deployed OpenAI resource.')
output id string = openAI.id
@description('Name for the deployed OpenAI resource.')
output name string = openAI.name
@description('Endpoint for the deployed OpenAI resource.')
output endpoint string = openAI.properties.endpoint
@description('Host for the deployed OpenAI resource.')
output host string = split(openAI.properties.endpoint, '/')[2]