CHAPTER 2
Windows Azure is a collection of products and services hosted in Microsoft’s data centers to enable developers and organizations to quickly assemble the right combination of pieces for their application’s needs. The tools represented in the Windows Azure suite almost exclusively focus on either hybrid, IaaS, or PaaS—with the only potential exception being the Visual Studio Online product. A key characteristic of all of the Windows Azure products is the idea that customers only pay for what they use, whether that is central processing unit (CPU) time on a virtual machine (VM) or disk space for persistent storage. This presents an extremely low barrier to entry for customers who initially have very low computing requirements, as well as a powerful tool to keep budget under control for customers with periods of heavy volume separated by periods where the volume is much lower.
Microsoft separates the Windows Azure products into four major categories based on the type of service that they provide. In this section, we will briefly discuss the services in each category, going into more detail for those services more likely to be encountered when building Windows Azure Web Sites. If you are already familiar with the various services offered in Azure or just prefer to discover them as you go along, you can safely skip reading this section.
Compute services are products that focus on utilization of the CPU capability in the Microsoft data center hardware. These are all priced based on a combination of CPU cores and available random access memory (RAM) and share the same capability for health monitoring and auto-scaling to meet customer demand in a flexible way that still controls cost.
Virtual Machines (VMs) are the only product in the Compute category that is considered an IaaS offering. With VMs, you can run dedicated virtual servers in Microsoft’s data center, starting from a number of predefined templates or even upload your own virtual hard disk (VHD) containing a configuration that you have created. These machines can run by themselves or participate in an ecosystem where they interact collaboratively with PaaS solutions.
The Windows Azure Web Sites product is focused on providing a targeted set of services to allow for the creation and maintenance of websites using many of the features required to make a website useful. This includes support for various server-side technologies including ASP.NET, classic ASP, PHP, Node.js, and Python, and includes either a Windows Azure SQL Database or MySQL to provide a backing store for your applications. As with the VMs product, application owners can either bring their own custom application or choose from a growing collection of site templates based on popular frameworks in the Application Gallery.
Mobile Services are a set of services aimed at providing the most commonly required server-side functionality to power mobile applications. These services allow developers the opportunity to quickly add features such as:
It’s important to the reader of this book to note that, even though these services are marketed as services geared to mobile devices, many of them can be extremely useful in developing highly interactive Web 2.0 applications.
Cloud Services are run time containers for executable code that are often used to create the back end service layer for applications that may be running on desktops, mobile devices or even other servers, and provide an alternative to managing a VM to applications built in a way that allows them to be deployed directly into Azure services. These services have commonly been used to create application components known either as Worker Roles or Web Roles. Worker Roles are application components that run as an independent process executing a task with no user interface (UI), while Web Roles share mostly the same run time characteristics as a Worker Role but add being publicly addressable on the Internet in order to serve either as a UI or public service API. Cloud Services are an integral part of many enterprise applications but will not be required for many small to medium-sized websites because Azure provides capabilities to meet their needs within the Azure Web Sites product.
One of the driving forces behind the success of Azure is that Microsoft has accounted for the fact that there is no one answer to “What is the best tool for ___?” Instead, many choices are available for accomplishing most tasks to allow architects to review the need in full context and identify the best (or sometimes just the least bad) way to solve the challenges that are presented when developing modern applications in the cloud. This is extremely apparent when looking at the choices made available when selecting how the application will store and retrieve data. Architects can examine such questions as:
For those questions and more, a variety of storage tools is available to provide a tailored solution for the needs of your application—either through bringing a single tool to bear or potentially building a solution that combines the strength of multiple tools.
Azure Storage is actually a subset of the Azure data services that encompasses a few different types of storage mechanisms itself, each aimed at solving a different storage problem:
Azure SQL Database can be reasonably thought of as Microsoft SQL Server’s extension to the cloud. With some features that could not scale well to a cloud solution removed, most on-premises applications built with Microsoft SQL Server will transfer to Azure SQL Database without any modification.
HDInsight is a service based on the Apache Hadoop platform. HDInsight is used to store and access large quantities of structured and unstructured data (commonly known as Big Data). A common use case for this tool is for data to be warehoused for analysis with business intelligence tools such as PowerPivot.
Azure Cache is used as a transient store to keep data that may be expensive to retrieve and is used frequently within the application close to where it is needed without having to again incur the cost of subsequent retrievals when it is needed again. Azure’s solution can either keep the cache within the application’s worker role or utilize it as a shared cache available to other components of your solution.
Azure Backup is an infrastructure tool used to provide off-site backup of your on-premises server data, providing additional features such as versioning and automated execution of data retention policies.
Azure Site Recovery (formerly Azure Hyper-V Recovery Manager) is an infrastructure tool used to provide off-site replication of private clouds running in on-premises data centers to a separate location and to coordinate recovery from the secondary location in case of outage at the primary.
App Services are a suite of tools that can be leveraged by application developers to add features to their solution without spending a tremendous amount of time and effort solving common problems that others have already solved. These services allow for developers to write the code that only they can write and focus on things that directly contribute to the problem that they are trying to solve with their application. A given website might need any number of these services. As with Data Services, many of the App Services have some degree of overlap with other App Services, requiring architects to thoroughly consider the strengths and weaknesses of the tools along with cost when determining the right tool for a given job.
Handling of media content is a problem area that many application developers could specialize in and make the focus of their entire career because it’s a complex and dynamic problem area. In addition to the complexity of dealing with the various encoding methods and ensuring that the content is delivered in a manner compatible with the consuming agent, most applications of media content also require protection of the content from unauthorized use, monetization of authorized use, and a way to measure how the content is used. Azure Media Services provides tools and APIs to handle all of these tasks either as a stand-alone service or integrated with your solution. Examples of applications using Azure Media Services may include a broadcaster streaming a live sporting event to Internet subscribers or a content provider renting Digital Rights Management (DRM)-protected content to a customer that is viewable for a limited amount of time.
Azure Service Bus is primarily known as a more robust queuing mechanism than Azure Storage Queues. The Service Bus is used to provide messaging between applications whether they are within the same Azure solution, part of another Azure solution, or a hybrid solution with on-premises components interacting with cloud components. Azure Service Bus allows for a loose coupling between these components that allow for massive scalability and also for flexibility if the implementation of one of the components within the system ever needs to be entirely reworked. Azure Service Bus will be discussed in a dedicated queuing chapter.
Notification Hubs provide a publish/subscribe framework for components within a solution to broadcast messages to all clients or target those messages only to specific clients. Publish/subscribe is an important pattern for scalable applications and could easily be the topic of its own book. Therefore, developers looking to move their skills to the cloud who are not familiar with this pattern should take the time to learn about it.
Azure Scheduler is a simple tool that enables jobs to be set up for execution and run outside the execution path of your application. Scheduled jobs can either invoke an HTTP web service or can post a message to a storage queue. Typical use cases include performing data management tasks (such as preaggregating data or clearing temp storage) and batch communications with external services.
As Azure SQL Database is the cloud evolution of the Microsoft SQL Server tool, Azure BizTalk Services brings the Microsoft BizTalk Server integration platform to Azure. This tool is primarily used to handle complex integration either between enterprise application platforms such as SAP and PeopleSoft or between businesses such as in electronic data interchange (EDI) transaction processing.
Visual Studio Online is a bit of an outlier when it comes to the tools categorized by Microsoft as App Services because, rather than providing run time services to add functionality to the application, it is used for the actual creation of the application. Visual Studio Online provides tools to host source code repositories either in a centralized or distributed manner (via Git or Team Foundation Version Control), plan and track projects, manage the testing cycle, and evaluate the initial and ongoing performance of the application.
Azure Active Directory provides authentication and authorization services, and can either stand alone or be integrated with an on-premises Active Directory through either synchronization or federation.
Multi-factor authentication is used to address the problem often caused by compromised passwords by providing steps beyond just supplying a password for the user to prove their identity. These steps typically involve a system-generated temporary passcode which is sent to a device or telephone known to belong to the user whose credentials are being used through a mobile app, text message or phone call.
Azure Network Services are aimed at providing support for IT professionals to achieve network configurations to enable and optimize applications running within their Azure account or in combination with on-premises solutions. These services are not directly applicable to building Azure Web Sites but are listed here and very briefly described to provide a complete picture of the tools available in the ecosystem to solution developers.
Azure ExpressRoute is an advanced tool made available through network service providers that provides a direct connection to the Azure data centers rather than connecting through the public Internet. This is used when reliability, speed or security requirements justify the cost of maintaining the direct connection.
Azure Virtual Network allows resources hosted in the Azure data center to exist in the same logical network as on-premises resources. This is useful when building hybrid applications where components of the application must be on the same network.
Azure Traffic Manager is a load-balancing solution used to control the distribution of requests that reach Azure services. This can be used to add fault tolerance and/or increase the performance of applications. For example, Azure Traffic Manager could use a balancing strategy known as round robin to cycle through a set of destinations in order to keep an even load across servers (assuming each request would produce the same amount of load as another) when used to increase performance. Azure Traffic Manager could use health monitoring to detect that an instance of your service has gone down and redirect traffic to another instance to achieve fault tolerance.
Before you can start developing websites on Azure, some steps need to be taken, both in setting up a development environment and in getting an Azure account. In this section, we’ll cover the basics necessary to get a developer up and running on the Azure platform.
This might seem like an obvious step but the first thing as a developer that you should do when preparing to venture into developing solutions on Azure is to familiarize yourself with the tools, techniques, and patterns applicable to making a successful application in the cloud. Reading this book is one step. Another very valuable resource is the Patterns & Practices section of Microsoft’s MSDN website (http://msdn.microsoft.com) which includes a collection of cloud development topics designed specifically to discuss problem and solution patterns particularly applicable to a cloud environment. Additionally, Microsoft and others sponsor many free, in-person and virtual training opportunities such as code camps and Microsoft Virtual Academy (http://www.microsoftvirtualacademy.com). Also, many popular online paid training opportunities exist.
Note: The URLs referenced in this section are current as of the time of this writing but may not remain consistent over time. If any URL is not accessible to the reader, I recommend searching for the current location using the search engine of your choice. Additionally, actions to be taken during an on-page workflow (such as sign up wizards) will be described as generically as possible because Microsoft may change steps at any point in time.
The steps for setting up your local development environment can vary greatly depending on the tools that you will be using to create applications and the individual Azure services that will be leveraged in your solution. In this section, we’ll cover the most basic setup for building websites using Visual Studio 2013.
If you don’t already have it, the first step in getting your .NET-based development environment set up is to obtain and install Visual Studio 2013. Visual Studio is available in many editions, ranging from the free Visual Studio Express 2013 product to Visual Studio Ultimate 2013 which comes at a premium cost. Many sources exist comparing the features available in the different editions of the tool, so this book will not go into those details. Visual Studio 2013 can be downloaded at http://www.visualstudio.com/downloads. You will be given the option of downloading either the free Express edition or a trial version of one of the paid editions. All of the descriptions and screen shots from this book were created using Visual Studio 2013 Premium, but Visual Studio Express 2013 for Web should be sufficient for creating and working with Azure Web Sites.
With Visual Studio installed, you’re ready to install the Azure tools for .NET and Visual Studio. More than one option exists for how to obtain and install the SDK but, for the purposes of this book, we’ll discuss the direct download option. Azure SDK and tool downloads are available at http://azure.microsoft.com/en-us/downloads. For Visual Studio 2013, you will want to select the “VS 2013 Install” link and then run the downloaded executable and follow the prompts.
In addition to the SDK and Visual Studio tools, you will most likely find value in installing the Azure command-line tools which are also available at http://azure.microsoft.com/en-us/downloads. Under the “Command-line tools” heading, you will find a Windows PowerShell download and Azure command-line interface installer as well as documentation for each. The Azure command-line interface tool can be downloaded for either Windows, Mac or Linux.
To establish an account on Azure, you need to first have a Microsoft account. If you don’t already have a Microsoft account, you’ll need to create one. Assuming that you already have a Microsoft account, go to http://windows.azure.com. If you are not already logged into your Microsoft account, log in as prompted. Once logged in, select the option to sign up for Azure (at the time of this writing, this was a call to action on the page labeled “Sign up now”). This will present several options from which to select including a free trial, a pay-as-you-go option, and some prepaid options intended for businesses that anticipate higher utilizations and want to benefit from receiving volume discounts for prepaid services. For the readers of this book, I would recommend going with the free trial option when available. Once the desired option is selected, follow the prompts to provide required information and complete the registration process.
Note: Pay close attention to the details of the information that you are providing and to ensure that you understand the costs associated with services that you utilize. If you provide payment details such as a credit card number and do not select spending limits, you could find yourself surprised by a bill received for services that you activated to explore and didn’t subsequently decommission.
After completing the registration process, you can access the Windows Azure Management portal to manage your accounts, subscriptions, and services at http://manage.windowsazure.com.
In this chapter, you learned about many of the services offered on the Azure platform and focused more on those services which may be particularly valuable in the creation of Azure Web Sites. You also learned how to prepare yourself and your development environment to successfully build applications to run on the Azure platform. This knowledge, along with the account that you now have set up (if you didn’t actually set up an account, you will need to do so in order to fully benefit from this book), will be used and built upon in the following chapters as you create and program websites on the Azure platform.