This chapter introduces Microsoft Azure, the process of implementing it, and the features and services it can offer us. We will cover the following topics:
A brief overview of cloud computing and Microsoft Azure
Selecting a Microsoft Azure solution
Administration of a Microsoft Azure system
Choosing a subscription
A walk-through of creating a Microsoft Azure account
Exploring the Microsoft Azure Management portal
Examining all the Microsoft Azure service options
Cloud computing is a term for computing resources and services such as server and network infrastructure, web servers, and databases, hosted by cloud service vendors, rented by tenants, and delivered via the Internet.
Cloud computing companies such as Microsoft and Google offer a variety of computing services built on top of their own infrastructure, which are managed in dedicated globally distributed data centers that offer high availability, resilience, and scalability.
There are three types of cloud service models, Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS). IaaS is the lowest service tier that offers server, storage, and networking infrastructure, which users can build their own systems on. PaaS allows users to create and deploy applications without having to worry about the infrastructure that's hosting it using services and tools designed to streamline the development and deployment processes. SaaS offers on-demand software products, which remove the infrastructure and software installation and setup overhead; web mail providers are an example of SaaS, where users can send and receive mails using a website rather than having to install a mail client on their machine.
Cloud services are often a cost-effective alternative to traditional on-premises infrastructure, which requires an initial investment in hardware and licenses and requires continual maintenance and expansion as required as well as utility costs such as premises' rent, electricity, and ISP.
There are four main cloud deployment models: public cloud, private cloud, hybrid cloud, and community cloud. Public cloud services are hosted by a vendor and made available to the public for use. Private cloud services emulate public cloud services in terms of features but are only available within a company's domain. Community cloud is a private cloud shared between a number of users. Hybrid cloud is a mixture of the other three.
Microsoft Azure is the collective name for Microsoft's cloud computing services that provide IaaS and PaaS service models. In terms of deployment models, Azure services would be classed as public; however, it's possible to install Azure Pack (http://www.microsoft.com/en-us/server-cloud/products/windows-azure-pack/) in a private data center that offers a private cloud model.
Microsoft Azure IaaS comprises of a number of globally distributed data centers that host virtualized servers controlled by the Azure Fabric Controller. When we host systems on Azure, we become tenants and pay for our share of processing and network resources that we use through the subscription we choose. In this layer, we can make use of services such as virtual machines, disk storage, and network services.
Microsoft Azure PaaS services are the main entry point for most developers, where we are offered a set of tools and services that allow us to develop and deploy scalable and robust systems such as websites, worker roles, and mobile services.
Microsoft Azure (formerly known as Windows Azure) was first announced in 2008 and was available as Community Technical Preview (CTP); then, it became commercially available from 2010. Since then, the number of services and features has continually grown to where we are now.
At the time of this writing, Windows Azure has been renamed Microsoft Azure as part of a rebranding exercise to move the services away from being tightly associated with Windows server operating systems, databases, and platforms, as Azure can support operating systems such as Linux that run on virtual machines, Oracle databases, Node.js, and PHP websites, to name a few. You may see the term Windows Azure still being used in documentation and resources for quite a long time. It's the same product, just with a different name, so it's likely to be still valid.
Before we start looking at everything Microsoft Azure can offer us, we need to take a step back and think about the reasons for choosing it in the first place. The first question is actually whether you should be using a cloud platform rather than your own infrastructure (if you have any); the second question, once you've decided to use a cloud platform, is whether to use Microsoft Azure or an alternative.
The main factors in choosing to deploy systems on a cloud platform are as follows:
Infrastructure capabilities: If your business doesn't currently own infrastructure for hosting your solution, or it doesn't have sufficient capacity, or the business simply doesn't want to invest in its own infrastructure, then a cloud-based solution might be the best
The main reasons for choosing to deploy systems on Microsoft Azure in particular are as follows:
Platform capabilities: If you've decided to build a cloud-based system using .NET, then Microsoft Azure is the obvious choice. If you are building a system on a different platform and Microsoft Azure can support it, it might be a good option.
Choosing to host systems on the cloud is not a straightforward decision. You may find that you have to go through the decision-making process on a project-by-project basis rather than having a policy where you always do the same thing for all systems.
Operating system migrations
Provision for expansion
Maintaining utilities (power, Internet, cooling, and so on)
If your business runs internal systems on just a single server, this may not be a full-time job for someone, but it still needs to be done and may be time-consuming periodically
If your business is on the other end of the spectrum and has two data centers that host hundreds of servers, you will need a team of people to manage them, which will obviously be very costly
If your business doesn't want to invest in its own infrastructure, irrespective of whether it needs enough servers to justify building a data centre, or just a single server with a website and database, it might be your best option to host your systems on a cloud platform
If your business' current infrastructure doesn't have the capacity for your system or it can't meet the required Service Level Agreement (SLA)
If your business has a heavy investment in its own infrastructure and can support future expansion on a variety of platforms, you may be less likely to want to use a cloud platform, but even then, there may be a service your infrastructure can't provide, or a platform it simply can't support, so it may be cheaper and faster to implement it in the cloud
If your business builds systems using Microsoft technologies, then Azure would be the logical choice, because although it now supports a number of platforms, Windows Servers, SQL Server Databases, and .NET platform tooling have been established long ago and have a fantastic toolset.
If, for example, your company does own its own infrastructure, but it's designed for running Java websites on Linux operating systems, and you have a requirement to build and host some .NET systems, you may want to choose to build your system on Microsoft Azure instead of provisioning more servers.
If Microsoft technologies are not your normal choice and you want to build a system on a cloud platform, you may choose Azure if it is more cost-effective than a competitor cloud service provider for a comparable design and SLA.
Cost can be one of the main drivers behind most decisions in a business; it has come up in both decision-making steps for choosing to use a cloud solution, then Microsoft Azure, so it's clearly important. I'd love to get straight down to talking about coding and deciding which bits of Microsoft Azure to use for what; we still have a responsibility to make the best decisions for our business and that includes designing a cost-effective system.
If you're working on a personal project, you may want to pick up a technology for reasons such as it being new or looking interesting; everyone does this and we might not mind if it costs us a few pounds (dollars or whatever), but in a business, we need to make the right choice ourselves or convince other people of the right choice, especially in the case of larger organizations, and that means choosing a solution that is cost effective.
We can use the pricing calculator to help us work out how much a system will cost once we have designed it; it is available at http://www.windowsazure.com/en-us/pricing/calculator/.
We've talked a lot about whether to use a cloud platform or not, and if your business decides to, whether it will be Microsoft Azure or whether to use your business' infrastructure; so now, we'll look at the administration overhead in looking after a cloud-based system and incorporating it into your business' maintenance and support procedures.
If you have a small organization or you are working on personal projects, you may choose to manage your environments yourself (you may not have a choice) and you may deploy applications to the cloud straight from your development machine. This is fine, but it's worth thinking about managing this process to make things easy for you and save yourself from accidently causing loss of service.
If you work in a larger organization with some governance in place, which dictates how systems should transition from a development environment to a live system and then how they are managed and maintained after that, you may need to put some new procedures in place or modify the existing procedures for handling cloud-based systems.
Using a cloud platform, we don't completely get away from systems management and maintenance overhead. The following are examples of administrative tasks we still need to consider:
Training: The people responsible for managing cloud systems will need to know how to manage and maintain them. This includes things such as understanding the different environments, using the portal, and how to perform deployments.
OS updates: It's actually possible to disable automatic updates on Azure OSes (this is not the default option), so if your IT policy is to have staged updates, you may wish to disable automatic updates and include Microsoft Azure systems in your update process.
Release management: Typically, in medium-to-large organizations, it's not normal for developers to deploy systems for staging or for live environments themselves, so this must be coordinated between developers and system administrators.
It's important to think about these things when deciding to implement a cloud-based system, because although there is certainly a huge reduction in administration overhead, particularly on the infrastructure side of things, they aren't completely administration-free.
The subscription you choose will depend on the type of project you are doing and its scale. If you are doing some experimentation or prototyping a system, which may never go into production, you may just want to use a free trial, which is time- and usage-limited, or go for a Pay-as-you-go option, where you pay for what you use rather than committing to a fixed payment. If you're a university student, your university may apply for a 5-month Educator Grant at http://www.microsoftazurepass.com/azureu.
To get started, you may need to do some design work to get some idea of the services you may require, what service tier you want, and how many instances of each service you may use, then go to the pricing calculator and start working out how much your monthly expenditure might be. There is a complete chapter dedicated to designing a system, and this whole book will help you choose which services you require, but we need a subscription to get started, so we'll talk about it now.
Once we have an idea about what our monthly expenditure might be, we can take a look at the purchase options page at http://www.windowsazure.com/en-us/pricing/purchase-options/.
The following table taken from the purchase options page shows us the discounts based on the base Pay-as-you-go rate and monthly commitment to spend in USD (there is a picker on the left-hand side of the page to change the currency):
$500 TO £14,999
$15,000 TO £39,999
$40,000 AND ABOVE
As with most commodities, the more you commit to spend, the better discount you get, and you save even more committing to pay for the whole term in one go.
You can pay by invoice as well as by credit card; the page at http://www.windowsazure.com/en-us/pricing/invoicing/ has details about requesting invoiced payments.
There is a new portal (https://portal.azure.com/), which was introduced earlier in 2014 during the Build conference. Unfortunately, at the time of writing this book, it was not complete enough for the majority of the services we're covering, so this book uses the old portal (https://manage.windowsazure.com/), which will continue to be available for some time to come.
If you already have a Microsoft Azure account, continue to the next section; otherwise, click on the Portal tab (https://manage.windowsazure.com/). It will take you to log in using your Microsoft account if you are not already logged in. Once you have logged in, you will see a big page saying you have no subscription:
Click on the SIGN UP FOR WINDOWS AZURE link (https://account.windowsazure.com/SignUp), and you should end up at the Sign up page (there are a number of routes to get to this page through the website, but this seemed to be the least clicks for me!). Your personal details should appear from your account info, and you'll need to verify it's you with an SMS or call verification:
Once your account is verified, you can enter your credit card details. Don't panic if you want a free trial or pay as you go; you don't get automatically signed up for any premium subscriptions; however, $1 will be charged to you for credit card verification. Accept the agreement and click on the Purchase button; your card details will be validated, and you will be taken to the subscriptions page, where you'll be pleased to find that you already have a free trial! This is shown in the following screenshot:
I chose the Pay-As-You-Go option for writing this book as I will not be leaving the system I'm building in production. Once you have selected your option, you get a purchase confirmation on your screen, as shown in the following screenshot:
If you have chosen to use a trial subscription, there is a spending limit feature so that you don't incur any costs; once you reach the offer limits, services will be disabled and data will be available as read-only.
Now that we have a subscription, we can go and start exploring the portal at https://manage.windowsazure.com/. When you go into the portal for the first time, you'll be presented with a nice tour wizard, which is a really good way of learning about the portal's features; step through the wizard, and then we'll look at these features and more without the wizard.
The menu available inside the top menu is as follows:
HOME: This links to the main Microsoft Azure site.
PRICING: This links to the price calculator for all Microsoft Azure services.
DOCUMENTATION: This links to the Microsoft Azure documentation home page; from here, you can find a large amount of reference material, code samples, and tutorials.
DOWNLOADS: This links to the downloads page, where you can find links to SDKs for all platforms and command-line tools.
COMMUNITY: This links to the community page from where we can find links to recent Microsoft Azure team blogs, links to other Azure blogs, and useful information to help us be up-to-date with what's going on with Microsoft Azure services. This is helpful because the platform is continually growing and changing, so it's good to be able to see what's going on.
SUPPORT: This links to the support page, which lists various support options for technical and billing issues, and contains links to MSDN forums.
Subscriptions menu (4): This menu allows you to adjust which subscriptions and their associated services are displayed in the portal; if you have a lot of subscriptions, you can even search for them! At the bottom of the page, there are also some useful links for managing your account:
Main menu (6): Clicking on your username at the top-right corner of the screen opens the main menu, which allows you to sign out, change password, view your bill, contact support, and access some other legal bits:
The various options available in the bottom toolbar are as follows:
Commands (2): The command bar provides contextual commands for controlling the currently selected service; in the preceding example screenshot, the controls are used for running a website, allowing you to browse, stop, restart, and delete it, and also allowing you to install WebMatrix, which is a lightweight web development tool.
Clicking on an alert symbol opens the alert banner showing more information:
Completed operations (4): A number of activities in the portal can take a while to complete and run asynchronously; once they complete, the completed operations' count indicator gets incremented, and clicking on this button shows you the completed operations' banners:
Individual operations can be dismissed by clicking on OK, or all of them can be dismissed by clicking on DISMISS COMPLETED at the top of the page.
We'll start taking a look at all the Microsoft Azure services available to us; while we do this, it's helpful to refer to the portal, and use the +NEW button to see the different options for each category. Don't be afraid to create a service to take a closer look; you can always delete it afterwards.
Microsoft Azure websites are a secure, scalable platform for publishing websites on a number of platforms (ASP.NET, PHP, Node.js, Python, and Classic ASP) with SQL Server and MySQL databases; there is also a large gallery of website templates for building websites on app frameworks such as Django, blog sites such as WordPress, and forums such as phpBB; to see the full list, click on the New Service button, and then navigate to COMPUTE | WEB SITE | FROM GALLERY.
Websites support SSL certificates for secure HTTPS sessions and custom domain names with A and CNAME records (for supporting a single domain name for a number of load-balanced web servers). Website instances can be manually or automatically (on schedule or on CPU metrics) scaled up and down to meet business demands. Websites can run in three modes, FREE, SHARED, or STANDARD, where FREE and SHARED run on a multitenant environment (a shared web server), but the SHARED mode has a higher resource quota than FREE. STANDARD runs on a dedicated virtual machine (small, medium, large size options similar to virtual machines).
Virtual machines offer you a scalable server infrastructure to build your systems from scratch. They are available as Windows Server or Linux operating systems, and there are a number of images available with server software such as SharePoint, SQL Server, and Oracle preinstalled. To take a look at the complete list, click on the New Service button, and then navigate to COMPUTE | VIRTUAL MACHINE | FROM GALLERY.
There are currently eight image sizes ranging from extra small (shared core, 768 MB RAM) to A7 (eight cores, 56 GB RAM) and default (one core, 1.75 GB RAM); obviously, the bigger the image, the higher the cost. You can see the prices in the pricing calculator at http://www.windowsazure.com/en-us/pricing/calculator/?scenario=virtual-machines. Virtual machines are charged at compute hours and have a monthly value in the calculator; Windows Server and Linux images cost the same, but the price increases with additional server software due to the extra licensing cost.
Mobile services are designed for mobile app developers so that they have a simple platform to quickly create secure (OAuth2 and key-based authentication over SSL) database and custom APIs and easily make push notification requests on all major mobile platforms (Windows Store, Windows Phone, iOS, and Android). Backend services can be created on Node.js or .NET; Node.js, which is the original platform, can be scripted in the portal directly or locally, and can be pushed using Git version control, whereas .NET backends, which are a relatively new addition, are created locally and published in a similar way to other web applications.
There's a complete set of SDKs for integrating mobile applications and other backend services for a growing number of platforms including Windows Store, Windows Phone, iOS, Android, Xamarin, HTML, and Sencha.
I recently wrote an entire book on this subject, which is available from Packt Publishing at http://www.packtpub.com/learning-windows-azure-mobile-services-for-windows-8-and-windows-phone-8/book.
Cloud services allow you to create scalable applications that have a high availability (99.95 percent monthly SLA). There are two main types of cloud services: web role and worker role. Web roles are web applications hosted on IIS in their own environment. They are different from normal websites as they have extra capabilities listed in the following bullet list (although websites can now be staged too), to start with web roles can start life as a website, then easily be added to a web role at a later stage if they require these additional capabilities. Worker roles are a bit like Windows Services, where they are applications with no user interface, which can perform long-running tasks from things such as processing data of a table to hosting a proprietary TCP server. Cloud service roles have the following characteristics:
They run on their own virtual machine
They can be scaled as required
They can be deployed to multideployment environments (staging and live)
They allow remote desktop onto their virtual machines
They execute start-up tasks
Data services are a collection of data-storage-related services including fully relational SQL Server Database, table storage, various Binary Large Objects (blobs) and disk-storage options, and storage queues. We'll take a look at each one in more detail now.
Microsoft Azure SQL Database is a fully managed, highly scalable relational database with a high availability (99.95 percent SLA). Microsoft Azure SQL Server is very similar to a SQL Server in terms of Transact-SQL (TSQL) and Tabular Data Stream (TDS) but has a number of features it does not support, such as:
Backup and restore (this will be supported when the new service tiers are made available)
Extended stored procedures
SQL Server agent/jobs
A full list of differences can be found here, although it doesn't currently mention SQL Server 2012 or 2014: http://msdn.microsoft.com/en-us/library/ff394115.aspx.
Premium edition: This is the same as premium editions but with reserved resource capacity for applications that may have a high peak loading, many concurrent requests, or require guaranteed low request latency
Databases benefit from having two data center replicas (for any tier of service) and the option to scale out as required (splitting large databases across multiple servers to improve performance).
Block blobs: This is the simplest way of storing large volumes of nonstructured data. Blobs can be accessed through managed SDKs and from anywhere via REST APIs. Block blobs are made up of a maximum of 50,000 blocks, having a size of up to 4 MB each, with a maximum total size of 200 GB.
Page blobs and disks: Page blobs are optimized for frequent updates and random access and are actually used as the storage media for Microsoft Azure VHD disks. Page blobs are collections of 512 byte pages; pages worth 1 to 4 MB can be written in one go and a maximum of 1 TB is available for a single blob.
Tables: Tables are a NoSQL (a nonrelational database) way of storing data, rather than storing data in a relational way, like in a traditional SQL Server Database, where we have tables, which have relationships with other tables via primary and foreign keys; Microsoft Azure tables allow you to create a container table, and then define classes that belong to it. These classes have a partition key, row key, and timestamp property, which allow them to be queried. Microsoft Azure tables allow us to store large amounts of data in a highly scalable way while still allowing efficient querying.
Queues: Queues are a messaging system that allows processes to exchange data between tiers of a system via a message queue. They are helpful for building scalable worker processes. Queues can be accessed via native SDKs and REST services.
HDInsight is a relatively new addition to the Microsoft Azure service family; it is a service based on Apache Hadoop (http://hadoop.apache.org/), which helps us integrate multiple data sources of different types and structures into Microsoft Business Intelligence (BI) tools such as Power Pivot and Power View.
Microsoft Azure Cache is a high-performance, in-memory distributed cache that allows scaled-out applications to share data without having to use a database. This can be useful for adding session state and page caching to ASP.NET applications (although session state is not generally a good practice for modern web applications, it may be useful for legacy applications or if you really can't live without it!) and also doing your own custom caching in worker roles for maintaining the state across instances. Cache is available in three tiers:
App services are a collection of services that help cloud and on-premises applications and services to interact with each other. They can be implemented on systems ranging from media-streaming services to multi-tier enterprise business systems. We'll look at each of these now.
Media services provide a scalable media processing workflow for digital media systems such as video-streaming services, from ingest through encoding, format conversion, and content protection, to on-demand and live streaming.
Queue: Service Bus queues as with .NET queues are first in, first out (FIFO) collections of messages that allow applications to communicate with each other asynchronously by publishing and consuming messages. This can be very helpful for building scalable systems across multiple tiers especially when part of the system may not always be online. It can also help with load leveling, where a consuming application can process batches of data in a controlled way rather than being driven by the producing application. Messages are processed by a single consumer and can be read in the ReceiveAndDelete mode, where the message will immediately be marked as consumed and returned to the provider and the PeekLock mode, where a consumer can get a temporary lock while it processes the request; then, if it cannot process the message, it can abandon it, or if it fails completely, the message will time out, allowing another process to consume it.
Topic: In contrast to queues, where we have a one-to-one relationship between a provider and a consumer, topics have a one-to-many relationship, where we create a topic with a number of subscriptions. Then, a provider can send messages to the topic, and subscribing clients can receive messages from subscriptions they are interested in.
Relay: Relays are different from topics and queues in that they don't offer disconnected services; instead, they can securely expose on-premises service endpoints, allowing them to be accessed directly by applications in the cloud.
Notification Hub: The Notification Hub service is a really nice way of handling push notifications to mobile apps from backend services in an efficient, scalable manner. Mobile apps on all major platforms can register to receive push notifications (in the case of Windows Store and Windows Phone applications, these are Toast, Tile, Badge, and Raw notifications), and from the backend service, just one request per platform is required to make the request rather than making requests per subscribed channel. The Notifications Hub also has a tagging feature, where users can subscribe to certain tagged topics and also template notifications, which can be used for localization support. The Notifications Hub handles all communications with the native Push Notification Services (PNS).
Visual Studio Online services allow Visual Studio Online accounts to be integrated into Microsoft Azure, enabling us to view, build, and load the testing status in the dashboard and enable continuous deployment so that websites can be deployed to a test environment on build when code is checked in.
The scheduler allows scheduled jobs to be created to perform operations such as making HTTP requests and performing actions on storage queues. Jobs can be scheduled to run once on demand, at a specific time, or at various intervals.
Azure AD allows you to manage user credentials and application access in your Microsoft Azure system. It is an Azure-specific, REST-based implementation of Active Directory, which is used with on-premises systems.
Multifactor authentication is an extra layer of security for applications. If you have a Windows Store account, you must have noticed that a PIN is sent to a configured mobile phone or e-mail address, which you must enter before signing in with your Microsoft account. This can be added to on-premises applications using ADFS, and to systems integrated with Windows Azure AD.
Traffic Manager allows user traffic to be distributed to the most appropriate cloud service or website within the same data center or across global data centers depending on the load-balancing method chosen. Traffic management requires one of the following three load-balancing methods:
We've covered a lot of preliminary subject matter regarding the decision process that will help us choose to build a system using Microsoft Azure, and also explored all the services available to us.
Next, we're going to look at how to go about architecting a system for Microsoft Azure and introduce a case study on which the examples in this book are based. We'll use the knowledge we've gained about the different Microsoft Azure services available to us to help design the system in the case study and choose the right service for each part of the system.
Throughout this book, we'll examine services in detail as we build the system in the case study.
What are the three types of cloud service models?
What does PaaS stand for?
What is Azure Pack?
In which two ways can we pay for Azure subscriptions?
What are the three notification types that can appear on the portal toolbar?
Name the three website modes.
Which two operating systems are available on virtual machines?
Name four platforms supported by Azure Mobile Services.
What are the two types of cloud services?
How many deployment environments does a cloud service have?
What is a Notifications Hub?
What are the three Traffic Manager load balancing methods?
IaaS, PaaS, and SaaS.
Platform as a Service.
It allows Azure to be installed in a private data center offering a private cloud deployment model.
Credit card or invoice.
Error, Warning, and Info.
Free, Shared, and Standard.
Windows Server or Linux.
Any of these: Windows Store, Windows Phone, iOS, Android, HTML, Xamarin, and Sencha.
Web role and worker role.
Two—staging and production.
It is a Service Bus service, which provides a scalable way of handling push notifications from backend services.
Failover, Round Robin, and Performance.