Deploy a Flask app in Azure web app through Visual Studio code
This post will walk you through steps for creating and deploying a Flask web app in the Azure app services.
Step 1: Create a basic app in the flask
First, let us create a minimal flask app for illustrating the steps for publishing an app in the Azure app services.
Create a python file app.py with the below code.
Create the requirements.txt file and add the libraries needed for the project.
You can find the sample project for the same in the Github link.
Step 2: Sign-in into azure in Visual studio code.
Before we proceed with this step, I assumed that you have an Azure account and subscriptions linked to that account. You can access your Azure resources through the Azure portal.
To access Azure services from visual studio code, go to extension at the sidebar and search for Azure App Service and click install. It will add all the required dependencies to the visual studio code.
Once added, you will see APP Services in the side menu bar in visual studio code, as shown in the below figure.
Now sign in to Azure using your Microsoft account. Once signed in, you will see the list of subscriptions you have under your account.
Step 3: Creating an azure app
Click on the subscriptions where it will prompt for creating a new web app.
You can start providing the details like web app name, resource group, pricing tier, python version, etc., needed for creating an app.
Once all the relevant details are provided, an azure web app will be created below your subscription.
Step 4: Deploying into Azure web app.
To deploy this app, you can select Deploy to the web app. This will prompt you to select the folder that contains your flask project which you want to deploy.
Once selected, the deployment process starts. After the deployment completes, you can view the web page by selecting the Browse website option in the Azure app you have deployed.
I hope this gives you an overview of deploying app from visual studio code.