Skip to content

Commit 3ace3aa

Browse files
authored
Update deploy-models-serverless.md
1 parent 041bb2b commit 3ace3aa

File tree

1 file changed

+135
-3
lines changed

1 file changed

+135
-3
lines changed

articles/ai-studio/how-to/deploy-models-serverless.md

Lines changed: 135 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ In this article, you learn how to deploy a model from the model catalog as a ser
7979
)
8080
```
8181
82+
# [Bicep](#tab/bicep)
83+
84+
Install the Azure CLI as described at [Azure CLI](/cli/azure/).
85+
86+
Configure the following environment variables according to your settings:
87+
88+
```azurecli
89+
RESOURCE_GROUP="serverless-models-dev"
90+
LOCATION="eastus2"
91+
```
92+
8293
# [ARM](#tab/arm)
8394
8495
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/).
@@ -108,6 +119,9 @@ The next section covers the steps for subscribing your project to a model offeri
108119
109120
For non-Microsoft models offered through the Azure Marketplace, you can deploy them to serverless API endpoints to consume their predictions. 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.
110121
122+
> [!TIP]
123+
> 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).
124+
111125
> [!NOTE]
112126
> 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).
113127
@@ -158,11 +172,41 @@ For non-Microsoft models offered through the Azure Marketplace, you can deploy t
158172
).result()
159173
```
160174
175+
# [Bicep](#tab/bicep)
176+
177+
Use the following bicep configuration to create a model subscription:
178+
179+
__model-subscription.bicep__
180+
181+
```bicep
182+
param projectName string = 'my-project'
183+
param modelId string = 'azureml://registries/azureml-meta/models/Meta-Llama-3-8B-Instruct'
184+
185+
var modelName = substring(modelId, (lastIndexOf(modelId, '/') + 1))
186+
var subscriptionName = '${modelName}-subscription'
187+
188+
resource projectName_subscription 'Microsoft.MachineLearningServices/workspaces/marketplaceSubscriptions@2024-04-01-preview' = if (!startsWith(
189+
modelId,
190+
'azureml://registries/azureml/'
191+
)) {
192+
name: '${projectName}/${subscriptionName}'
193+
properties: {
194+
modelId: modelId
195+
}
196+
}
197+
```
198+
199+
Then create the resource as follows:
200+
201+
```azurecli
202+
az deployment group create --resource-group $RESOURCE_GROUP --template-file model-subscription.bicep
203+
```
204+
161205
# [ARM](#tab/arm)
162206
163207
Use the following template to create a model subscription:
164208
165-
__template.json__
209+
__model-subscription.json__
166210
167211
```json
168212
{
@@ -196,6 +240,12 @@ For non-Microsoft models offered through the Azure Marketplace, you can deploy t
196240
}
197241
```
198242
243+
Use the Azure portal or the Azure CLI to create the deployment.
244+
245+
```azurecli
246+
az deployment group create --resource-group $RESOURCE_GROUP --template-file model-subscription.json
247+
```
248+
199249
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.
200250
201251
1. At any point, you can see the model offers to which your project is currently subscribed:
@@ -227,6 +277,15 @@ For non-Microsoft models offered through the Azure Marketplace, you can deploy t
227277
print(sub.as_dict())
228278
```
229279
280+
# [Bicep](#tab/bicep)
281+
282+
You can use the resource management tools to query the resources. The following code uses Azure CLI:
283+
284+
```azurecli
285+
az resource list \
286+
--query "[?type=='Microsoft.SaaS']"
287+
```
288+
230289
# [ARM](#tab/arm)
231290
232291
You can use the resource management tools to query the resources. The following code uses Azure CLI:
@@ -292,6 +351,46 @@ In this section, you create an endpoint with the name **meta-llama3-8b-qwerty**.
292351
).result()
293352
```
294353
354+
# [Bicep](#tab/bicep)
355+
356+
Use the following template to create an endpoint:
357+
358+
__serverless-endpoint.bicep__
359+
360+
```bicep
361+
param projectName string = 'my-project'
362+
param endpointName string = 'myserverless-text-1234ss'
363+
param location string = resourceGroup().location
364+
param modelId string = 'azureml://registries/azureml-meta/models/Meta-Llama-3-8B-Instruct'
365+
366+
var modelName = substring(modelId, (lastIndexOf(modelId, '/') + 1))
367+
var subscriptionName = '${modelName}-subscription'
368+
369+
resource projectName_endpoint 'Microsoft.MachineLearningServices/workspaces/serverlessEndpoints@2024-04-01-preview' = {
370+
name: '${projectName}/${endpointName}'
371+
location: location
372+
sku: {
373+
name: 'Consumption'
374+
}
375+
properties: {
376+
modelSettings: {
377+
modelId: modelId
378+
}
379+
}
380+
dependsOn: [
381+
projectName_subscription
382+
]
383+
}
384+
385+
output endpointUri string = projectName_endpoint.properties.inferenceEndpoint.uri
386+
```
387+
388+
Create the deployment as follows:
389+
390+
```azurecli
391+
az deployment group create --resource-group $RESOURCE_GROUP --template-file model-subscription.bicep
392+
```
393+
295394
# [ARM](#tab/arm)
296395
297396
Use the following template to create an endpoint:
@@ -344,8 +443,7 @@ In this section, you create an endpoint with the name **meta-llama3-8b-qwerty**.
344443
345444
```azurecli
346445
az deployment group create \
347-
--name model-subscription-deployment \
348-
--resource-group <resource-group> \
446+
--resource-group $RESOURCE_GROUP \
349447
--template-file template.json
350448
```
351449
@@ -386,6 +484,15 @@ In this section, you create an endpoint with the name **meta-llama3-8b-qwerty**.
386484
).result()
387485
```
388486
487+
# [Bicep](#tab/bicep)
488+
489+
You can use the resource management tools to query the resources. The following code uses Azure CLI:
490+
491+
```azurecli
492+
az resource list \
493+
--query "[?type=='Microsoft.MachineLearningServices/workspaces/serverlessEndpoints']"
494+
```
495+
389496
# [ARM](#tab/arm)
390497
391498
You can use the resource management tools to query the resources. The following code uses Azure CLI:
@@ -418,6 +525,10 @@ In this section, you create an endpoint with the name **meta-llama3-8b-qwerty**.
418525
print(endpoint_keys.secondary_key)
419526
```
420527
528+
# [Bicep](#tab/bicep)
529+
530+
Use REST APIs to query this information.
531+
421532
# [ARM](#tab/arm)
422533
423534
Use REST APIs to query this information.
@@ -435,6 +546,18 @@ Models deployed in Azure Machine Learning and Azure AI studio in Serverless API
435546
436547
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).
437548
549+
## Network isolation
550+
551+
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.
552+
553+
To set the PNA flag for the Azure AI hub:
554+
555+
1. Go to the [Azure portal](https://portal.azure.com).
556+
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.
557+
3. On the hub Overview page, use the left navigation pane to go to Settings > Networking.
558+
4. Under the **Public access** tab, you can configure settings for the public network access flag.
559+
5. Save your changes. Your changes might take up to five minutes to propagate.
560+
438561
## Delete endpoints and subscriptions
439562
440563
You can delete model subscriptions and endpoints. Deleting a model subscription makes any associated endpoint become *Unhealthy* and unusable.
@@ -494,6 +617,15 @@ To delete the associated model subscription:
494617
client.marketplace_subscriptions.begin_delete(subscription_name).wait()
495618
```
496619

620+
# [Bicep](#tab/bicep)
621+
622+
You can use the resource management tools to manage the resources. The following code uses Azure CLI:
623+
624+
```azurecli
625+
az resource delete --name <resource-name>
626+
```
627+
628+
497629
# [ARM](#tab/arm)
498630

499631
You can use the resource management tools to manage the resources. The following code uses Azure CLI:

0 commit comments

Comments
 (0)