Slide 1

Slide 1 text

AZURE WEBJOBS TO THE RESCUE @markvanstraten

Slide 2

Slide 2 text

AZURE WEB JOBS ARE SCHEDULED TASKS ON STEROIDS

Slide 3

Slide 3 text

RUN WHATEVER FLOATS YOUR BOAT .JS .PY .PHP .EXE .BAT . EXE .SH .CMD

Slide 4

Slide 4 text

C# WEBJOBS SDK = ♥

Slide 5

Slide 5 text

Azure Storage Queue Your web app var queueClient = Settings.GetWebjobStorageAccount.CreateCloudQueueClient(); var queue = queueClient.GetQueueReference("sendEmailQueue"); queue.CreateIfNotExists(); await queue.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject (new SendEmailQueueMessage { EmailTemplate = "succes", OrderId = 1234, Language = "nl" })));

Slide 6

Slide 6 text

QUEUES CONTAIN JSON

Slide 7

Slide 7 text

Azure Storage Queue Your Web Job private static void Main() { new JobHost().RunAndBlock(); } public async static Task SendEmail([QueueTrigger("sendEmailQueue")] SendEmailQueueMessage message, TextWriter logger) { logger.Write("Going to send email for order " + message.OrderId); }

Slide 8

Slide 8 text

AFTER FIVE RETRIES JOB IS PLACED IN POISON QUEUE

Slide 9

Slide 9 text

POISON QUEUE private static void Main() { new JobHost().RunAndBlock(); } public async static Task ProcessSendEmailPoisonMessage([QueueTrigger ("sendEmailQueue-poison")] SendEmailQueueMessage message, TextWriter logger) { logger.Write("Failed sending email for order " + message.OrderId); } Azure Storage Poison Queue Your Web Job

Slide 10

Slide 10 text

EASY DEVOPS ON QUEUES

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

FREE DASHBOARD

Slide 13

Slide 13 text

https://{mysite}.scm.azurewebsites.net/azurejobs

Slide 14

Slide 14 text

FTP MSDEPLOY

Slide 15

Slide 15 text

GOTCHAS

Slide 16

Slide 16 text

SITE OFF = WEBJOB OFF

Slide 17

Slide 17 text

ALL SLOTS

Slide 18

Slide 18 text

Solution: suffix queue names with app-version to let swapped old version deplete its own queue. sendemails-1.2.3 → sendemails-1.2.4 Con: Manual old queues cleanup after a few deploys

Slide 19

Slide 19 text

FURTHER READING http://azure.microsoft.com/en- us/documentation/articles/websites-dotnet-webjobs- sdk-get-started/ http://www.troyhunt.com/2015/01/azure-webjobs- are-awesome-and-you.html