Introduction To Windows Azure For Java Developers - Whitepaper
Introduction To Windows Azure For Java Developers - Whitepaper
UsingWindowsAzure
...for Java developers
Informationinthisdocument,includingURLandotherInternetWebsitereferences,issubjecttochangewithoutnotice.Unlessotherwise
noted,theexamplecompanies,organizations,products,domainnames,e-mailaddresses,logos,people,places,andeventsdepictedherein
arefictitious,andnoassociationwithanyrealcompany,organization,product,domainname,e-mailaddress,logo,person,placeoreventis
intendedorshouldbeinferred.Complyingwithallapplicablecopyrightlawsistheresponsibilityoftheuser.Withoutlimitingtherightsunder
copyright,nopartofthisdocumentmaybereproduced,storedinorintroducedintoaretrievalsystem,ortransmittedinanyformorbyany
means(electronic,mechanical,photocopying,recording,orotherwise),orforanypurpose,withouttheexpresswrittenpermissionofMicrosoft
Corporation.
Microsoftmayhavepatents,patentapplications,trademarks,copyrights,orotherintellectualpropertyrightscoveringsubjectmatterinthis
document.ExceptasexpresslyprovidedinanywrittenlicenseagreementfromMicrosoft,thefurnishingofthisdocumentdoesnotgiveyou
anylicensetothesepatents,trademarks,copyrights,orotherintellectualproperty.
2011MicrosoftCorporation.Allrightsreserved.
MicrosoftiseitheraregisteredtrademarkortrademarkofMicrosoftCorporationintheUnitedStatesand/orothercountries.
Thenamesofactualcompaniesandproductsmentionedhereinmaybethetrademarksoftheirrespectiveowners.
Introduction
AsaJavadeveloper,youmayhavecreatedacloud-based
applicationanddeployedittoGoogleAppEngine(GAE)ortoa
virtualmachinethatAmazonhostsbyusingAmazonElastic
ComputeCloud(AmazonEC2).WindowsAzureisthe
Microsoftcloudplatformthatprovideson-demand,cloud-based
hostingservicesforyourapplications.
Cloud-basedcomputingoffersyouaviablewaytocreaterobust
andscalableapplicationsthatarehostedonserversthatare
runninginadatacenterthatathirdpartymanages,insteadof
deployingapplicationstoserversinyourowndatacenter.By
deployingyourapplicationsonadedicatedcloudplatform,you
canfocusoncreatingyourbusinessapplicationandrelyonthe
thirdpartytomanagethedatacenter,maintainthe
infrastructure,andprovideastandardizedruntimeenvironment
foryourapplications.
TheWindowsAzurehostedservicemodelmakesiteasytoscale
upyourapplicationondemandbyaddingadditionalinstancesof
yourservices.Itisjustaseasytoscalebackwhentheadditional
capacityisnolongerrequired.Thevariousservicesthatare
availablethroughtheWindowsAzureplatformaremetered,so
youonlypayforwhatyouuse.
TheWindowsAzureSDKprovidesacomprehensivesetof
applicationprogramminginterfaces(APIs)thatyourapplications
canusetointeractwiththemanyservicesthattheWindows
Azureplatformoffers.WindowsAzureisanopenplatform,so
you'renotlimitedtousing.NETlanguagesandtools.Thereare
JavaAPIsforinteractingwithWindowsAzureandtoolsfor
Eclipse.YoucanalsorunJavacodeonWindowsAzure.
TheWindowsAzureplatformcurrentlyconsistsofseveral
elements:
WindowsAzurecomputeservices,whichcanrunapplicationcode.
WindowsAzurestorageservices,whichcanstoreapplicationdata.
Acollectionofothercloud-basedservicessuchasMicrosoftSQL
AzureandWindowsAzureAppFabric,whichprovideadditional
dataservicesandsupportforsecurity.
Contents
Introduction.............................................ii
Contents....................................................ii
WindowsAzure.......................................3
TheWebRole.....................................5
TheWorkerRole...............................5
WindowsAzureStorage.................6
SQLAzure..................................................7
WindowsAzureAppFabric.................7
TheAppFabricServiceBus............7
AppFabricAccessControl..............8
Summary...................................................8
Windows Azure
3 Building and Connecting to Cloud Services by Using Windows Azure
Windows Azure
WindowsAzureoffersarobustandscalableenvironmenttohostandrunyour
applicationsinthecloud.Youcanbuildcomplexbusinessapplicationsbyusingthe
Microsoft.NETFrameworktoolsandthendeploytheapplicationtoaWindowsAzure
datacenterfromwhereitisgloballyaccessible.Microsofthasconstructeddatacentersin
severallocationsaroundtheworld.Theruntimeenvironmentisstandardized,soifyou
moveyourapplicationtoadifferentWindowsAzuredatacenter,youcanbesurethatit
willbehaveinexactlythesameway.
Afteryouhavedeployedyourapplication,youcanmanageitremotelyovertheWebby
usingaWeb-basedconsole,orthroughacollectionofWebservicesthatMicrosoft
provides.
AtypicalWindowsAzureapplicationhasthree
keyelements:
AWebrole
Aworkerrole
Storage
Thisisalittledifferentfromothercloud
platforms.Forexample,ifyouuseJavatocreate
anapplicationtodeploytoGAE,yourapplication
consistsofservletsandJavaServerPages(JSP)
pagesthatarerunninginacustomWeb
container.GAEdoesnothaveadirectequivalent
ofaworkerrole.InGAE,yourunasynchronous
tasksintheWebcontainer,butitonlysupports
tasksthathaveadurationofupto10minutes.If
youdeployaJavaapplicationtoavirtual
machinethatAmazonEC2manages,youare
likelytobeusingastandardJavaPlatform,
EnterpriseEdition(JEE)serverinstalledonthat
virtualmachine,soyouwillbeusingstandard
JavaAPIs.Itisalsoyourresponsibilitytodesign
theapplicationforscalabilityintheAmazonEC2
environment.TheWindowsAzureplatform
handlesfarmoreofthescalabilityissuesforyouintheWebandworkerroles.
Figure1illustratestherelationshipsbetweentheWindowsAzureelements.These
elementsaresummarizedinthesectionsthatfollow.
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
Machine Images on Amazon
servers in the cloud. When
you take this approach, it is
up to you to keep the
operating system and
installed software in the
virtual machine up to date.
Windows Azure
4 Building and Connecting to Cloud Services by Using Windows Azure
Figure1.ArchitectureofatypicalWindowsAzurehostedapplication
Figure2illustratestheequivalentelementsinaJavaapplicationthatishostedinGoogle
AppEngine.
Figure2.ArchitectureofatypicalGoogleAppEnginehostedapplication
Windows Azure
5 Building and Connecting to Cloud Services by Using Windows Azure
Figure3illustratestheequivalentelementsinaJavaapplicationthatisdeployedby
usingAmazonEC2.
Figure3.ArchitectureofatypicalAmazonEC2hostedJavaEEapplication
The Web Role
YoucanthinkoftheWebroleasbeingyourWebserverinthecloudwhereyoucan
deployyourASP.NETWebapplicationsandWindowsCommunicationFoundation(WCF)
services.ThisissimilartoaGAEinstancewhereyoucanhostJSPpagesorservletsinthe
cloudinacustomWebcontainer.However,theWindowsAzureWebroleismuchless
restrictiveabouttheAPIsthatareavailabletoyourcodethanGAE.YouusetheWebrole
tohandleincomingHTTPorHTTPSrequests.ThereplythataWebrolecanreturnmight
beaWebpageoraserializedSOAPorRESTresponsemessage.
The Worker Role
AworkerroleinWindowsAzureisageneral-purpose,hostedcontainerforexecuting
long-running,non-interactivetasks.Thesetasksoftenrunasynchronously.Aworkerrole
typicallyperformsthebackgroundprocessingthat
isspecifiedbymessagesthataresentfromaclient
applicationtoaWebrole.TheWebrolecanusea
queuetoreliablypassthenecessaryinformationto
runataskinaworkerrole.WindowsAzure
managesandmonitorsboththeworkerroleand
theWebrole.
Did you know?
You can run applications
such as Apache Tomcat in
a worker role, or even run
your own Java code.
Windows Azure
6 Building and Connecting to Cloud Services by Using Windows Azure
Windows Azure Storage
Figure4showsthetwomaintypesofstoragethatWindowsAzureprovidesfor
applicationstouse.Theseare:
WindowsAzureBinaryLargeObject(BLOB)storage.Followsasimilarapproachto
AmazonSimpleStorageService,enablingyoutostorelargeobjects,suchasmedia
files,inthecloud.
WindowsAzureTablestorage.Usesanon-relationalstoragemodelthatis
optimizedforthecloud,muchliketheAmazonSimpleDBdatastore.
Figure4.WindowsAzurestorageoptions
YoucanaccessWindowsAzureBLOB
andTablestoragefrombothworker
andWebroles,anddirectlyfrom
youron-premisesapplications,by
usingaRESTAPI.Ifyouarebuilding
Javaapplicationsthatneedtoaccess
datathatisstoredinWindowsAzure
storage,youcanusetheWindows
AzureSDKforJava.Underthecovers,
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
systemtype storage, you can also use a
Windows Azure drive that is formatted
as an NTFS file system (NTFS) volume.
SQL Azure
7 Building and Connecting to Cloud Services by Using Windows Azure
useREST-basedAPIs,makingiteasytoaccessthemfromanyprogramminglanguage.
SQL Azure
AlthoughWindowsAzureincludesTablestorageservicesforholdingsimple,structured
data,theremaybetimeswhenyouneedafull,relationaldatabaseinthecloud.For
example,youmaybemakingextensiveuseofjoinsandcomplexqueries,youmay
alreadyhavearelationaldatabasedesign,oryoumaywanttousefeaturessuchas
MicrosoftSQLServerReportingServices.SQLAzureissimplySQLServer(anenterprise-
classrelationaldatabasemanagementsystem)runninginthecloudinthesamewaythat
AmazonRelationalDatabaseServiceisMySQLrunninginthecloud.
Windows Azure AppFabric
WindowsAzureAppFabricisacollectionof
additionalcloud-basedservicesthatapplications
thatarerunninginWindowsAzure,oron-premises
applications,canuse.TheAppFabricSDKforJava
DevelopersisusefulforcreatingJavaclient
applicationsthatcantakeadvantageofthe
WindowsAzureAppFabricservices.Thefollowing
sectionsdescribetheservicesthatWindowsAzure
AppFabriccurrentlyprovides.
The AppFabric Service Bus
YoucanbuildWCFservicesthatprovidecommunicationchannelsbetweenapplications
andenablethoseapplicationstoexchangemessages.Thisworkswellinmanyscenarios,
butisdifficulttoimplementifboththeclientandserverarebehindtheirownfirewalls.
TheAppFabricServiceBusprovidesasolutiontothisproblembyenablingtheserver
applicationtoregisteranendpointthatishostedinthecloud.Then,aclientrunning
elsewhereontheInternetcandiscoverthisendpoint.TheAppFabricServiceBusactsas
anintermediary,enablingtheexchangeofmessagesbetweentheclientandtheserver.
YoucanconfiguretheendpointeitherasaSOAP-basedWCFserviceorasaRESTWCF
service,enablinginteroperabilitywithawiderangeofclients,includingJavaapplications.
ThefunctionalitythattheAppFabricServiceBusexposesissimilartothatofAmazon
SimpleNotificationService.
Figure5illustrateshowtheAppFabricServiceBusenablesapplicationstoexchange
messages.Application#1couldbeanapplicationthatisrunningataclient'spremises,
andApplication#2couldbeanapplicationthatishostingaservicethatisrunningata
separatesite.
Did you know?
There are AppFabric SDKs
for Ruby and PHP
developers in addition to
tools for Eclipse.
Summary
8 Building and Connecting to Cloud Services by Using Windows Azure
Figure5.TheAppFabricServiceBus
AppFabric Access Control
AppFabricAccessControlisaservicethatenablesyourWebapplicationsandservices
(whethertheyarehostedinWindowsAzureoronyourownservers)tointegratewith
third-partyidentityservicessuchasActiveDirectoryFederationServices,oridentity
servicesthatfollowtheOAuthprotocol.AppFabricactsasatranslatorthataccepts
securitytokensthatanexternalidentityproviderissues,andconvertsthemtoastandard
form(asignedSimpleWebToken)thatyourWebapplicationorserviceunderstands.In
thisway,youcaneasilyimplementsinglesign-onscenariosoruseindustry-standard
authenticationmechanismswithyourapplication.
Summary
WindowsAzureprovidesyouwithaplatformforrunningyourapplicationsinthecloud.
Youcanbuildyourcloudapplicationbyusing.NETFrameworktoolsandlanguagessuch
asC#.However,theplatformisopenandinteroperable,soyoucanutilizeother
technologiessuchasJava,bothforimplementingyourcloudservicesandforcreating
clientapplicationsthataccessyourcloudservices.