Deploy machine learning models to the Azure Cloud as a webApp

TechNews Writer
Pronouns
(He/Him)
Mon Nov 30, 2020

Today, due to technological development and advancement there exists so many ways to deploy machine learning models to the Clouds like AWS, GCP, and Azure. Let's discuss how to deploy machine learning models to the Microsoft Azure Cloud as a WebApp.

Step 1: Create a Flask Application

This step involves creating a flask application by designing user interactive HTML pages which can be utilized to get the input from the user and to display the output to the user. Also, in the backend, we will give a call to machine learning models that will take the input provided by the user and predict the expected results.

Step 2: Create requirement.txt file

After developing the flask application, we will create the virtual environment and try to generate the requirement.txt file which will contain all the packages along with their versions.

Step 3: Push the code to Azure Repos using DevOps in their root directory

Once we have the flask application along with the requirement.txt file we will push the code to the Azure Repos in their root directory which will later be utilized for deployment.

Step 4: Create Pipelines in Azure DevOps

In this step, we will create the new pipeline by using the code present in the root directory of the specified branch. While creating the pipeline we will have to select the python version, we can go for unit testing in case we have multiple models (testing is optional). After that, it will execute the requirement.txt file in the virtual machine to check the compatibility of all the required packages with the current environment and throws the errors. So that the incompatibility can be resolved before the actual deployment.

Step 5: Create WebApp in the Azure portal

In this step, we will first login to the Azure portal and create a WebApp using our Resource Group and Azure subscription.

Step 6: Release the pipeline

Once the pipeline is created then we will create a new release in the release option. In this step first, it will create Artifacts. Artifacts are nothing but the zip folder of the whole code which is present in the Azure Repos in the specified branch and then it will ask us to select the WebApp which we have already created in the Azure portal. Once that is done it will release the whole code to the Azure portal.

Step 7: Run the WebApp

Now go to the Azure portal and check the deployment center of the created WebApp. We will find a message saying that the deployment is done. Once we see that message, we will click on the overview option and run the App. After running the App, we will browse the website to see the executable model.

 

 

Appears in
2020 - Fall - Issue 11
Tags
Channel