One of the benefits of building your application on Azure Infrastructure services is that you can completely control your virtual machines, so it's much easier to lift and shift an application you have deployed elsewhere or if you are deploying an application that requires components not available on Azure App Service. It is important, however, that you understand how best to deploy your virtual machines so you have a secure and highly available infrastructure. During this blog post I will deploy a simple WordPress site and demonstrate how to secure this infrastructure using Virtual Networks as well as discuss high availability options.
First, Some TheoryBefore we jump straight in let me explain a couple of concepts that you really need to understand before working with Azure Infrastructure Services.
Always Start with a Virtual NetworkIt is possible to jump straight into Azure and spin up a VM. You will be able to select from a wide range of Images, both Microsoft and Third Party, and define the size of VM, depending on it's function and if you need high memory or processing power. Check out this document on all of the different VM sizes available and this one for the types of VM images you can create. However, if you want to separate the tiers of your application, e.g. application and database tiers, into separate subnets and control access between, or if you want to completely block public access to a range of virtual machines, then you really need to start with a virtual network. Actually, I would say, always start with a Virtual Network as you never know when you will need it and it costs you nothing to use it. In fact, now whenever you create a VM a new Vnet will be created for you, so it's just good practise.
Understand Availability SetsThe fact is that there are situations where your virtual machines may be rebooted, and this could be during planned or unplanned maintenance. Obviously, this scenario is avoided as much as possible using live migration where appropriate and you may never actually experience it, but if you are planning for high availability then you should design with this in mind. Start by fully understanding our planned and unplanned maintenance policies for virtual machines.
To achieve high availability and a service level agreement you must place your VMs in an availability set. This will allow you to spread your VMs across fault and update domains. Fault domains are separate facilities within a region that have separate power and networking and are highly unlikely to fail at the same time and update domains are stamps within the data centre that are updated in turn, so no two stamps are updated at the same time. By spreading your VMs across update and fault domains you can survive both planned and unplanned maintenance as well as achieve an SLA of 99.95% uptime. Because VMs within an availability set may be rebooted during maintenance (always leaving at least one running) then there is no point mixing roles within an availability set. That is, don't place an app server and a database server in the same availability set, instead create two availability sets, one for your app servers and one for your database servers. You should also note that Micro soft have no knowledge of what is running inside your VM, that's the benefit of control you have, so it is up to you to ensure your application or database can work this way, i.e. that your application is stateless or stores its state in a central location and that your database is replicated across VMs.
You should also be aware that having a VM without an availability set is perfectly supported and this is a useful scenario if you manage your application availability some other way (e.g. with a cache or queuing mechanism) or if the VM is not running a critical workload. In this scenario if we need to reboot your VM you will get a one week email notification. So make sure your Azure account email address is monitored.
Creating the InfrastructureIn the following steps I will create a virtual network with two subnets, one for our web servers (WordPress) and another for a database server. In the app subnet I will create an availability set with two VMs and show how to setup load balancing between them.
Create a Resource Group and Virtual NetworkAll of the steps below will be taken with the new portal at portal.azure.com.
Next we will create two WordPress VMs and place them in our appsubnet.
The above steps show you the basics of creating virtual machines within an availability set and a virtual network. Below I list some of the other steps you would need to take to get the highly available site fully up and running, including building a database backend and pointing your new WordPress site at it.
Next StepsSource: Getting Started with Infrastructure Services on Azure
No comments:
Post a Comment