Lab 4.2 - Deploy to ACI using the Azure Portal

In this lab we are going to quickly deploy a model to an ACI to test it. You can do this in 2 ways. Using the Azure Portal or the Python SDK.

Step 1 - Locate the model

Open the Azure Machine Learning Studio(https://ml.azure.com). Select the newly created model with the name SimpsonsClassification-pytorch.

Sometimes your workspace does not show in ml.azure.com. If that happens go to the Azure Portal (portal.azure.com), search for your Machine Learning Workspace and click launch studio.

Click on Deploy and choose for Deploy to web services

Step 2 - Configure the deployment

Configure endpoint by giving it a name. Choose Azure Container Instance as Compute Type Download following 2 files

And configure them accordingly as entry script & conda dependency file

Finish up by clicking Deploy

Step 3 - Deploying ..

Check if deployment is finished by clicking on Endpoints in the left menu.

Click on the endpoint name you just created in this case workshop-endpoint

This will lead you the details. Please notice that your endpoint is in the deployment state Transitioning. This might take a couple of minutes before it changes to Healthy. You need to refresh the page to see the change coming through.

Step 4 - Test the endpoint

When the deployment state is set to Healthy it is time to test the endpoint

Notice that on the Details page you will find the REST Endpoint, it looks like this

  • http://abc1230-abc1230-abc1230-abc1230.westeurope.azurecontainer.io/score

Copy this endpoint url.

Now go back to Visual Code and in your terminal execute following:

code test.http

Paste following code in the file and replace the endpoint url with the one from your environment.

This POST request has as body a link to an image of Bart Simpsons, as a lego figure.

POST http://abc1230-abc1230-abc1230-abc1230.westeurope.azurecontainer.io/score

{
    "image":"https://raw.githubusercontent.com/hnky/dataset-lego-figures/master/_test/Bart.jpg"
}

Because of the Rest Client extension in Visual Studio Code you will see a small button Send Request. By clicking on the this you will execute the endpoint and send a picture of Bart Simpson to the endpoint.

This will return you following results

Don't hesitate to try it out with other pictures you find on the internet.

Conclusion

In this lab we learned how we can deploy a trained model to a container instance on Azure so it is available as a REST Endpoint that can be used in any kind of application.

Last updated