IN THIS CHAPTER
To this point, the focus of this book has been on migrating an ASP.NET website to an ASP.NET MVC 4 application and optimizing it. New topics learned during this reinvention included models, views, controllers, RouteMaps, the Razor scripting language, MiniProfiler, and the F12 Developer tools available in Internet Explorer. These concepts and tools advanced the example blog website for this book from older to newer technology and models. After utilizing some online tools such as Modern.IE or Google PageSpeed and incorporating those tools’ suggestions, the ASP.NET MVC 4 application can now perform and respond much faster. With that, the ASP.NET MVC 4 application for this book is complete and ready for you to host so that people can find, use, and share the information on the blog.
Besides the cloud, you can use a variety of platforms, hosting types, and services to deploy the ASP.NET MVC 4 application. For example, you can create a co-hosted website with a web hosting provider, build your own server, and then connect it to the Internet, or rent a server or virtual machine from an outsourcer.
In this chapter you will learn how to prepare an application for deployment and hosting on the Windows Azure platform. This chapter discusses topics such as understanding the supported SDKs like PHP, Ruby, Java and so on, as well as understanding the different types of Cloud Services, such as IaaS, PaaS and SaaS (defined later in the chapter). Additionally, the chapter covers the different deployment options and how to monitor the status of a deployment.
Because you have a number of hosting options, you should exercise due diligence in researching what works for your situation before making the final decision on where to host your website. The next section provides some tips for determining if Windows Azure is the best platform for your system as well as the sample ASP.NET MVC 4 application for this book.
To evaluate whether the Windows Azure platform suitably meets your needs (and the needs of the ASP.NET MVC 4 sample application), you should consider the benefits it offers, which include but are not limited to those discussed in the following sections.
Without much effort, a company can get its system implemented and running in a live environment on the Windows Azure platform faster than ever before — without purchasing hardware or software licenses, or implementing services, such as a Release Manager. You simply gain access to the Windows Azure environment, create the website or Web Role and/or storage feature, and, with a little configuration, the system is ready for use.
As mentioned in more detail in Chapter 3, a benefit of the Windows Azure platform is that it scales quickly and easily. The Windows Azure platform has something called elastic scalability, which allows you to quickly add more physical resources when your system requires them, such as an increase in traffic. Then, when the burst of traffic decreases, you can remove the additional capacity.
In addition, by having multiple instances of a Windows Azure Web Role, if one were to fail due to a worker process hang, for example, you can deploy a new role and automatically direct traffic to the working instance. From a data storage perspective, Windows Azure replicates storage services to multiple different servers to guarantee availability and durability.
Another benefit is that you can release internal IT resources to focus on tasks and activities that are most critical to business and innovation. Because management of infrastructure is increasingly outsourced, the in-house IT department no longer attends to network, OS patching, system issues, and other duties. These outsourced responsibilities are thus managed by high-quality support engineers and top experienced practitioners who proactively work to quickly respond to the technical issues happening on the platform.
Azure’s mobility enables you to access files, notes, intellectual property, and e-mail from a large variety of devices from almost any location in the world. For example, Microsoft’s SkyDrive or Office 365 are cloud applications hosted on the Windows Azure platform — both of which enable a company or an individual to store, share, and collaborate on tasks from anywhere on any device. You get all of this is at a price that is likely to be lower than the cost of hosting your own server or managing and running your own data center.
Cost is a significant factor when deciding which hosting service or model to use for your website. If your website does not get significant traffic or generate revenue, most likely the Windows Azure platform or any of the cloud platforms are not the most affordable or logical option to host your website. For these instances, some web-hosting companies have only a few dollars ($US) a month for hosting. Therefore, if you are an individual, the cheapest solution is likely the best option.
Because ASP.NET MVC 4 is based on the .NET Framework, it is certain to be supported when you deploy to the Windows Azure platform. At minimum, you must install the .NET Framework 4.0 for an ASP.NET MVC 4 application to function as expected. As shown on the Windows Azure Web Site and illustrated in Figure 5-1, you can download and use a number of other SDKs to code your application. By using the frameworks provided in the SDKs, you can be confident of seamless integration and support when you deploy to a Windows Azure Web Site, Web Role, or virtual machine.
Each of the Developer Centers provides information for the selected technology. As a result, .NET, Node.js, Java, PHP, and Python are currently supported on the Windows Azure platform. Additionally, Mobile Services and Media Services have tutorials and SDKs to implement those features available on the website. You can also find tutorials, reference documents, API, and REST interface descriptions for the website’s technology framework.
It is important to confirm that the technology and components your website requires to function and operate properly on the Windows Azure platform. By using these SDKs in preparation for deployment and performing a proof of concept early during your project, you can avoid surprises and costly delays. Proof of concept is a small program that you use to test the basic features of a software library before you make a large scale commitment to it.
Before moving into the cloud, you need to make two specific decisions. The first is determining the service model on which you’ll host your application, for example IaaS, PaaS or SaaS. Each of these service models requires different levels of support and responsibilities once a system is deployed to the platform. These differences are discussed in detail in later sections of this chapter. The second decision is determining in which deployment model you will host those service models. Do you want a private or on-premises cloud, or do you want to deploy your application directly into a public cloud? Security and cost are relevant things to consider for these deployment models, which are discussed in later sections of this chapter.
Different Cloud Services have different levels of technological support. These Cloud Services offer the resources required to operate most web-enabled systems imaginable. Cloud Services give you the hardware and the operating systems to run the website or solution as well as the binaries for executing and compiling your code. Other features are the Network connections and bandwidth that funnel information to your customer. Table 5-1 illustrates some of the most common Cloud Computing Service models.
ACRONYM | DESCRIPTION | SHORT DEFINITION |
IaaS | Infrastructure as a Service | Provides physical or virtual machines for service hosting. |
PaaS | Platform as a Service | Computing platform with OS, programming language execution, database, and websites. |
SaaS | Software as a Service | Cloud providers install software that users can access and use from any location, for example, Microsoft Office 365. |
DaaS | Database as a Service | A database for systems to connect to and use. |
NaaS | Network as a Service | VPN, bandwidth on demand, and network/transport connection services. |
The most common Cloud Computing Services, all of which are supported in the Windows Azure environment are IaaS, PaaS, and SaaS. As illustrated in Figure 5-2, each of those services are built on top of each other and sometimes referred to as the Cloud Stack.
NaaS, recently released on the Windows Azure platform, allows you to now configure Virtual Private Networks, site-to-site networks and point-to-site networks. DaaS is deployed and used by creating a database in the cloud and connecting to it. All the previously mentioned service models are available on the Windows Azure platform.
At the bottom level of Figure 5-2, you’ll notice Infrastructure as a Service (IaaS) which is the most basic model level. IaaS provides the physical hardware where cloud users can install operating systems and/or applications that run on this hardware. In most cases, it contains the virtual machines managed by products, such as Hyper-V or VMware. As previously discussed, virtual machines support the elastic scalability needed for system usage bursts. Other resources commonly provided with IaaS may include IP addresses, firewalls, and file storage.
The operating system exists on top of the physical hardware or virtual machine; this is where the Platform as a Service (PaaS) resides. Besides operating systems (such as Windows Server 2008 R2, Windows Server 2012, or Linux), code execution binaries, web servers, and databases provide environments where individuals, developers, or companies can host their computer system. The PaaS is also where the ASP.NET MVC 4 sample website (used throughout this book) exists. Both the Windows Azure Web Site and Windows Azure Cloud Service provide the PaaS services.
Cloud providers offer Software as a Service (SaaS) so consumers can access and use software on numerous devices from any location provided they have an Internet connection. The software is typically installed, supported, and managed on the PaaS environment by the cloud provider thereby eliminating those responsibilities from the individual or company. Some examples of SaaS are Microsoft Office 365, Microsoft SkyDrive, and Microsoft CRM Dynamics Online.
In addition to the Cloud Computing Service Models there are also different types of deployment models, which are summarized in Table 5-2. These are discussed in more detail in the following sections.
DEPLOYMENT TYPE | DESCRIPTION |
Private cloud | Cloud infrastructure for a single organization |
Public cloud | Cloud infrastructure made available by a provider, that is, Windows Azure |
Community cloud | Cloud infrastructure shared between two or more organizations |
Hybrid cloud | An arrangement of two or more of the other deployment models |
The primary difference between a private and public cloud is as follows:
The following sections examine private and public clouds in more detail.
A private cloud is likely utilized and implemented by companies or governments that must perform actions required by law or for regulatory compliance. These capabilities may not yet be possible in the public cloud. For example, a private cloud in the Windows Azure environment located onsite, resides in a company’s or organizations own private data center. The benefits of a private cloud are that you can customize it however you want, and it is perceived to be more secure compared to a public cloud because you have more control over the environment. Contrast that with a public cloud where you do not control operating system patches, the hardware, or the infrastructure, such as load balancers, network, and firewalls.
You can have either an offsite or onsite private cloud. The main difference between the two is that the offsite infrastructure is hosted in an outsourced data center (see Figure 5-3):
A public cloud is a large group of servers owned, operated, supported, and maintained by a cloud provider. When individuals or companies sign up for a Windows Azure account and deploy a website or Web Role, it is deployed into a public cloud.
Figure 5-4 illustrates a comparison or pros and cons between a private and public cloud. Full control of the environment, the usage of a private network, and having full control of and access to the content (that is, more security) are positives of the private cloud. Whereas initial capital costs, the requirement of building and managing the environment, and not getting many synergies by sharing the capacity are the private cloud deployment model’s downsides.
Don’t get the wrong impression that placing content or intellectual property into a public cloud is not secure. The private cloud does give complete control of access to the company owning and operating the private deployment model; however, even the public cloud has sophisticated layers of security.
The positive aspects of the public cloud deployment model are that it is less expensive to deploy and run; scaling the environment does not require the purchase and configuration of any hardware; and there are many real-world examples of high-performing, high-available solutions deployed to the public cloud that you can use as models. Negative aspects include the possibility you may be sharing your environment with other customers or companies and that this somehow will impact your websites’ performance or availability. Also, initially, the cost of the deployment may be complicated to calculate, and you do not have complete control over operating system patches or if other third-party components get installed. For all these reasons, you should use the private cloud only if you have a legitimate business justification.
A community cloud is a group of servers shared by a group of companies or individuals.
This approach is usually performed with partners or individuals who want to gain more control over their environment while spreading the costs across a group of trusted partners in the community. An advantage to this model is that you reduce the costs incurred by the purchase of hardware and maintenance. A disadvantage is that you share the environments with other systems that may impact the performance of your system by either using too much of the systems resources or by installing or updating dependencies that have a negative impact on the co-hosted systems.
A hybrid cloud is generally only used by enterprises who want to build a solution that is not yet completely available in the cloud. Figure 5-5 shows a hybrid deployment model that implements two or more of the four described deployment models. This model means you can control areas that you do not want outsourced but rather want to keep in-house or on-premises, while at the same time placing the pieces you want to make public into a multi-tenant cloud. You can also realize some cost advantages by placing content you still consider intellectual property on the public cloud.
A hybrid cloud is more cost effective when compared to a private cloud because your internal IT department only manages, supports, and scales out a portion of the company’s solution. You can pick and choose the best components of each deployment model, and build your own cloud solution. The down side is that because the system is hybrid, it’s also unique and you’ll have no best practice examples or patterns to follow. If you choose a hybrid cloud deployment model, you innovate and build a solution, which may result in unique problems that might need skilled and experienced cloud experts to work through and support. Therefore, you must choose your solution carefully and consider supportability and flexibility options before committing.
At this point the different Cloud Service and deployment models, plus the supported SDKs should be understood. The next step is to gain access to the Windows Azure platform. This, of course, assumes that you have decided to deploy to a public cloud and chose either an IaaS, PaaS, or SaaS Cloud Service. There are currently no private, hybrid, or community deployment models on the Windows Azure platform.
Obtaining access to the Windows Azure platform is not complicated. The details of this are discussed and performed in Chapter 6. After you provide the required information to access the platform, you log into the Windows Azure Portal, and can view the main overview page similar to that shown in Figure 5-6.
The right side of the management pane contains various platform items. You can click a group to access a specific item, or click the +NEW link to create a new item of any type. Table 5-3 shows the various services you have available to you.
Most of the services are intuitive and do as they are called, such as Web Sites, SQL Database, and Cloud Services, all of which have examples and exercises provided in Chapter 6. For many, Service Bus, Active Directory, SQL Reporting, and others likely need some additional investigation and study. All the details and descriptions for these services are provided at the following URL; click the Services link as shown in Figure 5-7: https://www.windowsazure.com/en-us/documentation. There is also a discussion of some Windows Azure Services provided in the following section, “Choosing your Windows Azure Services.” Nonetheless, a brief explanation of each Windows Azure service item is provided in the following list.
This section did not cover the details of all the services and options available on the Windows Azure platform because the best way to understand your options is to access the platform and start testing them, working with them, and obtaining practical experience. Learning how to apply the services to your company and communicating those benefits internally can come only after using and working in the platform over time. Some very good documentation that discusses all the Windows Azure service can be found here: www.windowsazure.com/en-us/documentation/.
For the examples and exercises provided in this book, the Compute and Data Services are chosen for you. However, when you’re choosing which services you require for a system other than the example, you may need more information. For example, what are the differences between a Windows Azure Web Site, Cloud Service, and Virtual Machines, and when should you use which? What is the difference between a Windows Azure SQL Database and Table Storage? And what are SQL Reporting, HDInsight, and Active Directory?
Let’s begin with the analysis and comparison of the Windows Azure Web Site, Cloud Service, and virtual machine. With a Windows Azure Virtual Machine, you can do basically anything you could do with a VMware or Hyper-V virtual machine. For example, you can build the infrastructure completely on your terms, choose the operating system, such as Windows Server or Linux, and securely connect your on-premises system with virtual machines running on the Windows Azure platform.
A Cloud Service, also referred to as a Web Role, provides an easy way to build and extend enterprise-level applications that require high availability and multitier settings. Windows Azure customers can also use Web Roles to create a Software as a Service (SaaS) product for their customers, which customers can use and access from any place in the world. Websites are co-hosted on multitenant instances, meaning they are co-hosted with other websites on the same virtual machine, but neither Remote Desktop Connection nor the ability to run programs nor software in an elevated mode (such as Run as Administrator) are supported. However, websites support FTP and GIT deployment options, which provide for near-continuous deployment strategies. Figure 5-8 illustrates these capabilities in more detail. Note that when running a virtual machine on the Windows Azure platform, you can utilize features available to both a website and a Web Role. Therefore, all the capabilities shown in Figure 5-8 apply to a virtual machine, too.
There are also two data storage capabilities to choose from:
You choose Windows Azure SQL Database when:
Choose Windows Azure Table Storage if:
Windows Azure SQL Reporting is built on the SQL Server Reporting services. This capability provides access to reports using only an Internet browser. After the report is accessed and rendered, it can be extracted to Excel and saved as a PDF. You can find more information by searching for Windows Azure SQL Reporting from any major search engine.
HDInsight is one Microsoft’s Big Data initiatives and solutions. Big Data analysis and technologies are all over the news and discussion boards, and it is commonly referred to as a solution without a problem to solve. Nonetheless, most of the major players in the IT industry, such as Amazon.com, Google, IBM, Facebook, Microsoft, and so on are investing big into this technology. If you are interested in working with it, you can add the feature to your Windows Azure platform and give it a test drive.
The Active Directory capabilities available on Windows Azure are similar to those available in a standard domain. The Active Directory supports the creation of domains, user, computer and service accounts, and the authentication of those accounts. This is a feature that is not currently available with any other cloud provider. A significant benefit and usage for this feature is to create and support a single-sign-on (SSO) solution for all your applications that exist in your domain, similar to the Windows Authentication, which uses either NTLM or Kerberos. In many corporations, employees need to know multiple user IDs and passwords to access the many systems in the company to do their job. With an SSO solution, the employee can sign-on once and access all the systems that they have authorization to as long as these resources exist in the same domain. This is one of the more exciting features available in the Windows Azure platform, and is full of innovative possibilities.
Now that you know how to prepare your application for Windows Azure, which SDKs are supported, the different types of Cloud Services (PaaS, IaaS, and SaaS), and the differences between a Web Site, Web Role/Cloud Service, and a virtual machine, it’s now time to review the different deployment methods. The next section covers the many options in detail.
The Chapter 6 exercises and examples have steps that walk you through using FTP, GIT, and TFS to deploy the sample ASP.NET MVC 4 project to both an Azure Web Site and a Web Role. There are a few other deployment options, and new ones are added often. A current list of available deployment options include:
Having a source code repository is important for a number of reasons. Primarily, the repository stores and secures source code, which is likely one of the most valuable sources of intellectual property that a company has. Additionally, many source code repositories have version controls that allow you to roll back from one version to another as well as simple comparison tools to see how code changes between different versions. Source code repositories are, thus, a recommended and commonly followed practice. Finally, the source code repository is the location where Release Managers get the final version of a release that’s eventually moved into the production environment for the customers and visitors to use.
The basic steps for integrating the source control with a Cloud Service are as follows:
To integrate source control with an Azure Web Site, you must select a preferred source control repository. You have several options for doing this including Team Foundation Service, CodePlex, and GitHub.
Although this section only covers the CodePlex and Dropbox source code repositories, the principles illustrated in the following sections are the same for the remaining deployment options.
You can use CodePlex to create new projects to share with the world or join others who have already started their own projects. Basic steps follow for integrating your source control with a Windows Azure Web Site utilizing CodePlex.
Like Microsoft’s SkyDrive, after the Dropbox software is installed on your PC, it acts like a mapped drive or folder accessible using Windows Explorer, as illustrated with Figure 5-12. Windows Azure describes this software as follows:
“Dropbox is a free service that lets you bring all your photos, docs, and videos anywhere, and share them easily. Use Windows Azure to quickly sync and deploy your code from your Dropbox folder.”
To configure Dropbox as your source code repository, follow these steps:
The final deployment option discussed in this section is deploying a Web Role using a Service Definition File, Service Configuration File, and a Service Package, all of which are described in Table 5-4.
COMPONENT | DESCRIPTION |
Service Definition File (.csdef) | Defines the service model and number of roles |
Service Configuration File (.cscfg) | An XML based file the provides configuration settings for the Cloud Service, individual roles, and number of role instances |
Service Package (.cspkg) | Contains application code and the Service Definition File |
You have numerous options for moving or replicating your source code to the Windows Azure platform. But remember that a Windows Azure Web Site and Windows Azure Web Role have different features. In addition, some deployment options do not provide source control, but rather only a source code depot for deployment. Depending on the complexity and requirements of your system, you need to assess which deployment option best meets your needs.
You can create both the deployment configuration and package files from Visual Studio 2012 after you install the Windows Azure SDK, using these basic steps:
Most systems require a database to store and manage the capabilities or features that are available for users. The sample ASP.NET MVC 4 Web Role detailed in Chapter 6 requires a relational database that is accessed by NHibernate and uses the Model First approach, where you create the database structure by coding the class files required for implementation. With this approach, instead of the database driving the application, the design and relationship between the classes drives relationships already existing in the database.
However, many systems that you migrate to the Windows Azure platform usually have relational databases or data structures with a significant amount of data stored in them already. The question then becomes, “How do you migrate an existing database to the Windows Azure platform?” One answer is to use the SQL Service Migration Assistant, a free download from the Microsoft Download Center. You then use tool to convert an existing database to a SQL Server hosted on the Windows Azure platform. Numerous database-management system conversions are supported. For example, you can migrate Oracle, MySQL, Sybase, and Access databases to a Windows Azure SQL Server database using this tool.
After you create the structure and schemas of the database, it is recommended that you migrate the majority of your data using the SQL Server Integration Services (SSIS) available. Compared to importing the data directly into tables from a PC or other data source, migrating data using this tool can speed up the process and minimize incurred charges.
Watching the deployment of your code, knowing when it is complete, and monitoring any issues in its deployment are important pieces of information to capture, maintain, and communicate. For large-scale enterprise applications, this type of information is a critical step in the software design life cycle. You need to know that code has deployed to the staging or production environment before you can begin the testing phase, which in turn leads to making go/no-go decisions for a project.
A number of Azure features enable a Release Manager or deployment expert to observe code movement from the source code repository to either a Windows Azure Web Site or Web Role. When the code is ready for deployment, you can then move code to the Production or Staging Windows Azure environment. As discussed in the previous section, the Windows Azure Web Site supports the deployment of code from numerous sources, whereas the Web Role is currently bound to the Team Foundation Server.
The Windows Azure Web Site supports the most deployment methods:
During deployment, the status of synchronization updates as the static files and binaries deploy. When complete, you can test to determine if the code has installed as expected.
Deployment history also provides a list of deployments, containing the number of items changed, identification of which one is the most current and the date when the deployment was made (see Figure 5-17). Deployment history is available when you deploy from a number of repositories — not only Dropbox. For example TFS and GitHub both provide history, while FTP does not. Git and CodePlex have the same features as Dropbox.
In addition to these deployment options, Team Foundation Server (TFS) is available for both the Windows Azure Web Site and Web Role. When you configure the link between TFS and your Windows Azure Web Site or Web Role deployment occurs immediately after you check your code into the TFS source code repository. For example, in the Visual Studio 2012 IDE (which is connected to the same TFS instance bound to the Windows Azure Web Site or Web Role), when you make a code change and check in, shown in Figure 5-18, these changes automatically deploy to either your website or Web Role.
To learn about the many features available for monitoring and managing deployments, you can use the online version of TFS via your Microsoft ID at http://***.visualstudio.com, where *** is the name provided to you when you created your TFS connection with Windows Azure. For example, for a given project, a complete list of currently queued builds, completed builds, and deployed builds are available for real-time and post-mortem analyses.
In this chapter you learned many decision points, capabilities, and limitations for deployment to the Windows Azure platform. You learned under which circumstances certain websites or applications should not be deployed to Windows Azure, primarily based on the incurred cost of the platform. A discussion occurred for SDKs supported on the Windows Azure platform such as PHP, Python, Java, and .NET.
The different Cloud Computing Services such as IaaS, PaaS, and SaaS were discussed as well as the primary differences between a Windows Azure Web Site and Web Role, which is also commonly referred to as a Cloud Service. Data storage options, such as Table Storage and SQL Server database were discussed in addition to how to deploy to them and how to deploy to the website or Web Role using source code repositories such as Git, TFS, Dropbox, or CodePlex. There are also many options for monitoring the deployments in real-time so that testing can begin when complete.
In the following chapter, you can find exercises and examples using many of the concepts discussed in this chapter.