Developing and Extending Applications for Windows Azure With Visual Studio Final

Embed Size (px)

Citation preview

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    1/25

    Developing and Extending Applicationsfor Windows Azure with Visual Studio2010White Paper

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    2/25

    Published: February, 2011

    Table of Contents

    Introduction ............................................................................................................. 1A Case for Cloud Computing ...................................................................................... 2

    SaaS, IaaS and PaaS ............................................................................................ 3

    Introducing Windows Azure ....................................................................................... 5Hello Cloud! ............................................................................................................. 6

    Exploring the Green Fee Broker Sample Application .................................................. 6Developing for Windows Azure with Visual Studio 2010 ............................................. 7Deploying to Windows Azure ................................................................................ 14

    Conclusion ............................................................................................................. 19About the Author: ............................................................................................... 20

    Appendix ............................................................................................................... 21Windows Azure Compute Service .......................................................................... 21Windows Azure Storage ....................................................................................... 22Security in the Cloud ........................................................................................... 22

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    3/25

    Developing and Extending Applications for Windows Azure with Visual Studio 20101

    Developing and Extending Applicationsfor Windows Azure with Visual Studio2010White 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.

    Whats more, providers of information technology solutions are expected to beable to guarantee service delivery while dynamically growing with the needs ofthe business and at the same time, minimizing costs.

    This is a difficult proposition. Organizations must be very careful in selectinginfrastructure 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 platformand 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 thenatural evolution ofthe 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 cloudthatsupports them.

    Windows Azure is a Platform as a Service (PaaS) cloud computing offering which

    forms the bedrock of Microsofts Azure Services Platform. PaaS offerings focus onenabling 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 cloudapplications and services. While Windows Azure supports several non-Microsoft

    programming languages including PHP, Java and Ruby, Microsoft .NET offersdevelopers a number of language choices, the most common being Visual C#and Visual Basic for writing applications in .NET as well as ASP.NET, Microsofts

    premier framework for building web applications. These applications can be

    written with a simple text editor and command line tools for managingcompilation, however, Visual Studio 2010 is the premiere integrated development

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    4/25

    Developing and Extending Applications for Windows Azure with Visual Studio 20102

    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 whenengaging experts to conduct capacity planning, the needs of the business canexpand and contract abruptly as demands for products and services are often

    elastic. The result is that often times, companies are faced with the choice toeither 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 prohibitivelyexpensive.

    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 adrain on operating budgets from a hardware perspective, but provisioning and

    deploying servers is time consuming and expensive and detracts from the abilityto 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 ensurethat they are able to scale to the ever changing needs of the business? What isthe 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 riskof 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.

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    5/25

    Developing and Extending Applications for Windows Azure with Visual Studio 20103

    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 servicesthat your company can consume as needed. Just as with your household utilities,

    your company extends an application tojust plug in to the cloud, takingadvantage 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 elasticneeds of the business as shown in Figure 2.

    Figure 2: Alignment of capacity with the elastic needs of the business.

    In this white paper, youll learnhow to plug in to Windows Azure with VisualStudio 2010 by walking through the process of taking an existing application andextending it for the cloud.

    Before we get started, lets 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 providea 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.

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    6/25

    Developing and Extending Applications for Windows Azure with Visual Studio 20104

    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 advantageof packaged offerings such as customer relationship management (CRM) software

    packages allowing greater access to that software without worrying aboutsystem 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 ofbuying 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) abstractsbeyond IaaS and provides a platform on which to build custom software enablingorganizations to develop, deploy and operate applications without needing to

    focus on underlying infrastructure or servers or ongoing operations management.

    With PaaS, you dont 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 simplymakes your application available for use at whatever level of scalability andredundancy you require.

    Microsoft offers businesses and developers the greatest breadth of choice as theyengage 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 byproviding customers the flexibility to use on-premises technology, cloud

    technology or both, as part of Microsofts 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 buildcustomized and highly dynamic applications at Internet scale.

    Figure 3: Common products offered by cloud providers.

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    7/25

    Developing and Extending Applications for Windows Azure with Visual Studio 20105

    Introducing Windows Azure

    Windows Azure is Microsofts operating system for the cloud and forms the

    bedrock of Microsofts Windows Azure Platform. As a PaaS offering, Windows

    Azure abstracts the details of hosting, runtime components and managementwhich 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 AzurePlatform 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.

    AppFabricis 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.

    CDNis 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. Youll learn how together they provide a development, runtime, and management environment that supports the ability to develop, deployand 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.

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    8/25

    Developing and Extending Applications for Windows Azure with Visual Studio 20106

    Hello Cloud!

    Exploring the Green Fee Broker Sample Application

    Lets start by exploring a start-up company who has recently begun experiencinggrowing pains.

    Green Fee Broker allows golfers to play their favorite courses at the lowestpossible rate. Golfers install theMy Green Fee Brokerapplication 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 insubmitting a booking offer, they can either submit an offer directly from theirsmart 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 lowestpossible 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 FeeBroker smart phone application orGreen Fee Broker online (as well as branded

    Web properties for specific golf courses) which allow golfers to use the Green FeeBroker Service APIto submit a booking request on-demand or in response to asmart 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 astrain on the companys 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 APIhas simply outpaced the

    abilities of the current infrastructure and the occasional application crashesthreatens 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 cloudfor a solution.

    One option would be to move the Green Fee Broker Service from the on-premisefacility 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 thefocus of Green Fee Broker which is to simply always be available. Moreover, thetime 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 thatGreen Fee Broker Service APIis 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

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    9/25

    Developing and Extending Applications for Windows Azure with Visual Studio 20107

    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 aligncapacity 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 theyalready have with little to no changes to the code.

    In addition, Windows Azure does not require big expenditures up front, so capitalexpenses 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 fuelsinnovation. 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 sametools theyd 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 Microsofts .NET Framework. Visual Studio 2010 provides a

    premier toolset for developing, testing, and maintaining applications for both on-premise deployment and the cloud. Ill 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. Ill then demonstratehow 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 WindowsCommunication 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 functionsknown as operations. These operations can be executed by applications on thesame machine, by different machines in the same network or on machines on

    completely different networks altogether. The Green Fee Broker Service exposeskey 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 arein turn grouped into a special container called a solution. A solution can have oneor more projects which includes one or more classes. After youve written code

    inside classes, you build a solution which conducts a series of verifications toensure that the code youve 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

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    10/25

    Developing and Extending Applications for Windows Azure with Visual Studio 20108

    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 WebApplication Template which provides the basic files for building a WCF web

    service. In its simplest form, the WCF Web Application project consists of two filesas shown in Figure 4:

    BrokerService.svccontains the implementation of the operationsmentioned 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 HTTPprotocol. SOAP makes it possible to use familiar object-oriented techniques when

    developing the service and automates the means by which the service exchangesand processes XML messages over the Internet.

    It would be tempting to write the code that implements the BrokerServiceoperations directly in the BrokerService.svc file, however, the Green Fee Broker

    application was developed with separation of concerns in mind such that each unitof 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 (theCourse class), isolate business rules for working with courses into a class called

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    11/25

    Developing and Extending Applications for Windows Azure with Visual Studio 20109

    CourseManager and group all data operations into a common class called

    DataServiceAgent.

    Separation of concerns is an important design principle when developing for bothon-premise and cloud because it allows you to focus on slices of functionality and

    makes for software that is easy to understand and maintain. Whats more, whendeveloping applications that will run both on premise and/or in the cloud, the

    ability to manage state and make deployment decisions is significantly simplifiedby mapping logical layers onto physical tiers as with web roles, worker roles andstorage services.

    Extending the Green Fee Broker Service for the Cloud

    Creating new applications and services for Windows Azure with Visual Studio 2010is very simple. Believe it or not, since the service was written in .NET with VisualStudio for on-premise hosting, with the exception of a little configuration, it is

    already ready to be hosted in Windows Azure.

    To demonstrate this, lets 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 2010solution. Just as the WCF Service Application template provides everything you

    need for creating a WCF web service, the Windows Azure Project templateprovides the container and configuration required to package a common VisualStudio 2010 solution for Windows Azure. To get started simply add a new

    Windows Azure Project to the GreenFeeBroker solution, provide a name for theproject, and click OK (Figure 5).

    1In addition to Visual Studio 2010, you must install the Windows Azure Tools for Microsoft Visual Studio version 1.3 which includes theSoftware 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 aswell.

    http://msdn.microsoft.com/windowsazure/cc974146.aspxhttp://msdn.microsoft.com/windowsazure/cc974146.aspxhttp://msdn.microsoft.com/windowsazure/cc974146.aspx
  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    12/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201010

    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 well choose the WCF Service web role as shownin Figure 6.

    Figure 6: Choosing the WCF Service web role.

    The Windows Azure Project makes it simple to configure the BrokerService projectfor 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 therole as shown in Figure 7.

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    13/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201011

    Figure 7: The result of associating a new or existing project to a Windows AzureProject.

    To make working with the solution as easy as possible, right-click theGreenFeeBroker.Cloud project and select Set as Start Up Project. This ensuresthat 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 theassociated role (in this case the BrokerService shown in Figure 7) and selecting

    properties.

    The most common settings include how many instances you would like WindowsAzure to allocate for you upon deploying your application as well as the size of thevirtual 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 machineyou want to use and the number of instances youd like Windows Azure to

    allocate to your application. In this case, Ive configured 4 Small instances. Dontworry if you arent 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!

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    14/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201012

    Figure 8: Windows Azure web role configuration options.

    The Settings tab allows you to set configuration string/value pairs for things likedatabase connections, paths for logging, etc. Visual Studio 2010 provides a great

    development experience by allowing you to set up configurations for both testinglocally and running in the cloud.

    Local Testing with the Development Fabric

    Visual Studio 2010 provides full application lifecycle management capabilities forapplications designed to run both on-premise and in the cloud. When developingapplications 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 thendeploy to a staging environment provided in the cloud by Windows Azure where

    you perform testing before finally pushing your application or service toproduction.

    Figure 9: Windows Azure Application Lifecycle Management.

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    15/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201013

    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 theCompute Emulator as the equivalent of the web hosting capabilities inside VisualStudio that provides an Azure hosting and debugging experience that emulates

    IIS. Visual Studio provides a seamless development, testing and debuggingexperience that allows you to interact with your application running in theCompute 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 StorageEmulator. The Storage Emulator provides a development experience that is

    identical to working directly with Azure storage at the API level. When workinglocally, Visual Studio will automatically provision local storage for you using anyrecent version of Microsoft SQL Server including SQL Server Express Edition. This

    allows you to write code that uses the same storage APIs regardless of whetherthe 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 forproduction scenarios.

    In fact, with Visual Studio 2010, interacting with the Development Fabric is simplya 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 isboth 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 moreinformation on the Windows Azure storage service).

    At this point, the application is hosted and ready for testing. Visual Studio 2010will automatically open a browser window with the base address of yourapplication 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 beexecuted 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 selectShow Compute Emulator UI.

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    16/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201014

    The Windows Azure Compute Emulator UI provides visibility into the applications

    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 theapplication, 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 normallywould 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 2010The first step to deploying your application to Windows Azure is to create a

    deployment package. Visual Studio 2010 simplifies this process by automating thecreation 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 twoapproaches:

    Create Service Package Only. This creates a package file containing your

    application and a configuration file containing all the settings that you

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    17/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201015

    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 packagingand 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 toensure that only authorized packages are being deployed.

    Figure 11: Windows Azure packaging and deployment in Visual Studio 2010.

    Ill show you how to deploy your application using the first method to give you

    some familiarity with the Windows Azure Management Portal. As you gainexperience with setting up and managing Windows Azure deployments, the fullyintegrated 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 Exploreropen to the location of the package that Visual Studio 2010 created. Figure 12shows the two files that are created.

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    18/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201016

    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 youve set up a Windows Azure

    account),you will have the option to create a new Hosted Service and a newHosted Storage Account. These options allow you to define a compute andstorage 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 hostingenvironment. After you select a subscription account, you provide a name for theservice that youll 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 orservice, in this case the BrokerService WCF web service.

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    19/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201017

    Figure 13: Windows Azure Management Portal New Hosted Service provisioning.

    You will also notice the ability to select affinity groups, which allow you to makeexplicit requests for where your Compute and Storage applications will be located.

    For example, since the Windows Azure data centers are geographically distributedworldwide, to optimize performance it may be a good idea to ensure that yourapplication 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 thestage 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 anapplication before it is live in production, and this is particularly useful whentesting two versions of an application side by side.

    You can select anything youd like for the Deployment name, but I recommendadopting 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 Locallyand 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 allocatedfor v1 of the BrokerService. The status of each instance will cycle through

    waiting, creating, and starting the compute instances that will host the

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    20/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201018

    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 speedand 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 astatus of Ready. Clicking on the label will provide metadata about the deployment

    including the date created, number of instances allocated, along with the DNSname to the publically available URI which provides a single logical load balancedendpoint 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 on-premise 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 theURL in the address bar and you should see a hosting page appear indicating thatthe service is ready to be consumed. I always recommend conducting post-

    deployment verification testing or smoke testing to ensure that the service ishosted properly and able to perform common, routine functions.

    You can use the WCF Test Client that ships with Visual Studio 2010 to test theservice in Windows Azure staging or production just as you would locally against

    the Storage Emulator.

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    21/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201019

    Promoting to Production in Windows Azure

    Once youve deployed your application to Windows Azure, you can instantly

    deploy your application to production by selecting the Swap VIP option in theAzure Management Portal. If you dont 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 casehttp://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 thesame 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 newerversion of the package or configuration, and you can also choose to simply updatethe configuration file, leaving the package or application code intact.

    In addition, you can provision storage services including table, blob and queuefrom 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 andfor retuning a list of all golf courses in the store. A storage account has been

    created for the BrokerService application called GreenFeeBrokerTable and theREST endpoints for accessing the table, queue and blob storage services areprovided 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 theease 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 existingapplications to take advantage of the cloud, making the development, testing and

    management of hybrid applications virtually seamless.

    http://brokerservice.cloudapp.net/http://brokerservice.cloudapp.net/http://brokerservice.cloudapp.net/http://brokerservice.cloudapp.net/
  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    22/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201020

    About the Author:

    Rick G. Garibay is the General Manager of the Connected Systems Developmentpractice 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 inCODE Magazineand 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

    http://www.code-magazine.com/Article.aspx?quickid=0909091http://www.code-magazine.com/Article.aspx?quickid=0909091http://www.code-magazine.com/Article.aspx?quickid=0909091http://www.microsoft.com/visualstudiohttp://www.microsoft.com/visualstudiohttp://www.microsoft.com/visualstudiohttp://www.microsoft.com/visualstudiohttp://www.code-magazine.com/Article.aspx?quickid=0909091
  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    23/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201021

    Appendix

    Windows Azure Compute Service

    The Compute Service is a logical container for any number of Windows Servervirtual machines that host your application. The Compute Service uses load

    balancers which ensure that requests for your application are always routed to anavailable virtual machine instance (provided multiple instances have been

    configured).

    The Compute Service is partitioned into two roles: web role and worker role. Eachrole has affinity to a virtual machine; however, an application in each role isnever aware of what physical machine or logical virtual machine it is running on.

    When designing an application for Windows Azure, your application must targeteither the web role or worker role, and it can also be partitioned and distributedto 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 Microsofts 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., yourdesktop or your customers server in their own data center). As such, it issomewhat equivalent to an on-premise DMZ (or demilitarized zone).

    Worker Role

    A worker role can only accept input from another application inside of WindowsAzure and accepts requests via a Windows Azure storage feature called Queue

    Storage. A worker role equates to the same way you might think about anapplication 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 layeredapproach which includes both roles and this is an excellent pattern if you want toprovide 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 servicedeployed to a web role.

  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    24/25

    Developing and Extending Applications for Windows Azure with Visual Studio 201022

    Windows Azure Storage

    Just as with on-premise applications, for software to be useful, it must beable to save and retrieve information across a variety of media typesincluding 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 traditionalstorage 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 knownas REST which provides the ability to insert, update, delete and readrecords within tables deployed to Table storage. Although this is differentthan common relational approaches to data storage and manipulation, itprovides a simple alternative to other options such as Microsoft SQLAzure.

    Blob storage allows you to store data in binary form, which is ideal formedia 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 theyprovide both a means for processing jobs in the order the jobs are createdas well as durabilty for ensuring that jobs or messages are not lost beforethey 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 datacentersand 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 usersof 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 asthe Access Control Service (ACS) which allows you to take advantage of claim-based security, which greatly simplifies the process of authenticating and

    authorizing users of your applications and takes advantage of a variety of identityproviders including Windows Active Directory, Windows Live, and FaceBook.

    For more information on security scenarios in Windows Azure, please see thePatterns and Practices site dedicated Windows Azure Security:

    http://azuresecurity.codeplex.com/.

    http://azuresecurity.codeplex.com/http://azuresecurity.codeplex.com/http://azuresecurity.codeplex.com/
  • 8/6/2019 Developing and Extending Applications for Windows Azure With Visual Studio Final

    25/25

    Developing and Extending Applications for Windows Azure with Visual Studio 2010

    2011 Microsoft Corporation. All rights reserved. This document is provided as-is. Information and views expressed in thisdocument, 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 usethis document for your internal, reference purposes.