In this article of AZ-203 certification series, let’s have a look at what is Azure App service. We will see how to create the App service web app and how to deploy your web application created in visual studio on Azure.
For following some of the steps in this article, you will need an Azure account. If you do not have an Azure account, you can create free account on Azure.
World without Azure App service !
Imagine you are building a web application which you are planning to deploy on your own servers. You will have to make sure that you design, develop, test and deploy the web application. Before you deploy, you will also have to decide few things like:
- hardware configurations would be required to deploy your web app
- server-level operating system
- how many servers would be required
- probably, a load balancing solution if you need more than 1 web server
The list can have many other items. The infrastructure teams take care of these items and they design how the infrastructure should be.
Designing the infrastructure can be challenging if you do not already know how many users are you expecting on your site. If the user load is going to increase over the time, the design may also need changes, meaning additional buying of hardware resulting into more cost.
So, What is Azure App service ?
Azure app service is PaaS (Platform-as-a-Service) offering from Azure. It allows you to focus on designing and building your applications, while Azure takes care of the infrastructure.
You can deploy to Azure app services using a visual studio, or FTP deployments or you can automate the deployment as a part of CI/CD pipeline. You can also schedule automated deployments from GitHub or Bit-bucket repositories.
Before we proceed further, let’s understand the concept of App service plans.
An App Service Plan is a set of virtual server resources that run your App Service App. So it decides how much RAM would be allotted, which features would be available, etc.
App service plan is also unit of billing. So the cost of running your App service app is calculated based on the App service plan you selected.
In theory, an App service plan can host unlimited applications. But in practice, the number of applications that can run on single app service will be dependent on the performance characteristics of your application and the resources available in the app service plan.
Let’s go to Azure portal and create a simple App service.
Create Azure App Service Web App
When you are ready to deploy your web application on Azure, you can visit Azure Portal.
Once you sign in, select App Services from the left side navigation menu. Then click on add new App Service.
Then you will be prompted to enter below inputs:
- Subscription: A valid and active Azure subscription
- Resource Group: A valid resource group name. You can either provide existing resource group name or you can create a new resource group. Please note that resource group is just to logically organize your Azure resources.
- App Name: A unique name for your web application. This is part of URL and hence needs to be unique among all the Azure app service web apps.
- Publish: You can either select “Code” option if you are directly deploying code. You also have “Docker Image”as an option. If you select Docker Image as an option, you have to provide the docker registry from where the docker image should be retrieved.
- Runtime Stack: If you select “code”in publish options, you need to provide this input. The input lets App service know which runtime is being used by your application (e.g. NodeJS, Python, Java, .NET, etc)
- Operating System: You can select either Linux or Windows. Please note that some runtime stacks may not need this input. If you select Docker Image as the publish option, then you need to select operating system on which the docker image can run.
- Region: An Azure geographical region from where the application would be served.
- App Service Plan: There are various options available. This decides the infrastructure resource that would be available for your application. This also decides the billing rate. You can also scale up/down the App service plan whenever you feel the need to do so (thereby optimizing the costs).
Then click on Reivew + Create button and it will start creating the app service for you. This may take some time. You will get to see a notification on top right corner when deployment is successful.
Publish Web App using Visual Studio
Open your web application in Visual Studio. Then right click on Solution and Select Publish. It would show below dialog:
You can also create new App Service from here. We will select existing App service option as we already have created App Service from Azure portal.
If you click on Advanced, you can select Framework, Type of Deployment (Self contained vs Framework dependent) and other details. For this demo, let them be default.
When you click on “Create profile” button, Visual studio shows another dialog, where you can select your subscription and existing App service.
When you click on OK on above dialog, you are shown all your publish configurations in Visual Studio. You just need to click on Publish button on this screen. Please note that we are ignoring a deployment warning because the demo is not using SignalR dependency.
Once publish is done, Visual studio will open the application URL in default browser.
I hope this article has provided enough information on what is App Service, what are app service plans and how to deploy your web application to app service using Visual Studio. Please do comment and let me know your thoughts.