Developing and Extending Applications for Windows Azure with Visual Studio 2010 White Paper Published: February, 2011 Table of Contents Introduction............................................................................................................. 1 A Case for Cloud Computing ...................................................................................... 2 SaaS, IaaS and PaaS ............................................................................................ 3 Introducing Windows Azure ....................................................................................... 5 Hello Cloud! ............................................................................................................. 6 Exploring the Green Fee Broker Sample Application .................................................. 6 Developing for Windows Azure with Visual Studio 2010 ............................................. 7 Deploying to Windows Azure ................................................................................ 14 Conclusion ............................................................................................................. 19 About the Author: ............................................................................................... 20 Appendix ............................................................................................................... 21 Windows Azure Compute Service .......................................................................... 21 Windows Azure Storage ....................................................................................... 22 Security in the Cloud ........................................................................................... 22 Developing and Extending Applications for Windows Azure with Visual Studio 2010 White Paper Published: February, 2011 (style = Published) For the latest information, please see http://msdn.microsoft.com/vstudio Introduction Organizations of all sizes are under increasing pressure to do more with less. Providing solutions that meet these demands while reducing operational costs and maximizing efficiency is not just highly desirable, but has become a necessity. What’s more, providers of information technology solutions are expected to be able to guarantee service delivery while dynamically growing with the needs of the business and at the same time, minimizing costs. This is a difficult proposition. Organizations must be very careful in selecting infrastructure and a platform that delivers both development and operational productivity. These choices must be able to meet both current and future needs of the business. However, planning investments around unpredictable platform and infrastructure costs can be daunting. In response to these challenges is the advent of a disruptive technology known as cloud computing. Wikipedia defines cloud computing as the “natural evolution of the widespread adoption of virtualization, service-oriented architecture and utility computing. Details are abstracted from consumers, who no longer have need for expertise in, or control over, the technology infrastructure ‘in the cloud’ that supports them.” Windows Azure is a Platform as a Service (PaaS) cloud computing offering which forms the bedrock of Microsoft’s Azure Services Platform. PaaS offerings focus on enabling customers to develop, deploy and operate applications without needing to focus on underlying infrastructure or servers or ongoing operations management. Developers write applications for Windows Azure using Microsoft .NET, a comprehensive framework for building desktop, mobile, web and cloud applications and services. While Windows Azure supports several non-Microsoft programming languages including PHP, Java and Ruby, Microsoft .NET offers developers a number of language choices, – the most common being Visual C# and Visual Basic for writing applications in .NET as well as ASP.NET, Microsoft’s premier framework for building web applications. These applications can be written with a simple text editor and command line tools for managing compilation, however, Visual Studio 2010 is the premiere integrated development Developing and Extending Applications for Windows Azure with Visual Studio 2010 1 environment (IDE) for writing .NET applications for deployment both on-premise and in the cloud. A Case for Cloud Computing Estimating and provisioning infrastructure is expensive because it is difficult to predict the elastic needs of an application or service over time. Even when engaging experts to conduct capacity planning, the needs of the business can expand and contract abruptly as demands for products and services are often elastic. The result is that often times, companies are faced with the choice to either go small or go big on their infrastructure purchases. The former introduces the very real risk of service delivery failure, and the latter can be prohibitively expensive. As shown in Figure 1, many companies typically land somewhere in the middle, which means a never ending procurement process and ballooning expenses with server after server seemingly disappearing into a black hole. This is not only a drain on operating budgets from a hardware perspective, but provisioning and deploying servers is time consuming and expensive and detracts from the ability to deploy resources to more tangible revenue generating activities. Figure 1: The perpetual mismatch of supply and demand of IT capacities. Does an organization need to over-invest in platform and infrastructure to ensure that they are able to scale to the ever changing needs of the business? What is the cost of excess capacity that goes unused for any given period of time? Worse, given increasingly aggressive budgets, what are the consequences to brand identity and customer experience when under-investing and introducing the risk of failing to meet the operational needs of the business? Cloud computing is revolutionary because it delivers the consumption of infrastructure, platform and software as a utility, or a service to the masses. Developing and Extending Applications for Windows Azure with Visual Studio 2010 2 With cloud computing, companies who are experts at providing infrastructure, platform and packaged software leverage massive investments in data centers and redundant infrastructure to provide these capabilities as commodity services that your company can consume as needed. Just as with your household utilities, your company extends an application to just “plug in” to the cloud, taking advantage of the massive scale and redundancy for a pre-defined, metered or per-user rate. The result is a much better alignment of IT capacity with the elastic needs of the business as shown in Figure 2. Figure 2: Alignment of capacity with the elastic needs of the business. In this white paper, you’ll learn how to “plug in” to Windows Azure with Visual Studio 2010 by walking through the process of taking an existing application and extending it for the cloud. Before we get started, let’s discuss the three most common ways that cloud providers, including Microsoft package their cloud computing products. SaaS, IaaS and PaaS The promise of cloud is choice, and there are a number of companies that provide a variety of cloud services packaged either as Software as a Service (SaaS), Infrastructure as a Service (IaaS) or Platform as a Service (PaaS) as summarized in Figure 3. Developing and Extending Applications for Windows Azure with Visual Studio 2010 3 Software as a Service (SaaS) is exactly what it sounds like. Companies build commercial software packages and make them easily available on the Internet. SaaS can deliver significant savings to organizations that want to take advantage of packaged offerings such as customer relationship management (CRM) software packages allowing greater access to that software without worrying about “system requirements” or other pre-requisites. Infrastructure as a Service or (IaaS) is a type of cloud service that offers the management, hosting and provisioning of computer infrastructure. Instead of buying physical hardware such as servers and PCs, installing operating systems, racking servers and connecting to networks, users of IaaS merely consume instances of operating systems that are made readily available at their fingertips. While SaaS and IaaS have their place in cloud computing, for many organizations, only highly customized solutions will do. Platform as a Service or (PaaS) abstracts beyond IaaS and provides a platform on which to build custom software enabling organizations to develop, deploy and operate applications without needing to focus on underlying infrastructure or servers or ongoing operations management. With PaaS, you don’t focus on infrastructure at all. You write your applications against a given platform such as .NET and simply deploy your software to a logical container. This eliminates cumbersome deployment chores and simply makes your application available for use at whatever level of scalability and redundancy you require. Microsoft offers businesses and developers the greatest breadth of choice as they engage in cloud computing because they are the only company that delivers across SaaS, IaaS and PaaS product offerings. Microsoft further differentiates itself from Amazon, Google or any other competitor in a fundamental way by providing customers the flexibility to use on-premises technology, cloud technology or both, as part of Microsoft’s software-plus-services (S+S) strategy. In this paper, I will focus your attention on Windows Azure which at its core provides you with the .NET platform as a service (PaaS) on which to build customized and highly dynamic applications at Internet scale. Figure 3: Common products offered by cloud providers. Developing and Extending Applications for Windows Azure with Visual Studio 2010 4 Introducing Windows Azure Windows Azure is Microsoft’s operating system for the cloud and forms the bedrock of Microsoft’s Windows Azure Platform. As a PaaS offering, Windows Azure abstracts the details of hosting, runtime components and management which helps you focus your time and resources on building software that delivers business value. In addition to providing an operating system for the cloud, the Windows Azure Platform provides additional cloud products including AppFabric, SQL Azure, CDN and MarketPlace. Each of these technologies enrich the development experience and reach of applications deployed in Windows Azure, the enterprise, on premise, in the cloud, or any combination thereof. AppFabric is an integrated set of services for hosting, managing, connecting and securing your applications and third-party applications that are deployed both on-premise or in the cloud. It allows you to connect and scale your applications whether they run on-premise, in the cloud or both. SQL Azure is a cloud-based relational database service (RDBMS) built on SQL Server technologies. It provides many of the capabilities of SQL Server with the ease of being hosted by Microsoft in the cloud. With SQL Azure, you just point your application to the database and SQL Azure takes care of the rest. CDN is a Content Delivery Network that geographically distributes copies of frequently used data such as files, images, and videos so that they are as close as possible to users of your applications that consume this media. This helps ensure that the content your application needs can be accessed as quickly as possible. Marketplace provides one-stop-shopping for discovering data feeds and other applications that can be used to bring your applications to market more quickly and easily. For example, DataMarket provides data feeds that you can integrate with your application, saving you the time and expense of building or finding this data on your own. While there are many exciting and useful features in the Windows Azure Platform, this paper will focus on gaining a better understanding of Windows Azure and how easy it is to build new and extend existing applications for Windows Azure with Visual Studio 2010. You’ll learn how together they provide a development, run time, and management environment that supports the ability to develop, deploy and run your applications at Internet-scale. To learn more about the Windows Azure Compute Service, Windows Azure Storage and Security in the Cloud, refer to the appendix of this paper. Developing and Extending Applications for Windows Azure with Visual Studio 2010 5 Hello Cloud! Exploring the Green Fee Broker Sample Application Let’s start by exploring a start-up company who has recently begun experiencing growing pains. Green Fee Broker allows golfers to play their favorite courses at the lowest possible rate. Golfers install the “My Green Fee Broker” application on their smart phone, pick from a list of participating golf courses, and subscribe to alerts when a registered course publishes an available tee time. If a golfer is interested in submitting a booking offer, they can either submit an offer directly from their smart phone, or login to My Green Fee Broker Online, a website that also provides the ability to submit a booking request to the Green Fee Broker Service from any PC. From there, Green Fee Broker Service goes to work to search for the lowest possible published rate available, books the course, and notifies the golfer of his or her tee time via a smart phone alert and/or an e-mail notification. The great thing about the Green Fee Broker Service is that it is always available. It exposes a web service API that can be consumed either by the My Green Fee Broker smart phone application orGreen Fee Broker online (as well as branded Web properties for specific golf courses) which allow golfers to use the Green Fee Broker Service API to submit a booking request on-demand or in response to a smart phone alert. However, the greatest strength of this product is quickly becoming its biggest liability. The success of marketing campaigns and word of mouth has really put a strain on the company’s ability to ensure that core engine that exposes the API for managing customer requests and enrolling new customers remains available – the volume of traffic to the Green Fee Broker Service API has simply outpaced the abilities of the current infrastructure and the occasional application crashes threatens the brand that the start-up has worked so hard to build. Realizing that adding more and more servers, and dealing with the complexities of configuring web farms and clusters is simply not an option, the company looks to the cloud for a solution. One option would be to move the Green Fee Broker Service from the on-premise facility to an IaaS provider. While this is certainly a more attractive option than the current situation, installing all of the requisite platform components and deploying the service to multiple hosted instances really takes away from the focus of Green Fee Broker which is to simply always be available. Moreover, the time and expense managing each of the instances independently could be better re-deployed to activities that enhance the product directly. After some internal discussion, the development management team decides that Green Fee Broker Service API is perfect for deployment to Windows Azure. At its core is a brokering engine that is exposed as a web service over HTTP to any number of consumers who leverage the API and the Broker Service must not only Developing and Extending Applications for Windows Azure with Visual Studio 2010 6 be always available, but be able to scale to the increasing demands of this successful start-up. Rather than continuing to fall into the staircase trap depicted in Figure 1, Windows Azure provides Green Fee Broker with the tools to align capacity with the precise needs of its customers as originally discussed in Figure 2. Since the team is already writing applications on the .NET Framework, the learning curve is minimal and they get to leverage the tools and skills they already have with little to no changes to the code. In addition, Windows Azure does not require big expenditures up front, so capital expenses can be converted to operational expenses. Since the start-up must only pay for what they use, they gain the flexibility and ability to test new ideas without having to make big, up-front investments in infrastructure which fuels innovation. All of these benefits of Windows Azure allow the company to focus on building and innovating on the product on the same platform and with the same tools they’d build any other applications for .NET. Developing for Windows Azure with Visual Studio 2010 Visual Studio is an integrated development environment (IDE) for developing applications on Microsoft’s .NET Framework. Visual Studio 2010 provides a premier toolset for developing, testing, and maintaining applications for both onpremise deployment and the cloud. I’ll show you how to extend an existing application for deployment to Windows Azure with Visual Studio by adding a Windows Azure Project and associating it with a web role. I’ll then demonstrate how simple Visual Studio 2010 makes testing a cloud application locally and packaging it for deployment to Windows Azure. Exploring the Green Fee Broker Service The Green Fee Broker Service is a web service written with Windows Communication Foundation (WCF). WCF is a messaging framework that is part of the .NET Framework that allows you to share modular units of functionality called classes with other applications by exposing these classes with special functions known as operations. These operations can be executed by applications on the same machine, by different machines in the same network or on machines on completely different networks altogether. The Green Fee Broker Service exposes key functionality over HTTP including operations for registering a new golf course, retrieving a list of participating golf courses and allowing golf courses to publish available tee times. Visual Studio organizes classes into special containers called projects, which are in turn grouped into a special container called a solution. A solution can have one or more projects which includes one or more classes. After you’ve written code inside classes, you build a solution which conducts a series of verifications to ensure that the code you’ve written is valid and follows the rules of the language. If all goes well, each project will be packaged into an assembly which can then Developing and Extending Applications for Windows Azure with Visual Studio 2010 7 either be executed directly or called by a different assembly that is part of a project (in the case of a web service, a client sends messages to the assembly over a communication channel to execute it). Inside the GreenFeeBroker solution is a Visual Studio 2010 project called “BookingService”. In this case, the “BookingService” project uses the WCF Web Application Template which provides the basic files for building a WCF web service. In its simplest form, the WCF Web Application project consists of two files as shown in Figure 4: BrokerService.svc contains the implementation of the operations mentioned above. Web.config contains basic configuration for hosting the web service. Figure 4: The Broker Service project in Visual Studio 2010 Solution Explorer. The Green Fee Broker service exposes its functionality using SOAP over the HTTP protocol. SOAP makes it possible to use familiar object-oriented techniques when developing the service and automates the means by which the service exchanges and processes XML messages over the Internet. It would be tempting to write the code that implements the BrokerService operations directly in the BrokerService.svc file, however, the Green Fee Broker application was developed with separation of concerns in mind such that each unit of functionality is independent of the other but work together to get a job done. As such, the project contains additional classes which define a golf course (the “Course” class), isolate business rules for working with courses into a class called Developing and Extending Applications for Windows Azure with Visual Studio 2010 8 “CourseManager” and group all data operations into a common class called “DataServiceAgent”. Separation of concerns is an important design principle when developing for both on-premise and cloud because it allows you to focus on slices of functionality and makes for software that is easy to understand and maintain. What’s more, when developing applications that will run both on premise and/or in the cloud, the ability to manage state and make deployment decisions is significantly simplified by mapping logical layers onto physical tiers as with web roles, worker roles and storage services. Extending the Green Fee Broker Service for the Cloud Creating new applications and services for Windows Azure with Visual Studio 2010 is very simple. Believe it or not, since the service was written in .NET with Visual Studio for on-premise hosting, with the exception of a little configuration, it is already ready to be hosted in Windows Azure. To demonstrate this, let’s take the existing Green Fee Broker application and enable it for Windows Azure1. Creating a Windows Azure Project The first thing you will do when developing or extending an application for Windows Azure is add a Windows Azure Project to your Visual Studio 2010 solution. Just as the WCF Service Application template provides everything you need for creating a WCF web service, the Windows Azure Project template provides the container and configuration required to package a common Visual Studio 2010 solution for Windows Azure. To get started simply add a new Windows Azure Project to the GreenFeeBroker solution, provide a name for the project, and click OK (Figure 5). 1 In addition to Visual Studio 2010, you must install the Windows Azure Tools for Microsoft Visual Studio version 1.3 which includes the Software Development Kit (SDK) and is available here: http://msdn.microsoft.com/windowsazure/cc974146.aspx. If you are running a 32-bit version of Windows 7, or are running Windows Vista or Windows Server 2008, there are some hotfixes you will want to install as well. Developing and Extending Applications for Windows Azure with Visual Studio 2010 9 Figure 5: Adding a Windows Azure Project in Visual Studio 2010 Visual Studio 2010 presents you with a list of roles that will tailor the template to the kind of application you are building. In this case, since we want to enable the BrokerService for Windows Azure we’ll choose the WCF Service web role as shown in Figure 6. Figure 6: Choosing the WCF Service web role. The Windows Azure Project makes it simple to configure the BrokerService project for Windows Azure by providing a user interface for associating projects with a role. You can simply right-click on the Roles icon to select an existing project or create a new one after which the project you added will be associated with the role as shown in Figure 7. Developing and Extending Applications for Windows Azure with Visual Studio 2010 10 Figure 7: The result of associating a new or existing project to a Windows Azure Project. To make working with the solution as easy as possible, right-click the GreenFeeBroker.Cloud project and select “Set as Start Up Project.” This ensures that when you test your application locally, the project is initialized correctly in the Development Fabric (which is covered shortly). There are a number of configuration options when deploying your application or service to Windows Azure and you can set these options by right-clicking on the associated role (in this case the BrokerService shown in Figure 7) and selecting properties. The most common settings include how many instances you would like Windows Azure to allocate for you upon deploying your application as well as the size of the virtual machine your deployment will target. These choices are among the most important because they will have a direct effect on application performance, availability, scalability and cost. Figure 8 shows various configuration options including the type of virtual machine you want to use and the number of instances you’d like Windows Azure to allocate to your application. In this case, I’ve configured 4 Small instances. Don’t worry if you aren’t sure what settings to choose at first. As you learn more, chances are your needs can and will change and the nice thing about Windows Azure is that you can change your mind! Developing and Extending Applications for Windows Azure with Visual Studio 2010 11 Figure 8: Windows Azure web role configuration options. The Settings tab allows you to set configuration string/value pairs for things like database connections, paths for logging, etc. Visual Studio 2010 provides a great development experience by allowing you to set up configurations for both testing locally and running in the cloud. Local Testing with the Development Fabric Visual Studio 2010 provides full application lifecycle management capabilities for applications designed to run both on-premise and in the cloud. When developing applications for Windows Azure, the development lifecycle is consistent with best practices for Application Lifecycle Management (ALM). As shown in Figure 9, you develop and test locally with Visual Studio 2010 and development run-time tools for emulating both Compute and Storage. You then deploy to a staging environment provided in the cloud by Windows Azure where you perform testing before finally pushing your application or service to production. Figure 9: Windows Azure Application Lifecycle Management. Developing and Extending Applications for Windows Azure with Visual Studio 2010 12 Visual Studio 2010, together with the Windows Azure SDK, includes a package for doing local development, testing and debugging called the Development Fabric. The Development Fabric consists of two main components: the Compute Emulator and the Storage Emulator. The Compute Emulator allows you to build, deploy and test your applications for Windows Azure in your local development environment. You might think of the Compute Emulator as the equivalent of the web hosting capabilities inside Visual Studio that provides an Azure hosting and debugging experience that emulates IIS. Visual Studio provides a seamless development, testing and debugging experience that allows you to interact with your application running in the Compute Emulator directly from within the IDE. For simulating the storage service, the Windows Azure SDK includes a storage service emulator intended for local development and testing called the Storage Emulator. The Storage Emulator provides a development experience that is identical to working directly with Azure storage at the API level. When working locally, Visual Studio will automatically provision local storage for you using any recent version of Microsoft SQL Server including SQL Server Express Edition. This allows you to write code that uses the same storage APIs regardless of whether the code is running locally or in the cloud. However, please be aware that the Storage Emulator is for development purposes only and should never be used for production scenarios. In fact, with Visual Studio 2010, interacting with the Development Fabric is simply a matter of running your application from the IDE! When you start your solution within Visual Studio 2010, you will notice some feedback in the lower left-hand corner of the IDE indicating that Visual Studio is both packaging and deploying your application to the Development Fabric including application code to the Compute Emulator and table, blob or queue instructions to the Storage Emulator (please refer to the appendix for more information on the Windows Azure storage service). At this point, the application is hosted and ready for testing. Visual Studio 2010 will automatically open a browser window with the base address of your application or service and put the application into debug mode which allows you to interact with the application and conduct any troubleshooting with the code in an interactive manner. In addition, any instructions for creating tables, blobs or queues will be executed. These instructions can be placed in a global file which will allow for the code to be executed during various stages of the application lifecycle including start up. To see the active deployment, look for the Windows Azure icon in your task taskbar, right-click it and select “Show Compute Emulator UI”. Developing and Extending Applications for Windows Azure with Visual Studio 2010 13 The Windows Azure Compute Emulator UI provides visibility into the application’s status and health. You can start and stop the application as well as continue to monitor it visually. Notice in Figure 10 that there are four virtual instances of the application, just as we selected when we configured the BrokerService Windows Azure Project. Figure 10: The Windows Azure Compute Emulator UI. At this point, with the BrokerService hosted, you can test it as you normally would and make any modifications necessary before deploying to Windows Azure. Deploying to Windows Azure Once you have developed and tested your application locally, you are ready to deploy to Windows Azure! Packaging Your Application with Visual Studio 2010 The first step to deploying your application to Windows Azure is to create a deployment package. Visual Studio 2010 simplifies this process by automating the creation of the package for you when you right-click on the Windows Azure project and select “Publish.” As shown in Figure 11, you can choose from two approaches: Create Service Package Only. This creates a package file containing your application and a configuration file containing all the settings that you Developing and Extending Applications for Windows Azure with Visual Studio 2010 14 specified for provisioning, deploying and running your application. You can then upload your package via the Windows Azure Management Portal. Deploy Your Windows Package to Windows Azure. This automates packaging and deploying your application into one easy step. The second option requires that an X.509 certificate be installed on the local development machine and uploaded to the Windows Azure Management Portal to ensure that only authorized packages are being deployed. Figure 11: Windows Azure packaging and deployment in Visual Studio 2010. I’ll show you how to deploy your application using the first method to give you some familiarity with the Windows Azure Management Portal. As you gain experience with setting up and managing Windows Azure deployments, the fully integrated deployment experience that the second option provides within Visual Studio will become useful, particularly when re-deploying existing applications or services. To package your solution, click OK and you will instantly see Windows Explorer open to the location of the package that Visual Studio 2010 created. Figure 12 shows the two files that are created. Developing and Extending Applications for Windows Azure with Visual Studio 2010 15 Figure 12: Service Package and Configuration files for deployment. Deploying Your Application via the Windows Azure Management Portal The Windows Azure Management Portal provides everything you need to manage your Windows Azure Platform services, including compute roles, storage, CDN, AppFabric and Marketplace services. When you log into the portal (provided you’ve set up a Windows Azure account),you will have the option to create a new Hosted Service and a new Hosted Storage Account. These options allow you to define a compute and storage deployment, which you must do before you deploy your application and corresponding storage requirements to Windows Azure. The process for deploying an application or service to stage or production is identical, and you must choose one of the two when first deploying your application to Windows Azure. To deploy the BrokerService, after clicking on “New Hosted Service” as shown in Figure 13, a window appears which you populate in order to prepare the hosting environment. After you select a subscription account, you provide a name for the service that you’ll use to easily identify the application in the Windows Azure Management Portal. You also must specify a unique URL prefix as this will become part of the fully qualified URL that will be used to access your application or service, in this case the BrokerService WCF web service. Developing and Extending Applications for Windows Azure with Visual Studio 2010 16 Figure 13: Windows Azure Management Portal New Hosted Service provisioning. You will also notice the ability to select affinity groups, which allow you to make explicit requests for where your Compute and Storage applications will be located. For example, since the Windows Azure data centers are geographically distributed worldwide, to optimize performance it may be a good idea to ensure that your application hosted in Compute is as close to your data hosted in Storage as possible. Affinity groups are the tool for accomplishing this. Deployment options include whether you want to deploy your application to the stage environment, the production environment, or not at all. Keep in mind that you will be billed the same regardless of whether you choose stage or production. The main benefit of having two environments is the ability to test a version of an application before it is live in production, and this is particularly useful when testing two versions of an application side by side. You can select anything you’d like for the Deployment name, but I recommend adopting a simple versioning standard that you can use as a label. This will make it easy to identify and track and recognize the different versions of your applications and services as you move them from stage to production. Lastly, providing the path to the package and configuration files that Visual Studio created for you by clicking “Browse Locally…” and clicking OK will begin the deployment and provisioning process. The management experience that is created based on your choices will show you that four instances of compute (in this case, 4 “Small” VMs) are being allocated for v1 of the BrokerService. The status of each instance will cycle through waiting, creating, and starting the compute instances that will host the Developing and Extending Applications for Windows Azure with Visual Studio 2010 17 application. This takes a few minutes, however when you consider how long it would take to get four traditional servers or virtual machines up and running in a load balanced environment and fully deployed with your application, the speed and ease of accomplishing this with just a few simple clicks is quite remarkable! As shown in Figure 14, when all instances are ready the logical service will show a status of Ready. Clicking on the label will provide metadata about the deployment including the date created, number of instances allocated, along with the DNS name to the publically available URI which provides a single logical load balanced endpoint to the BrokerService. Figure 14: The BrokerService ready for consumption. Testing in Windows Azure At this point, you can test the service just as you would in a traditional onpremise testing environment. To browse to the service, simply click on the DNS name shown in Figure 14 which will launch your browser. Add the BrokerService.svc file name at the end of the URL in the address bar and you should see a hosting page appear indicating that the service is ready to be consumed. I always recommend conducting postdeployment verification testing or “smoke testing” to ensure that the service is hosted properly and able to perform common, routine functions. You can use the WCF Test Client that ships with Visual Studio 2010 to test the service in Windows Azure staging or production just as you would locally against the Storage Emulator. Developing and Extending Applications for Windows Azure with Visual Studio 2010 18 Promoting to Production in Windows Azure Once you’ve deployed your application to Windows Azure, you can instantly deploy your application to production by selecting the “Swap VIP” option in the Azure Management Portal. If you don’t have an active production deployment, then your staging deployment will be promoted to production. From this point on, you can use the production URL, in this case http://brokerservice.cloudapp.net. Managing Your Application in Windows Azure You will use the Windows Azure Management Portal not only for deploying, but also for managing your Windows Azure applications and services. When you are ready to deploy a new version of the application, you can follow the same steps outlined above which will result in a different version deployed to physically separate nodes in the stage environment. You can also upgrade a currently running application by uploading a newer version of the package or configuration, and you can also choose to simply update the configuration file, leaving the package or application code intact. In addition, you can provision storage services including table, blob and queue from the same management portal. In fact, while details on storage services are beyond the scope of this white paper, the BrokerService sample application makes extensive use of table storage for storing new golf course descriptions and for retuning a list of all golf courses in the store. A storage account has been created for the BrokerService application called “GreenFeeBrokerTable” and the REST endpoints for accessing the table, queue and blob storage services are provided just as with the local Storage Emulator. Conclusion Organizations of all sizes stand to benefit from cloud computing. Windows Azure provides Platform as a Service capabilities that allow developers to leverage the ease and productivity of Microsoft .NET, and Visual Studio 2010 provides a premier development environment for developing applications both on premise and in the cloud. Together, Windows Azure and Visual Studio 2010 provide a powerful value proposition for building new applications while extending existing applications to take advantage of the cloud, making the development, testing and management of hybrid applications virtually seamless. Developing and Extending Applications for Windows Azure with Visual Studio 2010 19 About the Author: Rick G. Garibay is the General Manager of the Connected Systems Development practice at Neudesic. Rick is a Microsoft MVP, speaker and author focused on connected technologies such as SOA and hybrid composite solutions. This paper is derived from an article originally printed in CODE Magazine and is used with permission of the publisher, EPS Software Corporation. This white paper was developed in partnership with A23 Consulting. For more information: http://www.microsoft.com/visualstudio Developing and Extending Applications for Windows Azure with Visual Studio 2010 20 Appendix Windows Azure Compute Service The Compute Service is a logical container for any number of Windows Server virtual machines that host your application. The Compute Service uses load balancers which ensure that requests for your application are always routed to an available virtual machine instance (provided multiple instances have been configured). The Compute Service is partitioned into two roles: web role and worker role. Each role has affinity to a virtual machine; however, an application in each role is never aware of what physical machine or logical virtual machine it is running on. When designing an application for Windows Azure, your application must target either the web role or worker role, and it can also be partitioned and distributed to take advantage of both. Web Role You can think of a web role as a container for web applications that you would deploy to a web server. In Windows Azure, an application designed for the web role runs on Microsoft’s flagship web server, Internet Information Services (IIS) which provides a premiere hosting environment for both .NET and non-.NET applications and services. Applications deployed to a web role can accept HTTP and HTTPS requests from outside of the Microsoft data center network (i.e., your desktop or your customer’s server in their own data center). As such, it is somewhat equivalent to an on-premise DMZ (or demilitarized zone). Worker Role A worker role can only accept input from another application inside of Windows Azure and accepts requests via a Windows Azure storage feature called Queue Storage. A worker role equates to the same way you might think about an application server in a traditional on-premise data center which may run a series of middleware services that do heavy, long-running work in the background, ensuring that the user experience of your front-end application is not affected. Of course, you may choose to design your logical application taking a layered approach which includes both roles and this is an excellent pattern if you want to provide optimal scalability by supporting background, asynchronous work that does not consume resources in the web role application. In this white paper, however, I will focus on developing an application exposed as a web service deployed to a web role. Developing and Extending Applications for Windows Azure with Visual Studio 2010 21 Windows Azure Storage Just as with on-premise applications, for software to be useful, it must be able to save and retrieve information across a variety of media types including text or strings, objects, and files such as images, documents, music or video. The storage service provides three key options for enabling your applications to store and interact with data and resemble traditional storage mechanisms you may be used to when writing software on-premise. Table storage allows developers to model their conceptual schema using .NET entities without regard to the underlying logical storage technology. The Table storage service is exposed using an architectural style known as REST which provides the ability to insert, update, delete and read records within tables deployed to Table storage. Although this is different than common relational approaches to data storage and manipulation, it provides a simple alternative to other options such as Microsoft SQL Azure. Blob storage allows you to store data in binary form, which is ideal for media types such as images, files or trees. You can think of Blob storage as a file system for Windows Azure. Queue storage provides queue-based messaging between applications and roles. Queues are very common in distributed software design as they provide both a means for processing jobs in the order the jobs are created as well as durabilty for ensuring that jobs or messages are not lost before they can be processed. Security in the Cloud Security is a very broad topic, yet eminently important to anyone adopting cloud computing. Microsoft takes great care in ensuring the security of their datacenters and servers and puts you in control of applying the necessary security requirements in your applications. Since you are targeting the same platform (Windows and .NET) both on-premise and in the cloud, you use the same tools and techniques for identifying the users of your application (authentication) and deciding what privileges they have (authorization). You can also encrypt and digitally sign your data as necessary just as you would on-premise. In addition, Microsoft provides a service known as the Access Control Service (ACS) which allows you to take advantage of claimbased security, which greatly simplifies the process of authenticating and authorizing users of your applications and takes advantage of a variety of identity providers including Windows Active Directory, Windows Live, and FaceBook. For more information on security scenarios in Windows Azure, please see the Patterns and Practices site dedicated Windows Azure Security: http://azuresecurity.codeplex.com/. Developing and Extending Applications for Windows Azure with Visual Studio 2010 22 ©2011 Microsoft Corporation. All rights reserved. This document is provided “as-is.” Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it. This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes. Developing and Extending Applications for Windows Azure with Visual Studio 2010 23