cut your hair and get an azure webjob

25
CUT YOUR HAIR AND GET AN AZURE WEBJOB! Mark Greenway @MarkKGreenway Who | What | When | Where | Why | How | OMG WHY?!

Upload: mark-greenway

Post on 26-May-2015

74 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Cut your hair and get an azure webjob

CUT YOUR HAIR AND GET AN AZURE WEBJOB!

Mark Greenway@MarkKGreenway

Who | What | When | Where | Why | How | OMG WHY?!

Page 2: Cut your hair and get an azure webjob

THANKS SPONSORS!

Who | What | When | Where | Why | How | OMG WHY?!

Page 3: Cut your hair and get an azure webjob

Who the #$@& is this guy??

Him

WHO | What | When | Where | Why | How | OMG WHY?!

Page 4: Cut your hair and get an azure webjob

What is an Azure WebJob?

Who| WHAT | When | Where | Why | How | OMG WHY?!

Location NameAzure PaaS WebJobAzure PaaS

(old)Worker Role

Heroku WorkerApp Harbor Worker Unithttps://flic.kr/p/5uJsLG

Page 5: Cut your hair and get an azure webjob

What is an Azure WebJob?

Who| WHAT | When | Where | Why | How | OMG WHY?!

Options

Powershell

.BAT (Batch file)

Node.JS

Python

.exe

.NET Applicationhttps://flic.kr/p/a2qceu

Page 6: Cut your hair and get an azure webjob

What is an Azure WebJob?

Who| WHAT | When | Where | Why | How | OMG WHY?!

Can’t do

Run Servers

Invoke Server Applications

https://flic.kr/p/a2qceu

Page 7: Cut your hair and get an azure webjob

When Does an Azure WebJob Run?

Who| What | WHEN | Where | Why | How | OMG WHY?!

1. Triggered

2. Continuous

© 2013 Tim Buss

Page 8: Cut your hair and get an azure webjob

When Does an Azure WebJob Run?

Who| What | WHEN | Where | Why | How | OMG WHY?!

1. Triggered

© 2013 Tim Buss

• Scheduled• Manual

Page 9: Cut your hair and get an azure webjob

When Does an Azure WebJob Run?

Who| What | WHEN | Where | Why | How | OMG WHY?!

2. Continuous

© 2013 Tim Buss

• Runs All The Time (with Always On)• .NET Triggers Run (with SDK)

Page 10: Cut your hair and get an azure webjob

Where Does an Azure WebJob Run?

Who| What | When | WHERE | Why | How | OMG WHY?!

1. With An Azure Website (W/AWS)

https://flic.kr/p/7fXoky

• Logically bound to a particular site• Deployment options• Separate Manual Deployment• CLI• Web Interface

• Continuous Deployment with site• 1 …n

Page 11: Cut your hair and get an azure webjob

Where Does an Azure WebJob Run?

2. With Only Other Azure WebJobs

https://flic.kr/p/ajkTkm

• Not Logically bound to a particular site• Deployment options• Separate Manual Deployment• CLI• Web Interface

• Independent git et al. deployments.• 1 …n

Who| What | When | WHERE | Why | How | OMG WHY?!

Page 12: Cut your hair and get an azure webjob

Who| What | When | Where | WHY | How | OMG WHY?!

Why Use A WebJob:• Process Log Files• Process Orders• Migrate Deleted Items to Long term

storage• Compress Uploaded Images• Add Watermarks to Images• Run Nightly Tasks• Import on premise data to azure• Manage Videos for Smooth Streaming • RSS Aggregation• Migrating Log Files• Long Running Tasks

• Complex Creation of User Records• Interaction with slow 3rd party systems• Convert JSON to XML • Email users• Decoupling• Scalability• OCR• Billing

Page 13: Cut your hair and get an azure webjob

How to Manually Upload A WebJob :

1. Put files into a folder 2. Zip all the files in the folder 3. Go to Web or CLI

Who| What | When | Where | Why | HOW | OMG WHY?!

Page 14: Cut your hair and get an azure webjob

How to “PiggyBack” Upload A WebJob :

1. Put files into a folder 2. Copy that folder to

App_Data/jobs/[continuous,triggered]/3. Deploy As Usual

Who| What | When | Where | Why | HOW | OMG WHY?!

Page 15: Cut your hair and get an azure webjob

How to Continuously Upload A WebJob :

Who| What | When | Where | Why | HOW | OMG WHY?!

1. Create Project in Same Solution2. Modify Build to copy that folder to

App_Data/jobs/[continuous,triggered]/3. Deploy As Usual

Page 16: Cut your hair and get an azure webjob

How to Continuously Upload A WebJob :

1. Create Project in Same Solution2. Modify Build to copy that folder to

App_Data/jobs/[continuous,triggered]/3. Deploy As Usual

*Heavily Photoshopped for Clarity

Who| What | When | Where | Why | HOW | OMG WHY?!

Page 17: Cut your hair and get an azure webjob

How to create a .NET WebJob

Who| What | When | Where | Why | HOW | OMG WHY?!

1. File -> New -> Console Application 2. Add NuGet Packages for extra tooling

Page 18: Cut your hair and get an azure webjob

How to create a .NET WebJob

Who| What | When | Where | Why | HOW | OMG WHY?!

static void Main(){ var host = new JobHost(); host.RunAndBlock();}public static void AzureQueue([QueueTrigger("myqueue")] string userJson) {}public static void AzureQueueObject([QueueTrigger("myqueue")] Person person) {}public static void SbQueue([ServiceBusTrigger("sbqueue")] string person) {}public static void SbQueueObject([ServiceBusTrigger("sbobjectqueue")] Person person) {}public static void Resize( [BlobTrigger(@"images-input/{name}")] WebImage input, [Blob(@"images-output/{name}")] out WebImage output) {}

Page 19: Cut your hair and get an azure webjob

How to TEST a .NET WebJob

Who| What | When | Where | Why | HOW | OMG WHY?!

//IN WEBJOB CLASSpublic static Person LastPerson { get; set; }public static void SbQueueObject([ServiceBusTrigger("sbobjectqueue")] Person person){ LastPerson = person; Console.WriteLine("Service Bus Object Queue : {0}", person);}

//IN TEST CLASS[Test]public void PersonSetsLastPerson(){ var dawn = PersonCreator.CreatePerson("Dawn"); ImageProcessing.SbQueueObject(dawn); Assert.AreEqual(dawn,ImageProcessing.LastPerson);}

Page 20: Cut your hair and get an azure webjob

How to Debug a .NET WebJob

Who| What | When | Where | Why | HOW | OMG WHY?!

https://cutyourhair.scm.azurewebsites.net/azurejobs/#/jobs

Page 21: Cut your hair and get an azure webjob

1.Use A Backplane2.Post Directly to the Backplane

How to Update SignalR from a WebJob

Who| What | When | Where | Why | How | OMG WHY?!

Page 22: Cut your hair and get an azure webjob

How to Update SignalR from a WebJob

Who| What | When | Where | Why | How | OMG WHY?!

Page 23: Cut your hair and get an azure webjob

How to Update SignalR from a WebJob

Who| What | When | Where | Why | How | OMG WHY?!

Page 24: Cut your hair and get an azure webjob

Who| What | When | Where | Why | How | OMG WHY?!

https://twitter.com/rustdPranav RastogiProgram Manager, Azure WebJobs, ASP.NET

http://blog.amitapple.com/Amit AppleSenior Software Developer, Azure Web Sites

Who To Follow:

http://twitter.com/shanselmanScott HanselmanMicrosoft

http://Friday.Azure.com

Learn More:

Page 25: Cut your hair and get an azure webjob

Who| What | When | Where | Why | How | OMG WHY?!

Mark Greenway@MarkKGreenway

http://www.slideshare.net/MarkKGreenway/cut-your-hair-and-get-an-azure-webjob-37937899