Introduction to Azure App Service
If you are a developer, you would have come across this thought multiple times in the past – “How do I create a web app with ease and not bother about the virtual machine I am using”. If you had this thought and still not found the perfect solution to this, you are at the right place today because we have an answer for you - Azure App Service.
In this era of several technological advancements, apps are a common sight and are also the easiest way to access a brand’s services. Azure App Service provides the most user-friendly way of creating web apps and make the brand’s services available for all users.
In this post, we are going to understand in detail what is Azure App Service and also about Azure Service Fabric which is the key to creating web apps effortlessly. We will also take a glimpse into how to deploy a Flask application on Azure App Service.
What is Azure App Service?
Azure App Service is a “Platform as a Service” (PaaS) that is entirely managed by Microsoft. It coalesces Microsoft Azure websites, Mobile services, and Biz Talk services into a single unit. Azure App Service carries is built with several features such as advanced security, automatic scaling, load balancing, and automated management. Following benefits are offered to the user by Azure App Service:
- It is a quick and easy way to create web applications and mobile applications.
- It helps you to create visually appealing IOS, Windows, and Android applications.
- It effortlessly combines with “Software as a Service” (SaaS) applications such as Office 365, Salesforce, Dynamics, OneDrive, Box, Dropbox, Twilio, Twitter, Facebook, Marketo, and so on.
Since Azure App Service combines multiple functionalities and features in a single platform, it reduces the total cost for organizations as a single package with all these features will cost lower than paying for each service or feature individually. This gives them a huge advantage on monetary grounds.
What is Azure Service Fabric?
In the world of Infrastructure as a Service (IaaS), whenever we build a new web server, we first create a virtual machine, then we log in to it and configure IIS (Internet Information Services) on Windows Server or Nginx on LINUX. Our job is not over after this. Building a web server comes with several additional tasks for developers like managing the virtual machine, making it available, patching it, and above all, updating it to keep the web server relevant.
Now let us analyze this in the world of Platform as a Service (PaaS). Here, we can utilize our time in building the web app instead of focusing on performing the additional tasks that come with creating a web server. All these tasks that we had to carry out in the Infrastructure as a Service (IaaS) world are taken care by an abstraction called Azure Service Fabric. Thus, Azure Service Fabric is the backbone of the Azure App Service and helps you to create web applications effortlessly.
How does Azure Service Fabric work?
The Azure Service Fabric displays all the features of Azure Virtual Machines as simple services to Azure developers. Let us understand the functions of Azure Service Fabric with the help of the following examples:
- Say you want to build a web server. Instead of building one, you take the help of Azure Service Fabric that uses the Virtual Machine to make that web server accessible to us. A portal experience like Azure CLI, Visual Studio, etc. is used to supervise the browser.
- When we access a website that is run by a Web App, Azure Service Fabric automatically runs it on a virtual machine in a Microsoft data center. For some reason, if the virtual machine or the hardware fails to maintain the continuity of running the website, it automatically moves the Web App to a different virtual machine or a different server.
- If we scale a Web App multiple times, Azure Service Fabric runs each scaled Web App on different virtual machines and still maintains the continuity of running the Web App.
It is clear from all these examples that Azure Service Fabric makes Azure App Service highly user friendly.
Now if you are developing a web app in Python, there are high chances that you might be using a framework like Flask. A framework is nothing but a code library helping developers to build reliable and scalable web applications. In the next section, we are going to see how to deploy a Flask application using Azure App Service.
How to deploy a flask application on Azure App Service?
To deploy your Flask application, access the docker file that has all the requirements needed to deploy a Flask app on Azure. If it’s a Python file, it can also be deployed on Django. There are various other frameworks based on the language used to build the app. Dependencies which need to be installed before deploying the Flask app on Azure are:
- URL in which service app is to be hosted
- pip
- Gunicorn
- subprocess32
- virtualenv
- flask
After installing the dependencies mentioned in the file, the control is passed on to the entrypoint.py file to deploy whatever functionalities you intend.
Docker file showing requirements
The entrypoint.py code snippet is mentioned in the snippets below.
Firstly, the subprocess and OS are imported followed by mentioning the directories where the file is to be searched. The function subprocess() is built for communication with the app on the server while the check_flask() function validates whether the python file to be deployed is present or not.
Code snippet to check availability of python app and set environment
After the app is found on the system and the environment is set, we start the server using the code snippet mentioned below.
Code snippet to start the server on Azure
Summary
Azure App Service is used to make the creation of a Web App an effortless task. It supervises all the running Web Apps using Azure Service Fabric. Azure App Service also brings with itself several advantages like a high level of security, adaptable structure, high global availability, scalability, application templates, visual studio integration, and many more. So go ahead and use the features provided by the Azure App Service for creating your next Web App, Mobile App, API App, and Logic App in a single platform.