You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-studio/how-to/deploy-models-serverless.md
+135-3Lines changed: 135 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,6 +81,17 @@ This article uses a Meta Llama model deployment for illustration. However, you c
81
81
)
82
82
```
83
83
84
+
# [Bicep](#tab/bicep)
85
+
86
+
Install the Azure CLI as described at [Azure CLI](/cli/azure/).
87
+
88
+
Configure the following environment variables according to your settings:
89
+
90
+
```azurecli
91
+
RESOURCE_GROUP="serverless-models-dev"
92
+
LOCATION="eastus2"
93
+
```
94
+
84
95
# [ARM](#tab/arm)
85
96
86
97
You can use any compatible web browser to [deploy ARM templates](../../azure-resource-manager/templates/deploy-portal.md) in the Microsoft Azure portal or use any of the deployment tools. This tutorial uses the [Azure CLI](/cli/azure/).
@@ -110,6 +121,9 @@ The next section covers the steps for subscribing your project to a model offeri
110
121
111
122
Serverless API endpoints can deploy both Microsoft and non-Microsoft offered models. For Microsoft models (such as Phi-3 models), you don't need to create an Azure Marketplace subscription and you can [deploy them to serverless API endpoints directly](#deploy-the-model-to-a-serverless-api-endpoint) to consume their predictions. For non-Microsoft models, you need to create the subscription first. If it's your first time deploying the model in the project, you have to subscribe your project for the particular model offering from the Azure Marketplace. Each project has its own subscription to the particular Azure Marketplace offering of the model, which allows you to control and monitor spending.
112
123
124
+
> [!TIP]
125
+
> Skip this step if you are deploying models from the Phi-3 family of models. Directly [deploy the model to a serverless API endpoint](#deploy-the-model-to-a-serverless-api-endpoint).
126
+
113
127
> [!NOTE]
114
128
> Models offered through the Azure Marketplace are available for deployment to serverless API endpoints in specific regions. Check [Model and region availability for Serverless API deployments](deploy-models-serverless-availability.md) to verify which models and regions are available. If the one you need is not listed, you can deploy to a workspace in a supported region and then [consume serverless API endpoints from a different workspace](deploy-models-serverless-connect.md).
115
129
@@ -164,11 +178,41 @@ Serverless API endpoints can deploy both Microsoft and non-Microsoft offered mod
164
178
).result()
165
179
```
166
180
181
+
# [Bicep](#tab/bicep)
182
+
183
+
Use the following bicep configuration to create a model subscription:
var modelName = substring(modelId, (lastIndexOf(modelId, '/') + 1))
192
+
var subscriptionName = '${modelName}-subscription'
193
+
194
+
resource projectName_subscription 'Microsoft.MachineLearningServices/workspaces/marketplaceSubscriptions@2024-04-01-preview' = if (!startsWith(
195
+
modelId,
196
+
'azureml://registries/azureml/'
197
+
)) {
198
+
name: '${projectName}/${subscriptionName}'
199
+
properties: {
200
+
modelId: modelId
201
+
}
202
+
}
203
+
```
204
+
205
+
Then create the resource as follows:
206
+
207
+
```azurecli
208
+
az deployment group create --resource-group $RESOURCE_GROUP --template-file model-subscription.bicep
209
+
```
210
+
167
211
# [ARM](#tab/arm)
168
212
169
213
Use the following template to create a model subscription:
170
214
171
-
__template.json__
215
+
__model-subscription.json__
172
216
173
217
```json
174
218
{
@@ -202,6 +246,12 @@ Serverless API endpoints can deploy both Microsoft and non-Microsoft offered mod
202
246
}
203
247
```
204
248
249
+
Use the Azure portal or the Azure CLI to create the deployment.
250
+
251
+
```azurecli
252
+
az deployment group create --resource-group $RESOURCE_GROUP --template-file model-subscription.json
253
+
```
254
+
205
255
1. Once you subscribe the project for the particular Azure Marketplace offering, subsequent deployments of the same offering in the same project don't require subscribing again.
206
256
207
257
1. At any point, you can see the model offers to which your project is currently subscribed:
@@ -233,6 +283,15 @@ Serverless API endpoints can deploy both Microsoft and non-Microsoft offered mod
233
283
print(sub.as_dict())
234
284
```
235
285
286
+
# [Bicep](#tab/bicep)
287
+
288
+
You can use the resource management tools to query the resources. The following code uses Azure CLI:
289
+
290
+
```azurecli
291
+
az resource list \
292
+
--query "[?type=='Microsoft.SaaS']"
293
+
```
294
+
236
295
# [ARM](#tab/arm)
237
296
238
297
You can use the resource management tools to query the resources. The following code uses Azure CLI:
@@ -298,6 +357,46 @@ In this section, you create an endpoint with the name **meta-llama3-8b-qwerty**.
You can use the resource management tools to query the resources. The following code uses Azure CLI:
@@ -424,6 +531,10 @@ In this section, you create an endpoint with the name **meta-llama3-8b-qwerty**.
424
531
print(endpoint_keys.secondary_key)
425
532
```
426
533
534
+
# [Bicep](#tab/bicep)
535
+
536
+
Use REST APIs to query this information.
537
+
427
538
# [ARM](#tab/arm)
428
539
429
540
Use REST APIs to query this information.
@@ -441,6 +552,18 @@ Models deployed in Azure Machine Learning and Azure AI studio in Serverless API
441
552
442
553
Read more about the [capabilities of this API](../reference/reference-model-inference-api.md#capabilities) and how [you can use it when building applications](../reference/reference-model-inference-api.md#getting-started).
443
554
555
+
## Network isolation
556
+
557
+
Endpoints for models deployed as Serverless APIs follow the public network access (PNA) flag setting of the AI Studio Hub that has the project in which the deployment exists. To secure your MaaS endpoint, disable the PNA flag on your AI Studio Hub. You can secure inbound communication from a client to your endpoint by using a private endpoint for the hub.
558
+
559
+
To set the PNA flag for the Azure AI hub:
560
+
561
+
1. Go to the [Azure portal](https://portal.azure.com).
562
+
2. Search for the Resource group to which the hub belongs, and select your Azure AI hub from the resources listed for this Resource group.
563
+
3. On the hub Overview page, use the left navigation pane to go to Settings > Networking.
564
+
4. Under the **Public access** tab, you can configure settings for the public network access flag.
565
+
5. Save your changes. Your changes might take up to five minutes to propagate.
566
+
444
567
## Delete endpoints and subscriptions
445
568
446
569
You can delete model subscriptions and endpoints. Deleting a model subscription makes any associated endpoint become *Unhealthy* and unusable.
@@ -500,6 +623,15 @@ To delete the associated model subscription:
0 commit comments