Building Web Applications And APIs In Azure

If you are new to Microsoft Azure, I will recommend to first go through my article on Deep Dive Into Microsoft Azure.

In this article, we will look at building web applications and APIs with Microsoft Azure. We will see how we can use Azure as a platform for our applications, and we will see the different options for creating and deploying an application.

Let’s see three different scenarios for building and hosting an application.

The below image shows a clear distinction between On-Premise, IaaS (Infrastructure as a Service), and PaaS (Platform as a Service) models along with the information of what we are responsible for and what Azure is responsible for in each model.

Microsoft Azure

In On-premises solution, we have to purchase the physical servers and then host the application there. In this scenario, we are responsible for not only building the application, but also for acquiring, installing, and configuring the servers, operating system etc.

The second scenario i.e. IaaS could be achieved using Azure. With IaaS also, we are responsible for building our applications, and we need to configure the operating system. However, the hardware is taken care of by Azure.

The third scenario i.e. PaaS allows us not to think about the hardware or operating system. We don’t need to configure the operating system and we don’t need to apply patches or clean up temporary files or setup software backups. All of this is taken care of by Azure only. We have to just focus on building the application.

In this article, I am going to show the App Service platform.

Microsoft Azure App Services is the main thing if we want to build an application or API that runs on a platform in the cloud. Mentioned below are the various tasks that we can perform with Azure App Services -

  1. We can write traditional Web Applications and server HTML to a browser. 
  2. We can write the application in ASP.NET or Node.js or PHP etc.
  3. We can build an API Application and can server data over the internet.
  4. We can build Logic Applications, which integrated with other backend systems and implement a business workflow, or an application, which needs to collect data from external sites like Twitter etc.
  5. We can build Mobile Applications

    Microsoft Azure

Now, we will see how to build a web application up and running in App Services.

For creating App Services, go to Azure Portal and click on App Services on left-hand side and then click on Add. There are many templates available that Azure provides. (There are pre-configured App Services available, e.g. – WordPress blog).

Microsoft Azure

I selected the “ASP.NET Starter Web App”, as shown below and click on Create.

Microsoft Azure

Once you click on Create, a form will be displayed which will ask the information like App Name, Subscription, App Service Plan etc. The point to note here is that “App Name” needs to be unique because we are creating an app that will be hosted on azurewebsites.net and it might be possible that someone already has registered that name.

Microsoft Azure

NOTE

We can have multiple app services mapped to a single app service plan and a single plan can run the application on multiple instances. You can also click on “Create New” for creating a new service plan, if you do not want to use the default service plan.

Microsoft Azure

Click on Create, and after few seconds, you will see a message that Deployment is successful.

Microsoft Azure

Therefore, if you go to App Services, you will see the App Service created.

Microsoft Azure

Click on the App Service created and click on Overview. You will see the URL of your web application created and once clicked on the URL, you will see the ASP.NET application created which is running ASP.NET pages.

Microsoft Azure

Microsoft Azure

NOTE

You can download the web pages and can open the project in Visual Studio and start to edit the website.

Now we will create an ASP.NET Web Application (MVC) project in Visual Studio 2015

Microsoft Azure

Microsoft Azure

Once the project is created in Visual Studio, you will see the below scree. Press F5, which will build the application and run the application locally.

Microsoft Azure

Microsoft Azure

If you want to publish this web application, just right click on your project and click on Publish. There you can select the App Service created in Azure or you can create a new App Service in Visual Studio.

There is a very good tool for the developers in Visual Studio called “Cloud Explorer” available in “View” Menu. If it is not available in View, then go to Tools->Extensions and Updates and search for Cloud Explorer.

Microsoft Azure

Check the URL for details about Cloud Explorer - https://docs.microsoft.com/en-us/azure/vs-azure-tools-resources-managing-with-cloud-explorer

By using this tool, you can get the Publish Profile file locally and can use that file while publishing your project in Visual Studio by using Import settings. You can also get the publish profile from Azure Portal by clicking on Get Profile data link available in App Service created. This will force Azure to generate a new password for deployment.

Microsoft Azure

A profile file will be downloaded locally and if you open that file, you will see that you can use either Web Deploy or FTP. In addition, it shows the deployment username and password in the unencrypted form.

Microsoft Azure

Microsoft Azure

Summary

In this article, we learned about app services, and how we can host different types of applications and APIs in Azure using an app service, and an app service plan.


Similar Articles