java and windows azure tutorial

50
Java in the Microsoft Cloud Deploying Enterprise Applications to Windows Azure Jim White ([email protected] ) Director of Training, Instructor Intertech, Inc (www.intertech.com )

Upload: intertech-training

Post on 26-Jan-2015

108 views

Category:

Software


3 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Java and Windows Azure Tutorial

Java in the Microsoft Cloud Deploying Enterprise Applications to

Windows Azure

Jim White ([email protected])

Director of Training, Instructor

Intertech, Inc (www.intertech.com)

Page 2: Java and Windows Azure Tutorial

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

Page 3: Java and Windows Azure Tutorial

Session Demo: Please Visit Now

http://bit.ly/wherefrom

Enter your

• US Zip Code or

• Canadian Postal code

Attendee locations are

mapped

Page 4: Java and Windows Azure Tutorial

“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,

Page 5: Java and Windows Azure Tutorial

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 DevX.com

• Dir. Training, Instructor, Partner at

Intertech, Inc.

• Former architect at Target Corp.

Page 6: Java and Windows Azure Tutorial

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

Page 7: Java and Windows Azure Tutorial

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

Page 8: Java and Windows Azure Tutorial

BACKGROUND“If we are to go forward, we must go back…” – Martin Luther King

Page 9: Java and Windows Azure Tutorial

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?

Page 10: Java and Windows Azure Tutorial

What is cloud computing?

?

Page 11: Java and Windows Azure Tutorial

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…”

Page 12: Java and Windows Azure Tutorial

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 http://en.wikipedia.org/wiki/Cloud_computing

Page 13: Java and Windows Azure Tutorial

Cloud Ontology (a.k.a. Service Models)

Examples

Salesforce.com, NetSuite, Gmail,

SPSCommerce.net

Force.com, 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

Page 14: Java and Windows Azure Tutorial

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,…

Page 15: Java and Windows Azure Tutorial

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

Page 16: Java and Windows Azure Tutorial

Windows Azure Platform

12+ (and growing) Microsoft Data Centers across the globe. Warehousesfull 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…

Page 17: Java and Windows Azure Tutorial

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.

Page 18: Java and Windows Azure Tutorial

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

Page 19: Java and Windows Azure Tutorial

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 ??

Page 20: Java and Windows Azure Tutorial

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

Page 21: Java and Windows Azure Tutorial

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)

Page 22: Java and Windows Azure Tutorial

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

Page 23: Java and Windows Azure Tutorial

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 & StorageEmulator

Page 24: Java and Windows Azure Tutorial

Windows Azure Developer Portal(s)

Internet access to the

Microsoft cloud

• Subscribe

• Deploy

• Manage

• Tweak

• Billing

Page 25: Java and Windows Azure Tutorial

Publishing and Deploying Applications

“publish”

“deploy”

Page 26: Java and Windows Azure Tutorial

JAVA AND WINDOWS AZURE

“And now, here's something we hope you'll really like!” – Rocket

(Rocky) J. Squirrel

Page 27: Java and Windows Azure Tutorial

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

Page 28: Java and Windows Azure Tutorial

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

Page 29: Java and Windows Azure Tutorial

Java & Azure – What you need

The Basics

• Java 6 environment

• Windows Azure Account

www.microsoft.com/windowsazure/account/

• Windows Azure SDK – free

msdn.microsoft.com/en-us/library/dd179367.aspx

Tools for creating the packages/files for deployment to Azure

Provides DevFabric & DevStorage for testing locally

• Windows Azure SDK for Java – free

www.windowsazure4j.org/

API for accessing Azure Storage

Azure Service Management API

Page 30: Java and Windows Azure Tutorial

Java & Azure – What you also want

Additionally, for convenience (not required, but…)

• Windows Azure Tools for Eclipse - free

www.windowsazure4e.org/

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

www.jdotnetservices.com/

From Microsoft , Persistent Systems Limited and Schakra

Java API for accessing AppFabric services

Page 31: Java and Windows Azure Tutorial

Java & Azure - Conveniences

Other tools and API you may find handy

• Log4J Appender - free

https://github.com/blackwre/log4j-azure

Java Log4J API

Sends log messages to Windows Azure Table Storage

• Cerebrata Tools - < $100

www.cerebrata.com

Tools for exploring Azure Storage, logs, etc.

Cloud Storage Studio

Azure Diagnostics Manager

Page 32: Java and Windows Azure Tutorial

Java running in Azure

To run Java applications (and their containers) in Azure

• Tomcat Solution Accelerator

code.msdn.microsoft.com/winazuretomcat

Packages your Java Web application, Java and Tomcat for Azure

deployment as an Azure worker role

Approach can be used for other containers

See blogs.msdn.com/b/dachou/archive/2010/03/21/run-java-with-

jetty-in-windows-azure.aspx

• AzureRunMe

https://github.com/blackwre/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

Page 33: Java and Windows Azure Tutorial

Demo Application

Page 34: Java and Windows Azure Tutorial

Demo Application Architecture

1

2

3

With Java code external to the cloud

Page 35: Java and Windows Azure Tutorial

Demo Application Architecture

With Java code internal to the cloud

Page 36: Java and Windows Azure Tutorial

Java Accessing Azure Storage

Remember, Azure Storage = Queues, Blobs, Tables

How to access with Java

• Raw REST – for the sadomasochist

Reference guide: msdn.microsoft.com/en-us/library/dd179355.aspx

• Windows Azure SDK for Java

Let’s look at some example code

Page 37: Java and Windows Azure Tutorial

Access Azure Storage Code Examples

Azure Storage API

Message to a

queue

Page 38: Java and Windows Azure Tutorial

Access Azure Storage Code Examples

Azure Storage API

Read table data

Page 39: Java and Windows Azure Tutorial

Access Azure Storage Code Examples

Azure Storage API

Use blobs

There is also a blob

API for

programmatic

access

Page 40: Java and Windows Azure Tutorial

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 msdn.microsoft.com/en-us/library/gg433121.aspx

Page 41: Java and Windows Azure Tutorial

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

Page 42: Java and Windows Azure Tutorial

Building and Deploying Java

Applications for Azure

Using Tomcat Solution

Accelerator

Live Demo

Page 43: Java and Windows Azure Tutorial

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

Page 44: Java and Windows Azure Tutorial

Building and Deploying Java

Applications for Azure

Using a VM Role

Live Demo

Page 45: Java and Windows Azure Tutorial

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 social.msdn.microsoft.com/Forums/en-

US/windowsazuredata/thread/69f2de2f-389b-4c4e-9497-471b8094b029

Page 46: Java and Windows Azure Tutorial

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

Page 47: Java and Windows Azure Tutorial

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

3www.eweek.com, 10-29-2010

Page 48: Java and Windows Azure Tutorial

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

3http://www.microsoft.com/windowsazure/pdcannouncements/

Page 49: Java and Windows Azure Tutorial

Intertech

Copyright © Intertech, Inc. 2012 • http://www.Intertech.com • 800-866-9884 • Slide 53

Associated Courses and Resources

Guide: Building Hybrid Cloud Applications on Windows Azure

• Complete Azure Training

• Windows Azure Startup Tasks

Page 50: Java and Windows Azure Tutorial

Thank you

Jim White – [email protected]

www.intertech.com

Windows Azure Virtual UG

• http://azureug.net