! { "action": { "type": "http", "request": { "uri": ", "method": "GET",

27

Transcript of ! { "action": { "type": "http", "request": { "uri": ", "method": "GET",

Kevin LamPrincipal Program ManagerScheduling jobs in the cloud with Azure Scheduler service

Scheduling jobs in the cloud with Azure Scheduler Service

3-620

Overview

REST API & Capabilities

Demo

Scheduling in Azure

Agenda

Scheduler Illustrated

Job

On-Prem Service

Cloud Hoster

Web Service

Relay

Jobs

History

Create Job

Get Job History

Windows Azure

Web Service

HTTP

Azure Scheduler

Scheduler Capabilities Overview

Management

•REST API•.NET Client•PowerShell•Portal Experience

Actions• HTTP &

Storage Queue Actions

• Error Handler

• Configurable Retry

Scheduling

•Fire once•Simple recurrence•Complex schedule

Monitoring

•Execution History

Geo-redundant service deployment

Geo-regional job replicationServiceHigh Availability Schedul

erNorth

Central US

Scheduler

South Central US

Job replication

Configurable Retry Policy

Alternate endpoint configurabilityJob

Reliability

AtlantaWeb Service(Secondary)

Jobs

History

New YorkWeb Service

(Primary)retryPolicy

Azure Scheduler

Scheduler REST API and Capabilities

REST RESTful API for managing Scheduler resources

Service Management API as Proxyhttps://management.core.windows.net/{subid}/cloudservices/{csname}/resources/scheduler/~/jobcollections/{jcname}/jobs/{jobname}

Inbound Security Authentication using subscription certificate

REST API

Entity Hierarchyhttps://management.core.windows.net/{subid}/cloudservices/{csname}/resources/scheduler/~/jobcollections/{jcname}/jobs/{jobname}/history jobcollections jobs history

Job Collections

Jobs History

Job

Azure Resource Created by the subscription owner

Unit of Organization or Management Can group jobs together based on usage or application boundaries Constrained to a region

Quotas Can apply quotas to constrain the usage of all jobs in that collection

{MaxJobs, MaxRecurrence}

URIhttps://management.core.windows.net/{subid}/cloudservices/{csname}/resources/scheduler/jobcollections/{jcname}

Job Collections Job Collections

jobcollections

JSON DefinitionActionError ActionRetry PolicyRecurrenceState Secure

Action is encrypted at rest

URIhttps://management.core.windows.net/{subid}/cloudservices/{csname}/resources/scheduler/~/jobcollections/{jcname}/jobs/{jobname}

Jobs Jobs

jobs

Describes a type of service invocation Call HTTP/s endpoint Post to a storage queue

Invoked on each occurrence

Job Action Job

Storage Queue with SAS Token Min privilege (add message access permission) Can be revoked and can expire

HTTPS Web Request with Basic Auth Add Base64 encoded username:password to Authorization header

"headers": { “Authorization": “Basic QWxhZGRpbjpvcGVulHNlc2FtZQ==“ }

HTTPS Web Request with Shared Secret Create secret such as a hash of the job URI + shared secret Add to custom security header Server verifies the security header such that the shared secret matches

Job Authentication Job

Start time Date-time for the first occurrence

Frequency One of minute, hour, day, week, month

Interval Interval at the given frequency for the recurrence

Prescribed schedule Specify minutes, hours, weekdays, month days of the recurrence

Completion Rule Count of occurrences End date

Recurrence schedule Job

Retry Policy Override the default retry policy with a different recurrence and count

or set it to ‘none’

Action invoked when primary action fails Call an error handling endpoint Call an alternative available endpoint for job reliability (endpoint high

availability)

Error Handling Job!

{ "action": { "type": "http", "request": { "uri": "http://my.cloudapp.net:8000/ItemService/GetTweets", "method": "GET", "headers": { "Content-Type": "text/plain", "x-myapp-auth": "<MYAPP_TOKEN>" }, },

// Call Contoso error endpoint if the main action has an error "errorAction": { "type": "http", "request": { "uri": "http://contoso.com/error", "method": "POST", "body": "Scheduler error", "header": { "Content-Type": "application/json" } } },

Putting it all together "retryPolicy": { "retryType": "fixed", "retryInterval": "PT1H", "retryCount": 5 }, }, "state": "enabled",

// Starting Friday occur on the last Friday of every month this year at 8:30am and 5:30pm "startTime": "2014-01-30T12:08:00-08:00", "recurrence": { "frequency": "month", "unit": 1, "endTime": "2014-12-31T23:00:00", "schedule": { "minute": 30, "hour": [8,17], "weekday": [ {"day": "friday", "monthlyOccurrence": -1} ] } },}

{ "action": { "type": "http", "request": { "uri": "http://bing.com", "method": "GET", "headers": {} } }}

Simple Job

Shows the result of job occurrences Execution status, start time, end time, response, …

Filter on execution status Last 2 months of job occurrences URIhttps://management.core.windows.net/{subid}/cloudservices/{csname}/resources/scheduler/~/jobcollections/{jcname}/jobs/{jobname}/history

History History

history

Demo

West US Backend(Secondary)

Jobs

History

Azure Scheduler

East US Backend(Primary)

Storage Queue Action

Storage Queue Action

Blob Store

Mobile Services Scheduled Scripts Run custom JavaScript as custom business logic on a schedule

Websites Scheduled WebJobs Run custom jobs (running executables or scripts) on a schedule

Azure Management Scheduling Scheduled AutoScaling Scheduled Website Backup Scheduled SQL Azure Database Backup

Azure Services Powered by Azure Scheduler

Backend scheduled workloads Xbox Video

Scheduling video publication content checks

Skype Data Scheduling Hadoop jobs for data analysis

Enabling scheduling capabilities GoFormz

Scheduled forms reports

Partners and Customers Powered by Azure Scheduler

Mobile Services Scheduled Scripts Effect data within the mobile service

Websites Scheduled WebJobs Effect data or processing within the website Simple way to host lightweight job on an existing website

Schedule Jobs Pre-existing endpoint Invoke workloads on other services (e.g., HDInsight with WebHCat) Invoke heavier workloads on worker roles using a storage queue

Scheduling Options in Azure

Channel 9 Cloud Cover episode Episode 127: Windows Azure Scheduler

http://channel9.msdn.com/Shows/Cloud+Cover/Episode-127-Windows-Azure-Scheduler

Channel 9 Azure Friday episodes Azure Scheduler 101 – Kevin Lam explains how to schedule stuff

http://channel9.msdn.com/Shows/Windows-Azure-Friday/Azure-Scheduler-101-Kevin-Lam-explains-how-to-schedule-stuff

Azure Scheduler 102 – Kevin Lam on strange or unusual schedules http://

channel9.msdn.com/Shows/Windows-Azure-Friday/Azure-Scheduler-102-Kevin-Lam-on-strange-or-unusual-schedules

Azure Scheduler 103 – Kevin Lam on the internals and details behind scheduled jobs http://

channel9.msdn.com/Shows/Windows-Azure-Friday/Azure-Scheduler-103-Kevin-Lam-on-the-internals-and-details-behind-scheduled-jobs

Resources

Live recording of John Gruber’s podcast: The Talk Show

TODAY 4:30 pm 2nd floor Press Room (2000)

Space is very limited so please arrive on time Drinks and apps will be served

The Talk Show

Your Feedback is Important

Fill out an evaluation of this session and help shape future events.

Scan the QR code to evaluate this session on your mobile device.

You’ll also be entered into a daily prize drawing!

© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.