How to build a web application on Azure?

Microsoft Azure is one of the leading cloud platforms that enables us to build a scalable and highly performing web applications. In this article,  I will list the available options that allow you to quickly understand what you need in order to build your application and what services to use in each layer.

What do we need to build a web application?

Each web application needs some services in order to work propably. For example, a web server, a database server, queuing system etc..

In the past few years, I have found many people using Azure wrong or inefficiently. Some used virtual machines while they should have used Web Apps, others used a huge size of a virtual machine because they didn’t know they could scale their VM without losing the data. Accordingly, I will do my best to give you a summery of Azure services that you can utilize to build your next fantastic Web App.

Application Life-cycle Management

So, first things first. You need a place to store your use cases, test cases, source code, run unit tests and perform a continuous integration and deployment.

Although it may not be a part from Azure, but Team Services integrates seamlessly with Azure and many Azure Services like Web Apps, Mobile Apps, Azure Functions … support continuous integration with Azure.

Team Services help you to have a central repository for your source code, documents and requirement. It also supports Visual Studio Team Services and Git as a source control. It is free and supports unlimited number of projects with 5 free users.

Hosting

Now, you developed your web application, tested it and it is time to host it. Azure supports hosting for .Net, Java, PHP, NodeJS, and Python built applications.

In this phase you have more than one option:

  1. Virtual Machine: This is the very basic option and should not be used unless you have no other way, ex: migrating a legacy application that cannot work with a PAAS offering, in this case you simply have a virtual machine in the cloud and you can remotely connect to it, install the needed software and deploy your application. Note that this is the most expensive solution.
  2. Cloud Services: This is the same as Virtual Machine except that it offloads some of the work to be done by you such as setting up software and windows updates. It has 2 types, a web role which is setup to host a web application directly, and a worker role which enables you to host an executable application such as a windows service or a console app. The good part about cloud services is that you provide it with a package that has your code and it manages the deployment of the application. If the virtual machine hosting the app went down, Azure will automatically creates another virtual machine and deploy the code to it.
  3. App Service: This is the Platform as a Service or PAAS offering from Azure, all you have to worry about here is your code. It gives you a vitrual directory on cloud and all you have to do is to deploy your App to it either through web deploy, FTP or upload a package. It also offers continous integration and monitoring capabilities. This is the most flexible and cheapest option and you can autoscalre it according to the CPU usage, RAM usage and other factors. So basically, you can start small and scale as you need later. Azure App Service has Web Apps to host your application, Mobile App which is a backend as a service to your mobile apps, Logic Apps which gives you the option to build your businss logic and integration between different systems, and finally API Apps which is used to host your REST api web Apps.

Integration

If your application integrates with other systems, then you can use Azure Logic App, Azure Functions, BizTalk Service and Service Bus

Most services gives you a very nice visual designer that allows you to orchestrate your business logic and it offers out of the box seamless integration with many external systems such Office 365, Dynamic CRM or On-premise system through BizTalk Services

Data Storage

Azure offers many services to store your data, all of it are based on Azure Storage Account which is the main storage system for all services in Azure. Each account has some storage and throughput limitation, you can check these limitation from here

  1. If you need to store text files or video files, you can use Page and Block blobs. Each type is suitable for specific file types, you can read more about it from here
  2. Use Azure Media Services if you have to store and stream media files.
  3. Azure table storage is suitable if you need a NoSQL database, it provides a high throughput storing and retrieving entities that have no referential integrity between them.
  4. Azure DocumentDB is a NoSQL document database similar to MongoDB, it is a born in the cloud database that you can use if you need a low latency high performing database
  5. Azure SQL Database is a SQL Server database in the cloud where you need not to worry about SQL Server installation, Backup and Restore or anything else, you just create a database and use it.
  6. Azure File Share is used to replace any legacy File System Share in any legacy application.

 

Now, you should be able to have some basic knowledge about the features you can use to build your next web application.

What is Microsoft Azure?

During the Colleague, I remember people were talking about renting the schools’ servers during the summer as there was nothing to do with it while there is no study, so why not to make some money from those people who don’t want to purchase new hardware to get their application working quickly.

Later, there were those vendors who give you a free or paid site that you can upload your files and program to it and manage it through a control panel, some times it was provided with a database engine like MySQL, sometimes not.

Nowadays, it is all about Cloud, and before we talk about Azure, lets first see what is cloud:

What is Cloud?

According to searchcloudcomputing, cloud is

Cloud computing enables companies to consume compute resources as a utility — just like electricity — rather than having to build and maintain computing infrastructures in-house.

Think of it with a real life example, people can buy a car or a home, and pay hundreds of thousands and maybe millions to purchase their dream home, they will be responsible to maintain it and fix any issues that may happen to it.

Others may just rent the home and start quickly and save their selves a great deal of money and time, still they will have to maintain the home, clean it and fix or pay for any damages.

Some other people would simply rent a room inside a hotel and enjoy their  time, have a nice room service and a good breakfast, pay for only the nights they spent and if they didn’t like it, they can always move somewhere else.

The same Idea applies for software, You can either buy your own hardware and Software to build your own data center, or you can just consume it from somewhere else, this consumption model comes in 3 forms as explained below:

Infrastructure as a Service (IAAS)

In the OnPremise model, you can notice that you manage everything, starting from the server rooms, Hardware, electricity, A/C, Storage and everything including the persons who maintain and support it.

Imaging the time needed to purchase the hardware, preparation and OS installations, batching…, all of these activities can take months to start not to mention how much it will take to finish

In real life, this is a guy who pay a lot of money to a buy a new car, he will search for a new model, think about resale price, maintenance fees, running costs, and insurance cost.

Instead, you can just contact a cloud vendor, ask them to rent a 5 or 10 virtual machines and it can be ready in few ours for you to use in your application.

In this model, you only manage the OS updates and your application + Data, you don’t have to worry about the hardware, networking or Storage.

You will not install the OS, you will just install the software you need, ex: SQL Server, IIS, Domain Controllers …

In real life, This is a guy who went to a car agency, rent a car, pay the rent and take it for a ride, he still has to put pay for Gas, wash and some other few things, but not as much as if it was his.

Platform as a Service (PAAS)

If you see that managing the virtual machines will be time consuming and hard to do, then you can go for the PAAS model, where you will be managing only your application and data.

You will need to just deploy your application, think of it as if you have a remote connection to a virtual directory on IIS where you can upload your asp.net site, and a connection to a SQL server where you can run the database scripts, you don’t have to worry about the SQL Cluster or backup, windows updates or anything else, the vendor will manage all of that for you, you just need to take care of your application.

in real life, this is a guy who rented a car with a driver, he still pay but he is doing less work now and he can focus on his own stuff instead of driving himself

Software as a Service (SAAS)

The final model is when you are not developing an application and you don’t want to do anything extra, just use the software as is with minor customization, this model is used a lot nowadays, the most used example is email service, when we need an email account, we open Hotmail, yahoo or GMail and register for a new account and start to use instantly, everyone use it as if the software was designed for him and no one can see the data for others, we never cared about where the data is stored or who is running what, we just open our browser or use a mobile application to send and receive emails.

In real life, this is a guy who simply took a taxi or Uber :). 

If you compared the 4 models (including On Premise) and the 4 real life cases, you will find the difference is mainly about:

  1. Speed: the time to start and get the environment ready is much less when you move from OnPremise -> IAAS -> PAAS -> SAAS
  2. Cost: the cost is much less, you don’t have to pay a large amount of money in advance, you simply pay for what you use, if you didn’t like the service, you can switch to another, the other reason is: for OnPremise, you will have to purchase the needed hardware for the max number of users who will use the system even if the system will be idle most of the times, so if your application is used by 10 user most of the time but in some days it is being used by 1000, you will have to purchase a hardware that support the 1000 users, but with Cloud, you can simply get resources for the 10 users and scale for more when needed.
  3. Scalability: Most cloud vendors have automatic scalabiity depending on CPU usage, Memory consumption or any other metric, so you can set your application to add an extra virtual machine if the CPU usage exceeded 80% for more than 30 minutes and remove it if it drops under 50% for 30 minutes.
  4. Manageability:  As you can see from the image, when you move to the right, the stuff you manage is less, this gives you the opportunity to put your focus on the applications you build.

What is Azure?

Microsoft Azure which is also known as Windows Azure is Microsoft Cloud Platform, it offers a great deal of features and it is growing unbelievably fast, every week or maybe every day they add more and more features and more hardware resources, when I started learning Azure, they only had 6 data centers, today they have 19 data centers, and by a data center we are talking about a place that is larger than a football field that has millions of servers read for you to use.

What is in it for me?

Azure support all the 3 types (IAAS, PAAS and SAAS), you can use it build virtual machines, you can establish a VPN between Azure and your OnPremise servers to extend your data center, you can use Azure App Service to build web sites, Mobile back end, API and Logic Apps, You can use its data services like SQL Azure, DocumentDB or Hadoop

The post will not even be enough to list all the features in Azure today, I shall write another post that introduces most of the features that you can use to build web applications with links to help you start

How to Start?

Microsoft offers a 30 days free trial with a credit of $200, after it expires you can create a subscription and still can use a lot of features offered for free.

You will notice that many services in Azure has a FREE plan with some limited features but you can use it to practice, of course it will not be possible to use these free features for production sites, one of few examples is Azure web App , it gives you 10 free Web Apps that can be accessible over the internet, it can run asp.net, NodeJS, PHP, Java and Python.

If you don’t already have an account, go to http://azure.microsoft.com/ click the Try for Free button and register.

Another way to have an account that gives you a free $25/month is through Microsoft newly introduced Dev Essentials, you just need an MS Account and then activate your benefits, if you didn’t do that already, you can do that from the below link, it also gives you a free 6 months PluralSight Subscription

Visual Studio Dev Essentials

I hope the post is helpful and if you have any comments, questions or suggestion,  please leave me a comment

In the coming posts, I will introduce Azure different services and explain how to build an application with it.