Introduction to Windows Azure for Java Developers - Whitepaper
Comments
Content
BuildingandConnectingtoCloudServicesby UsingWindowsAzure
...for Java developers
Informationinthisdocument,includingURLandotherIn Informationinthisdocument,inclu dingURLandotherInternetWeb ternetWebsitereferences,issubje sitereferences,issubjecttochangewithou cttochangewithoutnotice.Unlessotherwise tnotice.Unlessotherwise noted,theexamplecompanies,or noted,theexamp lecompanies,organizations,produ ganizations,products,domainnam cts,domainnames,e-mailaddresses,logos,p es,e-mailaddresses,logos,people,places,andev eople,places,andeventsdepictedherein entsdepictedherein arefictitious,andnoassociationwithanyrealcomp arefictitious,andnoasso ciationwithanyrealcompany,organization any,organization,product,do ,product,domainname,e-mailadd mainname,e-mailaddress,logo,person ress,logo,person,placeoreventis ,placeoreventis intendedorshouldbeinferred intendedorsho uldbeinferred.Complyingwithallapplicable .Complyingwithallapplicablecopyrightlawsistheresp copyrightlawsistheresponsibilityoftheuser.With onsibilityoftheuser.Withoutlimitingtherightsun outlimitingtherightsunder der copyright,nopartofthisdocumen copyright,nopart ofthisdocumentmaybereprod tmaybereproduced,storedino uced,storedinorintroducedintoar rintroducedintoaretrievalsystem, etrievalsystem,ortransmittedinanyform ortransmittedinanyformorbyany orbyany means(electronic,mechanical,photoco means(electronic,m echanical,photocopying,recording pying,recording,orotherwise),orfo ,orotherwise),orforanypurpose,w ranypurpose,withouttheexpress ithouttheexpresswrittenpermissiono writtenpermissionofMicrosoft fMicrosoft Corporation. Microsoftmayhavepatents,patentapplications,tradem Microsoftmayhavepatents,paten tapplications,trademarks,copyrights,or arks,copyrights,orotherintellectualpro otherintellectualpropertyrightscov pertyrightscoveringsubjectmatterinthis eringsubjectmatterinthis document.Exceptasexpresslyprovide document.Excep tasexpresslyprovidedinanywrittenlicenseagr dinanywrittenlicenseagreementfro eementfromMicrosoft,th mMicrosoft,thefurnishingofthisdo efurnishingofthisdocumentdoesn cumentdoesnotgiveyou otgiveyou anylicensetothesepatents,trademarks,c anylicensetothesepa tents,trademarks,copyrights,oroth opyrights,orotherintellectualprope erintellectualproperty. rty. ®2011MicrosoftCorporation.Allrightsreserved. Microsoftiseitheraregisteredtrademar Microsoftiseitherare gisteredtrademarkortrademark kortrademarkofMicrosoftC ofMicrosoftCorporationinth orporationintheUnitedStatesand eUnitedStatesand/orothercoun /orothercountries. tries. Thenamesofactualcompaniesandp Thenamesofactual companiesandproductsmention roductsmentionedhereinmayb edhereinmaybethetrademark ethetrademarksoftheirrespectiv softheirrespectiveowners. eowners.
Introduction
Contents
AsaJavadeveloper,youmayhavecreatedacloud-based AsaJavadeveloper,youmayhavecrea tedacloud-based applicationanddeployedittoGo applicatio nanddeployedittoGoogleAppEngine(GAE)orto ogleAppEngine(GAE)ortoa a virtualmachinethatAmazonhostsbyusingAmazonElastic
Introduction............................................. Introduction .............................................iiii
™
Contents.................................................... Contents ....................................................iiii WindowsAzure WindowsA zure....... ............. ............. ............. ............. ............. ......3
ComputeCloud(AmazonEC2).Windows®Azure isthe Microsoftcloudplatformthatp Microsoftcl oudplatformthatprovideson-demand rovideson-demand,cloud-based ,cloud-based hostingservicesforyourapplications. Cloud-basedcomputingoffersyouaviablewayto Cloud-basedcomputingoffersy ouaviablewaytocreaterobust createrobust andscalableapplicationsthatarehostedo andscalablea pplicationsthatarehostedonserversthatare nserversthatare runninginadatacenterthatathirdpartymanages,insteadof deployingapplicationstoservers deployingapp licationstoserversinyourowndatacenter.By inyourowndatacenter.By deployingyourapplicationsonad deployingyo urapplicationsonadedicatedcloudpla edicatedcloudplatform,you tform,you canfocusoncreatingyourbusinessappl canfocusoncreati ngyourbusinessapplicationandrelyo icationandrelyonthe nthe thirdpartytomanagethedatacenter,maintainthe infrastructure,andprovideastandardiz infrastructure,andpro videastandardizedruntimeenvironme edruntimeenvironment nt foryourapplications. TheWindowsAzurehostedservicemodelmakesiteasy TheWindowsAzurehostedservicemo delmakesiteasytoscale toscale upyourapplicationondemandbyaddi upyourapplica tionondemandbyaddingadditionalinsta ngadditionalinstancesof ncesof yourservices.Itisjustaseasytosca yourservices.Iti sjustaseasytoscalebackwhentheadditi lebackwhentheadditional onal capacityisnolongerrequired.Thevar capacityisnol ongerrequired.Thevariousservicesthatare iousservicesthatare availablethroughtheWindowsAzurepla available throughtheWindowsAzureplatformaremetered,so tformaremetered,so youonlypayforwhatyouuse. TheWindowsAzureSDKprovidesacomprehensiveseto TheWindowsAzureSDKprovidesac omprehensivesetof f applicationprogramminginterfa applicatio nprogramminginterfaces(APIs)thatyourappli ces(APIs)thatyourapplications cations canusetointeractwiththemanyservicesthattheWindows canusetointeractwiththemanyservicesthatthe Azureplatformoffers.WindowsAzureisanopenplatform,so Azureplatform you'renotlimitedtousing.NETlanguag you'renotlimited tousing.NETlanguagesandtools.Therear esandtools.Thereare e JavaAPIsforinteractingwithWindo JavaAPIsfori nteractingwithWindowsAzureandtoolsfor wsAzureandtoolsfor Eclipse.YoucanalsorunJavacodeonWindowsAzure. TheWindowsAzureplatformcurrentlyconsistsofseveral TheWindowsAzureplatformcurrentlyconsis tsofseveral elements: WindowsAzurecom WindowsAzurecomputeservices puteservices,whichcanrunapplica ,whichcanrunapplicationcode. tioncode.
WindowsAzurestora WindowsAzurestorageservices,whic geservices,whichcanstoreapplic hcanstoreapplicationdata. ationdata.
Acollectionof Acollectionofothercloud-basedservic othercloud-basedservicessuchasMicr essuchasMicrosoft®SQL osoft®SQL
Azure andWindowsAzure andWindowsAzureAppFabric,whic AppFabric,whichprovideadditiona hprovideadditional l dataservicesandsupportforsecurity. ™
TheWebRole TheWeb Role....... ............. ............. ............. ............. ........... ....5 5 TheWorkerRole TheWorke rRole............. ...... ............. ............. ............ .....5 5 WindowsAzureS Windows AzureStorage torage...... ............. ........... ....6 6 SQLAzure SQLAzur e............. ....... ............. ............. ............. ............. ............. ........... ....7 7 WindowsAzureA WindowsA zureAppFabri ppFabric c...... ............. ........... ....7 7 TheAppFabric TheAppF abricService ServiceBus Bus....... ............ .....7 7 AppFabricAcces AppFabr icAccessContro sControl.... l........... .......... ...8 Summary................................................... Summary ...................................................8
Windows Azure Windows Azure WindowsAzureoffersarobustandscalableenvironmenttoho WindowsAzureoffersarobustandsca lableenvironmenttohostandrunyour standrunyour applicationsinthecloud.Youcanbuild applications inthecloud.Youcanbuildcomplexbusinessap complexbusinessapplicationsbyusi plicationsbyusingthe ngthe Microsoft.NETFrameworktools Microsoft.NETFra meworktoolsandthendeploytheappli andthendeploytheapplicationtoaWindow cationtoaWindowsAzure sAzure datacenterfromwhereitisgloball datacenterfromwher eitisgloballyaccessible.Mic yaccessible.Microsofthasconstr rosofthasconstructeddatacentersin ucteddatacentersin severallocationsaroundtheworl severallocati onsaroundtheworld.Theruntimeenviro d.Theruntimeenvironmentisstandardized nmentisstandardized,soifyou ,soifyou moveyourapplicationtoadiffe moveyourappl icationtoadifferentWindowsAzuredatacenter,youca rentWindowsAzuredatacenter,youcanbesurethatit nbesurethatit willbehaveinexactlythesameway. Afteryouhavedeployedyourapplication,youcanmanageitremo Afteryouhavedeployedyourapplicati on,youcanmanageitremotelyovertheWebby telyovertheWebby usingaWeb-basedconsole,orthroughacol usingaWeb-basedc onsole,orthroughacollectionofWeb lectionofWebservicesthatMicroso servicesthatMicrosoft ft provides. AtypicalWindowsAzureapplicationhasthree keyelements:
AWebrole
Aworkerrole Storage
Thisisalittledifferentfromothercloud platforms.Forexample,ifyouuseJavatocreate anapplicationtodeploytoGAE,yourapplication consistsofservletsandJavaServerPages(JSP) pagesthatarerunninginacustomWeb container.GAEdoesnothaveadirectequivalent ofaworkerrole.InGAE,yourunasynchronous tasksintheWebcontainer,butitonlysupports
Did you know?
Windows Azure now also supports virtual machine roles that enable you to run custom virtual machines that contain your own installation of Windows Server® 2008 and any other software that you require. This approach is similar to the way in which the Amazon EC2 service enables you to run custom Amazon
tasksthathaveadurationofupto10minutes.If Machine on Amazon servers inImages the cloud. When youdeployaJavaapplicationtoavirtual machinethatAmazonEC2manages,youare you take this approach, it is likelytobeusingastandardJavaPlatform, up to you to keep the EnterpriseEdition(JEE)serverinstalledonthat operating system and virtualmachine,soyouwillbeusingstandard installed software in the JavaAPIs.Itisalsoyourresponsibi JavaAPIs.Itisals oyourresponsibilitytodesign litytodesign virtual machine up to date. theapplicationforscalabilityintheAmazonEC2 environment.TheWindowsAzureplatform handlesfarmoreofthescalabilityi handlesfarmore ofthescalabilityissuesforyouintheWeba ssuesforyouintheWebandworkerroles. ndworkerroles. Figure1illustratestherelationshipsbetweentheWindows Figure1illustratestherelationshipsbetw eentheWindowsAzureelements.These Azureelements.These elementsaresummarizedinthesectionsthatfollow. 3 Building and Connecting to Cloud Services by Using Windows Azure
Windows Azure
Figure1.ArchitectureofatypicalWindowsAzurehostedapplication
Figure2illustratestheequivalentelementsinaJavaapplicatio Figure2illustratestheequivalentelementsi naJavaapplicationthatishostedinGoogle nthatishostedinGoogle AppEngine.
Figure2.ArchitectureofatypicalGoogleAppEnginehostedapplication
4 Building and Connecting to Cloud Services by Using Windows Azure
Windows Azure Figure3illustratestheequivalentelementsinaJavaapplica Figure3illustratestheequivalentelementsi naJavaapplicationthatisdeployedby tionthatisdeployedby usingAmazonEC2.
Figure3.ArchitectureofatypicalAmazonEC2hostedJavaEEapplication
The Web Role YoucanthinkoftheWebroleasbeingyourWebserverinthecloudwhereyoucan YoucanthinkoftheWebroleasbeingyourWebserverinthec loudwhereyoucan deployyourASP.NETWebapplicati deployyourASP.NET WebapplicationsandWindowsComm onsandWindowsCommunicationFoundation(WCF) unicationFoundation(WCF) services.ThisissimilartoaGAEinsta services.This issimilartoaGAEinstancewhereyoucanhostJSPpa ncewhereyoucanhostJSPpagesorservletsinthe gesorservletsinthe cloudinacustomWebcontainer.However,the cloudinacustom Webcontainer.However,theWindowsAzureWebro WindowsAzureWebroleismuchless leismuchless restrictiveabouttheAPIsthatareavailable restrictiveabouttheAP IsthatareavailabletoyourcodethanGAE.YouusetheWeb toyourcodethanGAE.YouusetheWebrole role tohandleincomingHTTPorHTTPSrequests tohandleincomi ngHTTPorHTTPSrequests.ThereplythataWebrol .ThereplythataWebrolecanreturnmight ecanreturnmight beaWebpageoraserializedSOAPorRESTresponsemessage.
The Worker Role AworkerroleinWindowsAzureisageneral-purpose,hostedcontai AworkerroleinWindowsAzureisageneral-p urpose,hostedcontainerforexecuting nerforexecuting long-running,non-interactivetasks.Thesetas long-running,non-intera ctivetasks.Thesetasksoftenrunasynchronousl ksoftenrunasynchronously.Aworkerrole y.Aworkerrole typicallyperformsthebackgroundprocessingthat isspecifiedbymessagesthataresentfromaclient Did you know? applicationtoaWebrole.TheWebrolecanusea You can run applications queuetoreliablypassthenecessaryinformationto such as Apache Tomcat in runataskinaworkerrole.WindowsAzure a worker role, or even run managesandmonitorsboththeworkerroleand
your own Java code.
theWebrole.
5 Building and Connecting to Cloud Services by Using Windows Azure
Windows Azure Windows Azure Storage Figure4showsthetwomaintypesofstoragethatWindowsAzureprovi Figure4showsthetwomaintypesofsto ragethatWindowsAzureprovidesfor desfor applicationstouse.Theseare:
WindowsAzureBinaryLargeObject(BLOB)storage.Followsasimilarapproachto WindowsAzureBinaryLargeObject(BLOB)storage.Followsasimilarapproachto AmazonSimpleStorageService,enabling AmazonSimpleSto rageService,enablingyoutostorelarge youtostorelargeobjects,suchasmedia objects,suchasmedia files,inthecloud.
WindowsAzureTablestorage.Usesanon-relationalstoragemodelthatis WindowsAzureTablestorage.Usesanon-relationalstoragemodelthatis optimizedforthecloud,muchliketheAma optimizedfor thecloud,muchliketheAmazonSimpleDB zonSimpleDBdatastore. datastore.
Figure4.WindowsAzurestorageoptions
YoucanaccessWindowsAzureBLOB andTablestoragefrombothworker andWebroles,anddirectlyfrom youron-premisesapplications,by usingaRESTAPI.Ifyouarebuilding Javaapplicationsthatneedtoaccess datathatisstoredinWindowsAzure storage,youcanusetheWindows storage,youcanusethe AzureSDKforJava..Underthecovers, AzureSDKforJava WindowsAzurestorage,Amazon SimpleDB,andtheGAEdatastoreall
Did you know?
Windows Azure Table and BLOB storage are optimized for the cloud environment. However, if your application needs access to standard file system–type storage, you can also use a Windows Azure drive that is formatted as an NTFS file system (NTFS) volume.
6 Building and Connecting to Cloud Services by Using Windows Azure
SQL Azure useREST-basedAPIs,makingiteasytoacces useREST-basedAPIs,m akingiteasytoaccessthemfromanypro sthemfromanyprogramminglanguage. gramminglanguage.
SQL Azure AlthoughWindowsAzureincludesTablestorageservicesforho AlthoughWindowsAzureincludesTablestora geservicesforholdingsimple,s ldingsimple,structured tructured data,theremaybetimeswhenyouneedafull,rel data,theremaybetimes whenyouneedafull,relationaldatabas ationaldatabaseinthecloud.For einthecloud.For example,youmaybemakingextensiveuseo example,youma ybemakingextensiveuseofjoinsandcom fjoinsandcomplexqueries,youmay plexqueries,youmay alreadyhavearela alreadyhavearelationaldatabasedes tionaldatabasedesign,oryoumaywanttousefea ign,oryoumaywanttousefeaturessuchas turessuchas MicrosoftSQLServer®ReportingServices.SQLAzure SQLAzureissimplySQLServer(anenterpriseclassrelationaldatabasemanagem classrelatio naldatabasemanagementsystem)runninginthecloudi entsystem)runninginthecloudinthesamewaythat nthesamewaythat AmazonRelationalDatabaseServic AmazonRelational DatabaseServiceisMySQLrunninginthecloud. eisMySQLrunninginthecloud.
AppF ppFabric abric Windows Azure A WindowsAzureAppFabricisacollectionof WindowsAzureAppFabric additionalcloud-basedservices additionalcl oud-basedservicesthatapplications thatapplications thatarerunninginWindowsAzure,oron-premises applications,canuse.TheAppFabricSDKforJava applications,canuse.The DevelopersisusefulforcreatingJavaclient Developers applicationsthatcantakeadvantageofthe WindowsAzureAppFabricservices.Thefol WindowsAzureAppFabri cservices.Thefollowing lowing sectionsdescribetheservicesthatWindowsAzure AppFabriccurrentlyprovides.
Did
you know?
There are AppFabric are AppFabric SDKs for Ruby and PHP developers in addition to tools for Eclipse.
The AppFabric Service Bus YoucanbuildWCFservicesthatprovidecommunicationchannel YoucanbuildWCFservicesthatprovideco mmunicationchannelsbetweenapp sbetweenapplications lications andenablethoseapplicationstoexchang andenablethoseappl icationstoexchangemessages.This emessages.Thisworkswellinm workswellinmanyscenarios, anyscenarios, butisdifficulttoimplementifboththecl butisdifficultto implementifboththeclientandserverarebehi ientandserverarebehindtheirownfirewa ndtheirownfirewalls. lls. TheAppFabricServiceBusprovidesasolutiontothispro TheAppFabricServiceBusprovidesas olutiontothisproblembyenabling blembyenablingtheserver theserver applicationtoregisteranendpointthatisho applicationto registeranendpointthatishostedinthecloud.Then,aclie stedinthecloud.Then,aclientrunning ntrunning elsewhereontheInternetcandiscoverthis elsewhereontheInter netcandiscoverthisendpoint.TheAppFabricServi endpoint.TheAppFabricServiceBusactsas ceBusactsas anintermediary,enablingtheexchangeofme anintermediary,enabl ingtheexchangeofmessagesbetweenthecl ssagesbetweentheclientandtheserver. ientandtheserver. YoucanconfiguretheendpointeitherasaSOAP-ba Youcanconfiguretheendp ointeitherasaSOAP-basedWCFserviceoras sedWCFserviceorasaRESTWCF aRESTWCF service,enablinginteroperabili service,enabli nginteroperabilitywithawiderangeo tywithawiderangeofclients,includingJa fclients,includingJavaapplications. vaapplications. ThefunctionalitythattheAppFabricServiceBusexpo ThefunctionalitythattheApp FabricServiceBusexposesissimil sesissimilartothatofAmazon artothatofAmazon SimpleNotificationService. Figure5illustrateshowtheAppFabricServiceBusenablesappl Figure5illustrateshowtheAppFabricServic eBusenablesapplicationstoexchange icationstoexchange messages.Application#1couldb messages.Appli cation#1couldbeanapplicationthatisrunningatac eanapplicationthatisrunningataclient'spremises, lient'spremises, andApplication#2couldbeanapplica andApplicatio n#2couldbeanapplicationthatishostingaservi tionthatishostingaservicethatisrunningata cethatisrunningata separatesite. 7 Building and Connecting to Cloud Services by Using Windows Azure
Summary
Figure5.TheAppFabricServiceBus
AppFabric Access Control AppFabricAccessControlisaservicethatenablesyourWebapp AppFabricAccessControlisaservicetha tenablesyourWebapplicationsandser licationsandservices vices (whethertheyarehostedinWindowsAzureoronyo (whethertheyarehostedi nWindowsAzureoronyourownservers)toi urownservers)tointegratewith ntegratewith third-partyidentityservicessuchasActiv third-partyidentitys ervicessuchasActiveDirectory®FederationS eDirectory®FederationServices,oridenti ervices,oridentity ty servicesthatfollowtheOAuth servicesthatfollowthe OAuthprotocol.AppFabricactsasatranslatorthataccepts securitytokensthatanexternalidentityprovideris securitytokensthatanexterna lidentityproviderissues,andconvertsthemto sues,andconvertsthemtoastandard astandard form(asignedSimpleWebToken)thatyourWeb form(asignedSi mpleWebToken)thatyourWebapplicationors applicationorserviceunderstands.In erviceunderstands.In thisway,youcaneasilyimplementsingl thisway,youcaneasi lyimplementsinglesign-onscenarioso esign-onscenariosoruseindustry-standard ruseindustry-standard authenticationmechanismswithyourapplication.
Summary WindowsAzureprovidesyouwithaplatformforrunningyourap WindowsAzureprovidesyouwithapla tformforrunningyourapplicationsinthecl plicationsinthecloud. oud. Youcanbuildyourcloudapplicationbyusi Youcanbuildyourclo udapplicationbyusing.NETFramewo ng.NETFrameworktoolsandlanguage rktoolsandlanguagessuch ssuch asC#.However,theplatformisopenand asC#.However,thepl atformisopenandinteroperable,soyo interoperable,soyoucanutilizeother ucanutilizeother technologiessuchasJava,bothfori technologiessucha sJava,bothforimplementingyo mplementingyourcloudservicesa urcloudservicesandforcreating ndforcreating clientapplicationsthataccessyourcloudservices.
8 Building and Connecting to Cloud Services by Using Windows Azure
Sponsor Documents