Java and Windows Azure Tutorial


Published on

• Cloud computing – what is it and why you should care
• Windows Azure – what is it and why you should care
• Java in the clouds – options/considerations
 Java and Windows Azure
• Use cases (why Windows Azure and Java)
• What you need and how to get setup
• Java access to Windows Azure data (Azure Storage)
• Java running in Windows Azure
• Demo application

Published in: Software, Technology, Business
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Java and Windows Azure Tutorial

  1. 1. Java in the Microsoft Cloud Deploying Enterprise Applications to Windows Azure Jim White ( Director of Training, Instructor Intertech, Inc (
  2. 2. Intertech Instructors Who Consult, Consultants Who Teach Training • Training through hands-on, real world business examples. • Our site, your site, or live online – globally. • Agile/Scrum, Citrix, VMware, Oracle, IBM, Microsoft, Java/Open Source, and web and mobile technologies. Consulting  Design and develop software that powers businesses and governments of all sizes.  On-site consulting, outsourcing, and mentoring.  Agile, .NET, Java, SQL Server, mobile development including iPhone and Android platforms and more…. Our Company  Over 35 awards for growth, innovation and workplace best practices.  99.7% satisfaction score from our consulting and training customers.  Yearly “Best Places to Work” winner in Minnesota.
  3. 3. Session Demo: Please Visit Now   Enter your • US Zip Code or • Canadian Postal code  Attendee locations are mapped
  4. 4. “Those that can't do, teach, and those that can't teach... teach gym” Jack Black as Dewey Finn in “The School of Rock” 2003,
  5. 5. A Brief Introduction from your teacher  Jim White • Software Engineer for 20+ years • Java developer/architect for 13+ years • Author of Windows® Azure™ Solutions with Microsoft® Visual Studio® 2010 – Microsoft’s Courseware Library • MSFT Azure Bootcamp trainer • Author of J2ME, Java in Small things (Manning) • Frequent contributor to journals like • Dir. Training, Instructor, Partner at Intertech, Inc. • Former architect at Target Corp.
  6. 6. Our Session Agenda  Background • Cloud computing – what is it and why you should care • Windows Azure – what is it and why you should care • Java in the clouds – options/considerations  Java and Windows Azure • Use cases (why Windows Azure and Java) • What you need and how to get setup • Java access to Windows Azure data (Azure Storage) • Java running in Windows Azure • Demo application
  7. 7. Session Goal: To show the benefits of and ways to use Azure as a cloud platform for Java My Randy Pausch “Head Fakes”: 1. Cloud computing proselytizing 2. Get you started with Java and Windows Azure
  8. 8. BACKGROUND “If we are to go forward, we must go back…” – Martin Luther King
  9. 9. Background check By a show of hands, who here…  Feels they have a good grasp of “cloud computing”  Understand platform-as-a- service?  Is already developing to the cloud?  Has started playing in the Windows Azure Platform?  Has production apps in WAP?  Is already using Java in Azure?
  10. 10. What is cloud computing? ?
  11. 11. What is cloud computing?  Does anyone really know? • Everybody is laying claim to cloud computing • Without care, “cloud computing” may be relegated to the IT term- doghouse like architecture, SOA, and framework Microsoft’s -“Yeah cloud!” IBM’s-“My cloud does…”
  12. 12. What is cloud computing?  “Cloud computing is location independent computing, whereby shared servers provide resources, software, and data to computers and other devices on demand, as with the electricity grid.” 1 • Computing resources made available in a metered fashion  Computing resource = hardware, software, data, etc.  Metered fashion = like a public utility; pay for what you use • Utility Computing 1
  13. 13. Cloud Ontology (a.k.a. Service Models) Examples, NetSuite, Gmail,, Google’s App Engine, Microsoft’s Azure Amazon's Elastic Compute Cloud (AWS), IBM, VMware, HP Yes – there are other “XaaS”, but let’s keep it simple. Our focus
  14. 14. Why do I care? What’s in it for me?  Scale and time to market • We can’t be ready by then • We can’t scale up or down fast enough  Data center/infrastructure is expensive • We have to build for the maximum potential • It’s always getting old and needs to be replaced • It’s getting harder to maintain • We don’t have the expertise for the new stuff • Cloud computing offers OpEx vs. CapEx  Others: multi-tenancy, geodistribution, eco-friendly,…
  15. 15. Introducing Windows Azure  Formally - Windows Azure Platform (WAP) • Microsoft’s cloud service platform • I.e. – Microsoft’s Platform as a service (PAAS) • A “cloud operating system”  An array of capability/services • Data centers for hosting applications/data • A platform/tools for building cloud based applications and data • Services for on-premise systems • Tools for building on-premise consumers of cloud data/services
  16. 16. Windows Azure Platform 12+ (and growing) Microsoft Data Centers across the globe. Warehouses full of servers and networking that host Windows Azure and things like Bing, Windows Live, etc. The Fabric is the infrastructure in the data centers. The Fabric Controller is the “brains” of Windows Azure. Controls the hardware, software and just about everything in the Microsoft cloud. Where your code runs. Where your non-SQL data resides. APIs and tools to help build these. Services that can be used by in the cloud or on-premise apps. This collection is growing. SQL Server (minus) running in the cloud. Now with data sync and report capability. Tools, APIs, etc. (some provide by Microsoft and an increasing number provided by 3rd parties) to develop apps/data for the cloud or to integrate on-premise with the cloud. And there is more…
  17. 17. The Microsoft Cloud Data Center • Microsoft has > 12 data centers across the world • Not all of them run Azure • Exact number and location are not advertised • Chicago Data Center has ~360,000 servers • On each server: • 1.5 to 1.7GHz CPU • ~1.7GB of RAM • Modified Hyper-V Hypervisor allows machine resources in the data center to be shared. It manages and controls the virtual machine/partition running on the physical server.
  18. 18. Windows Azure Fabric and Fabric Controller  Azure Fabric = raw resources • Physical/virtual servers • Supporting software • Load balancers, Switches, Routers, …  The Fabric Controller “brains” • Controls the hardware, software and just about everything in the Microsoft cloud • Manages the physical deployment of services and data into the virtualized environment • Monitors the hardware, software and takes corrective action when any fail
  19. 19.  Applications run in Windows Azure Compute • Consist of one or more components or services known as Hosted Services  Two types (soon 3) of components in Hosted Services • Web roles and worker roles and soon to be released VM roles (beta) • Web roles are Web applications  Runtime includes a Web server (IIS7) • Worker roles are background processes  Essentially, worker roles can be any running process  This is how Java can run in Azure • VM Roles are customized Hyper-V images running in Azure  Another way to run Java Windows Azure Compute VM Role ~= IAAS ??
  20. 20. Azure Storage  Azure Storage consists of three types of data storage in the cloud: tables, blobs and queues • Accessible in the cloud or on-premise (REST based) • Azure replicates all of storage 3 times • Azure Storage is scalable and typically cheaper than storing data in relational form in the cloud • Table storage  Structured data that can be queried  Not relational storage – that’s SQL Azure • Queue storage  Mechanism for reliable, persistent messaging • Blobs  Store any text or binary data  Great for images, music, etc.  Azure CDN is really just Blob storage
  21. 21. SQL Azure  SQL Azure is the relational database in the Azure • It is SQL Server 2008 R2 at its core. • But not a full-blown SQL Server. • This is SQL Server with a number of limitations.  50 GB limit today • If it works today against SQL Express edition then it should work in/with SQL Azure with little or no modification2  Access SQL Azure from in the cloud or on-premise • Access like normal (use ODBC, JDBC, ADO.NET, …) • Access via tools like SQL Server Management Studio 2Azure in Action, Prince and Hay (Manning 2010)
  22. 22. Windows Azure AppFabric  “Cloud middleware” • Internet-based computing services • To be used by cloud apps or on-premise apps – REST based • AppFabric today consists of:  Access control – claims based identity and access control • Allowed identity providers: Active Directory, Windows Live ID, Google, Yahoo!, and Facebook  Service Bus – app secure messaging and connectivity  More services on the way  Caching (beta) – distributed, in-memory app cache  Integration – BizTalk server integration  Composite App - Automates the deployment and management
  23. 23. Windows Azure Development  Microsoft provides APIs, tools, etc. to assist developers • Third party vendors are now starting to participate  Must have the Windows Azure SDK – it’s free • Even if you are doing Java development (more in a bit) • The SDK comes with Dev Fabric and Dev Storage  Simulate Windows Azure Compute and Storage locally  Dev Fabric uses processes to simulate virtual machines  Dev Compute simulates storage through local SQL Server Express  The Dev Fabric is based on 90% of the real Fabric  In most cases, performance will be better in the real cloud Newly coined Compute & Storage Emulator
  24. 24. Windows Azure Developer Portal(s) Internet access to the Microsoft cloud • Subscribe • Deploy • Manage • Tweak • Billing
  25. 25. Publishing and Deploying Applications “publish” “deploy”
  26. 26. JAVA AND WINDOWS AZURE “And now, here's something we hope you'll really like!” – Rocket (Rocky) J. Squirrel
  27. 27. Why Azure and Java?  Why would Azure be of interest to Java developers? • It’s another place to run your code (a cloud place).  Cheap (relative)  Available (12+ data centers, geodistributed)  Scalable, flexible, reliable, maintenance free, (X-ables) • It provides all sorts of services (and data)  Use them in the cloud  Use them on-premise • You have other apps (.NET, PHP, etc.) to integrate with in the Azure cloud
  28. 28. Use cases  Java access of Azure Storage for data • Or Java to SQL Azure or CDN for data  Windows Azure Marketplace DataMarket is commercial data already available in the cloud for all to use  Java physically running on/in Azure • Why?  You need a cloud platform to host/run your applications/data for the reasons cited earlier • Dominos Pizza  You need to integrate to .NET solutions already there  Java use of App Fabric Services Example coming up Example coming up
  29. 29. Java & Azure – What you need  The Basics • Java 6 environment • Windows Azure Account  • Windows Azure SDK – free   Tools for creating the packages/files for deployment to Azure  Provides DevFabric & DevStorage for testing locally • Windows Azure SDK for Java – free   API for accessing Azure Storage  Azure Service Management API
  30. 30. Java & Azure – What you also want  Additionally, for convenience (not required, but…) • Windows Azure Tools for Eclipse - free   Eclipse 3.5 or better  Eclipse Plug-in for Java and PHP development  Provides Eclipse View Storage Explorer  Open source project by Soyatec and Microsoft • AppFabric SDK for Java Developers - free   From Microsoft , Persistent Systems Limited and Schakra  Java API for accessing AppFabric services
  31. 31. Java & Azure - Conveniences  Other tools and API you may find handy • Log4J Appender - free   Java Log4J API  Sends log messages to Windows Azure Table Storage • Cerebrata Tools - < $100   Tools for exploring Azure Storage, logs, etc.  Cloud Storage Studio  Azure Diagnostics Manager
  32. 32. Java running in Azure  To run Java applications (and their containers) in Azure • Tomcat Solution Accelerator   Packages your Java Web application, Java and Tomcat for Azure deployment as an Azure worker role  Approach can be used for other containers  See jetty-in-windows-azure.aspx • AzureRunMe   Runs 3rd party software in Windows Azure  Alternative to Tomcat Solution Accelerator or grow-your-own  Claims Tomcat, Jetty, JBoss all work Example coming up
  33. 33. Demo Application
  34. 34. Demo Application Architecture 1 2 3 With Java code external to the cloud
  35. 35. Demo Application Architecture With Java code internal to the cloud
  36. 36. Java Accessing Azure Storage  Remember, Azure Storage = Queues, Blobs, Tables  How to access with Java • Raw REST – for the sadomasochist  Reference guide: • Windows Azure SDK for Java  Let’s look at some example code
  37. 37. Access Azure Storage Code Examples Azure Storage API  Message to a queue
  38. 38. Access Azure Storage Code Examples Azure Storage API  Read table data
  39. 39. Access Azure Storage Code Examples Azure Storage API  Use blobs  There is also a blob API for programmatic access
  40. 40. Java Apps on Windows Azure  Couple of options • Java application (with JRE and container) bundled and deployed as a worker role.  Using Tomcat Accelerator, AzureRunMe, “role-your-own” • Use of the new VM Role  Still in beta as of this writing  See
  41. 41. Java App as Worker Role  Steps (using Tomcat Solution Accelerator) • Create, debug, test your Java application • Deploy your application to a local Tomcat image (webapps directory) • Use Tomcat Solution Accelerators to…  Create an Azure solution that can be run on DevFabric/DevStorage • Needs the location of Tomcat and your JRE • Buildme.cmd  Run and test the solution on DevFabric/DevStorage • Runme.cmd  Create a Azure Cloud Service Package (.cskpg) and configuration file (.cscfg) containing the JRE, Tomcat and your app code (its big!). • Packme.cmd • Use these files to deploy your app (and Tomcat and Java) to Azure
  42. 42. Building and Deploying Java Applications for Azure Using Tomcat Solution Accelerator Live Demo
  43. 43. Java App in VM Role (beta)  Build and deploy a virtual hard drive (VHD) image • Requires you have Microsoft Windows Server 2008 R2 and Hyper-V Manager on your box  Use Hyper-V Manager to create a VHD image  Install and configure all the bits on the VHD like it was a regular server • Java • Tomcat (or whatever container you want) • Your application/data  Deploy the image to Azure • Use CSUpload.exe (part of the SDK) to upload the image  Create and deploy VM Role Hosted Service (use VS Studio) • For changes create and deploy a differencing VHD
  44. 44. Building and Deploying Java Applications for Azure Using a VM Role Live Demo
  45. 45. Issues/Considerations  The Good • Price competitively with regard to other cloud platforms • Java access to Azure Storage • Java access to AppFabric services • Other APIs (like Log4J Appender) are emerging  The OK • Documentation for tools/APIs is hit and miss • Containers using java.nio can run into issues. • Java access to SQL Azure  Its just JDBC – that’s the easy part  There are some potential issues  See US/windowsazuredata/thread/69f2de2f-389b-4c4e-9497-471b8094b029
  46. 46. Issues/Considerations  The Ugly (or at least still a little ugly) • Creating JRE/container CSPKG is clumsy  Not integrated into IDE yet  Customization can require knowledge of Windows Azure SDK, Powershell, Visual Studio, … • JRE/container image is huge and not quickly deployed  Use blob storage to improve • Custom configuration not always easy or allowed  Azure wants things in certain way (ports, etc.)  VM Role makes this better, but is a heavy infrastructure (probably not suitable for most developer laptops) • Troubleshooting is foreign territory  Remote desktop to Azure image is in beta  Remote debugging is not there yet
  47. 47. Future of Java and Azure  “…still a work in progress, but Microsoft’s goal is to be very open in its Java support.”3  Windows Azure is a growing and improving platform • Windows Azure SDK 1.3 recently released • AppFabric Caching in beta • Additional AppFabric services coming or in beta • Remote Desktop in beta • VM Role in beta • Extra Small Role in beta, 10-29-2010
  48. 48. Future of Java and Azure  Microsoft has made public statements regarding improved interoperability for Java • Announced for 2011 at MSFT’s Professional Developers Conference 2010 (November)  “Improved Java Enablement: Microsoft plans to make Java a first- class citizen on Windows Azure. This process will involve improving Java performance, Eclipse tooling and client libraries for Windows Azure. Customers can choose the Java environment of their choice and run it on Windows Azure.”3 • Better Eclipse support. • Windows Azure SDK for Java v2.0 coming soon • Better support for Java to SQL Azure 3
  49. 49. Intertech Copyright © Intertech, Inc. 2012 • • 800-866-9884 • Slide 53 Associated Courses and Resources Guide: Building Hybrid Cloud Applications on Windows Azure • Complete Azure Training • Windows Azure Startup Tasks
  50. 50. Thank you  Jim White –   Windows Azure Virtual UG •
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.