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
@@ -35,6 +35,7 @@ For more information on features provided by Azure App Service, see the [App Ser
35
35
## Prerequisites
36
36
37
37
* An Azure Machine Learning service workspace. For more information, see the [Create a workspace](how-to-manage-workspace.md) article.
38
+
* The [Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest).
38
39
* A trained machine learning model registered in your workspace. If you do not have a model, use the [Image classification tutorial: train model](tutorial-train-models-with-aml.md) to train and register one.
39
40
40
41
> [!IMPORTANT]
@@ -94,34 +95,146 @@ For more information on inference configuration, see [Deploy models with the Azu
94
95
95
96
To create the Docker image that is deployed to Azure App Service, use [Model.package](https://docs.microsoft.com//python/api/azureml-core/azureml.core.model.model?view=azure-ml-py#package-workspace--models--inference-config--generate-dockerfile-false-). The following code snippet demonstrates how to build a new image from the model and inference configuration:
96
97
98
+
> [!NOTE]
99
+
> The code snippet assumes that `model` contains a registered model, and that `inference_config` contains the configuration for the inference environment. For more information, see [Deploy models with the Azure Machine Learning service](how-to-deploy-and-where.md).
When `show_output=True`, the output of the Docker build process is shown. Once the process finishes, the image has been created in the Azure Container Registry for your workspace.
110
+
When `show_output=True`, the output of the Docker build process is shown. Once the process finishes, the image has been created in the Azure Container Registry for your workspace. Once the image has been built, the location in your Azure Container Registry is displayed. The location returned isin the format`<acrinstance>.azurecr.io/package:<imagename>`. For example, `myml08024f78fd10.azurecr.io/package:20190827151241`.
111
+
112
+
> [!IMPORTANT]
113
+
> Save the location information, as it is used when deploying the image.
103
114
104
115
## Deploy image as a web app
105
116
106
-
1. From the [Azure portal](https://portal.azure.com), select your Azure Machine Learning workspace. From the __Overview__ section, use the __Registry__ link to access the Azure Container Registry for the workspace.
117
+
1. Use the following command to get the login credentials forthe Azure Container Registry that contains the image. Replace `<acrinstance>`with th e value returned previously from`package.location`:
107
118
108
-
[](media/how-to-deploy-app-service/workspace-overview-expanded.png)
119
+
```azurecli-interactive
120
+
az acr credential show --name <myacr>
121
+
```
109
122
110
-
2. From the Azure Container Registry, select __Repositories__, and then select the __image name__ that you want to deploy. For the version that you want to deploy, select the __...__ entry, and then __Deploy to web app__.
123
+
The output of this command is similar to the following JSON document:
111
124
112
-
[](media/how-to-deploy-app-service/deploy-to-web-app-expanded.png)
125
+
```json
126
+
{
127
+
"passwords": [
128
+
{
129
+
"name": "password",
130
+
"value": "Iv0lRZQ9762LUJrFiffo3P4sWgk4q+nW"
131
+
},
132
+
{
133
+
"name": "password2",
134
+
"value": "=pKCxHatX96jeoYBWZLsPR6opszr==mg"
135
+
}
136
+
],
137
+
"username": "myml08024f78fd10"
138
+
}
139
+
```
113
140
114
-
3. To create the Web App, provide a site name, subscription, resource group, andselect the App service plan/location. Finally, select __Create__.
141
+
Save the value for __username__ andone of the __passwords__.
115
142
116
-

143
+
1. If you do not already have a resource group orapp service plan to deploy the service, the following commands demonstrate how to create both:
117
144
118
-
## Use the Web App
145
+
```azurecli-interactive
146
+
az group create --name myresourcegroup --location "West Europe"
147
+
az appservice plan create --name myplanname --resource-group myresourcegroup --sku B1 --is-linux
148
+
```
119
149
120
-
From the [Azure portal](https://portal.azure.com), select the Web App created in the previous step. From the __Overview__ section, copy the __URL__. This value isthe __base URL__ of the service.
150
+
In this example, a __Basic__ pricing tier (`--sku B1`) isused.
121
151
122
-
[](media/how-to-deploy-app-service/web-app-overview-expanded.png)
152
+
> [!IMPORTANT]
153
+
> Images created by the Azure Machine Learning service use Linux, so you must use the `--is-linux` parameter.
154
+
155
+
1. To create the web app, use the following command. Replace `<app-name>`with the name you want to use. Replace `<acrinstance>`and`<imagename>`with the values from returned `package.location` earlier:
156
+
157
+
```azurecli-interactive
158
+
az webapp create --resource-group myresourcegroup --plan myplanname --name <app-name>--deployment-container-image-name <acrinstance>.azurecr.io/package:<imagename>
159
+
```
160
+
161
+
This command returns information similar to the following JSON document:
1. To provide the web app with the credentials needed to access the container registry, use the following command. Replace `<app-name>`with the name you want to use. Replace `<acrinstance>`and`<imagename>`with the values from returned `package.location` earlier. Replace `<username>`and`<password>`with the ACR login information retrieved earlier:
At this point, the web app begins loading the image.
123
219
124
-
The web service that passes requests to the model is located at `{baseurl}/score`. For example, `https://mywebapp.azurewebsites.net/score`. The following Python code demonstrates how to submit data to the URLand display the response:
220
+
> [!IMPORTANT]
221
+
> It may take several minutes before the image has loaded. To monitor progress, use the following command:
222
+
>
223
+
>```azurecli-interactive
224
+
> az webapp log tail --name <app-name>--resource-group myresourcegroup
225
+
>```
226
+
227
+
Once the image is deployed, you can find the hostname by using the following command:
228
+
229
+
```azurecli-interactive
230
+
az webapp show --name <app-name>--resource-group myresourcegroup
231
+
```
232
+
233
+
This command returns information similar to the following hostname -`<app-name>.azurewebsites.net`. Use this value as part of the __base url__ for the service.
234
+
235
+
## Use the Web App
236
+
237
+
The web service that passes requests to the model is located at `{baseurl}/score`. For example, `https://<app-name>.azurewebsites.net/score`. The following Python code demonstrates how to submit data to the URLand display the response:
0 commit comments