-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathai-hub-model-serverless-endpoint.bicep
112 lines (101 loc) · 4.47 KB
/
ai-hub-model-serverless-endpoint.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
@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('Key Vault configuration information for storing keys for serverless endpoint deployments.')
type keyVaultConfigInfo = {
@description('Name of the key vault.')
name: string
@description('Name of the key for the primary key.')
primaryKeySecretName: string
@description('Name of the key for the secondary key.')
secondaryKeySecretName: string
}
@export()
@description('Serverless model information for serverless endpoint deployments.')
type serverlessModelInfo = {
@description('Name of the model. The model ID will be determined by the template.')
name: string?
@description('Model ID. Optional override if the expected model name is not supported. Value may start with azureml://.')
id: string?
}
@export()
@description('Serverless model deployment information.')
type serverlessModelDeploymentInfo = {
@description('Name for the serverless model deployment.')
name: string
@description('Serverless model information.')
model: serverlessModelInfo
@description('Key Vault configuration for the serverless model deployment.')
keyVaultConfig: keyVaultConfigInfo
}
@export()
@description('Output information for serverless endpoint deployments.')
type serverlessModelDeploymentOutputInfo = {
@description('ID for the deployed AI model serverless endpoint resource.')
id: string
@description('Name for the deployed AI model serverless endpoint resource.')
name: string
@description('Inference endpoint for the deployed AI model serverless endpoint resource.')
endpoint: string
@description('Primary key secret name for the deployed AI model serverless endpoint resource.')
primaryKeySecretName: string
@description('Secondary key secret name for the deployed AI model serverless endpoint resource.')
secondaryKeySecretName: string
}
@description('Name for the AI Hub resource to deploy the serverless endpoint to.')
param aiHubName string
@description('Model to deploy as a serverless endpoint.')
param model serverlessModelInfo
@description('Key Vault configuration to store endpoint keys.')
param keyVaultConfig keyVaultConfigInfo?
var models = loadJsonContent('./models.json')
var modelId = contains(model, 'id') ? model.id! : models.serverless[model.name!]
resource aiHub 'Microsoft.MachineLearningServices/workspaces@2024-04-01-preview' existing = {
name: aiHubName
}
resource modelServerlessEndpoint 'Microsoft.MachineLearningServices/workspaces/serverlessEndpoints@2024-04-01-preview' = {
name: name
location: location
tags: tags
parent: aiHub
sku: {
name: 'Consumption'
}
properties: {
modelSettings: {
modelId: modelId
}
}
}
module primaryKeySecret '../security/key-vault-secret.bicep' = if (keyVaultConfig != null) {
name: keyVaultConfig!.primaryKeySecretName
params: {
name: keyVaultConfig!.primaryKeySecretName
keyVaultName: keyVaultConfig!.name
value: modelServerlessEndpoint.listKeys().primaryKey
}
}
module secondaryKeySecret '../security/key-vault-secret.bicep' = if (keyVaultConfig != null) {
name: keyVaultConfig!.secondaryKeySecretName
params: {
name: keyVaultConfig!.secondaryKeySecretName
keyVaultName: keyVaultConfig!.name
value: modelServerlessEndpoint.listKeys().secondaryKey
}
}
@description('The deployed AI model serverless endpoint resource.')
output resource resource = modelServerlessEndpoint
@description('ID for the deployed AI model serverless endpoint resource.')
output id string = modelServerlessEndpoint.id
@description('Name for the deployed AI model serverless endpoint resource.')
output name string = modelServerlessEndpoint.name
@description('Inference endpoint for the deployed AI model serverless endpoint resource.')
output endpoint string = modelServerlessEndpoint.properties.inferenceEndpoint.uri
@description('Primary key secret name for the deployed AI model serverless endpoint resource.')
output primaryKeySecretName string = keyVaultConfig != null ? keyVaultConfig!.primaryKeySecretName : ''
@description('Secondary key secret name for the deployed AI model serverless endpoint resource.')
output secondaryKeySecretName string = keyVaultConfig != null ? keyVaultConfig!.secondaryKeySecretName : ''