Launch WebJobs from Fiddler or your application

On several occasions I have spoken of the WebJobs associated with Microsoft Azure Websites, and how we can convert a console application using this service or even launch WebJobs actions using queues or blobs. This time I wanted to show how it is possible run a WebJob from Fiddler or even from our own application.

Download the publish profile

To call a WebJob you must be authenticated but what credentials? With the publish profile. When you use Web Deploy, and you have associated Visual Studio to a Microsoft Azure account, this is a transparent step for us: the IDE download an XML file, which completes the deployment information:

Publish Web

To download the file simply select the website where it hosts the WebJob and click on the Download the publish profile link in the quick glance section:

quick glance - download the publish profile

This file contains the credentials of deployment and publishing (Web Deploy and FTP). For this post, you need to copy the values for: userName (without the site name) and the hash of the password stored in userPWD.

The next step is to know where we have to call to run the WebJob. It is not sufficiently visible on the portal, but there is a URL for each WebJob we created. The pattern is Only when we create a scheduled one we can access this information by clicking on the Schedule link WebJob:

Website - WebJob - Schedule link

This will lead to service Scheduler where you can see all those WebJobs that are being released on a scheduled basis:

Scheduler WebJobs

If you click on a WebJob, you can see a section called job action, where you can check its setup:

Scheduler job action

The Scheduler service is performing a POST call to the URL mentioned above with the Authorization header with the credentials are included in publish profile, and a Content-Type using text/plain.

If you don’t have any scheduled WebJob, you can use the texbox in this post for getting a base64 string composed of userName: userPWD

Call from Fiddler

Ready! Now We know how call to WebJobs!. In this example I have used Fiddler to perform the test:

Fiddler calling a WebJob

The result of this action should be a 202 (Accepted). Furthermore, you can check the WebJob logs at the following URL:

WebJob Recent job runs

Hope this helps.