I am trying to create an Azure WebJob to send a BrokeredMessage
to an Azure ServiceBus Topic, the actual act of creating and sending the message is trivial however I have been unable to find a way to automate the creation of the Scheduled WebJob.
The automated workflow should work as follows:
- Create a new Azure Website [Done]
- Create a new triggered Azure WebJob uploading a PS1 file [Done]
- Create a new Azure Scheduler Job Collection [Proven Concept]
- Create a new Azure Scheduler Job that triggers the WebJob
The Azure Management Portal provides a nice UI for this functionality, which under the covers creates an Azure WebJob in the selected WebSite, an Azure Scheduler Job Collection and an Azure Scheduler Job:
There doesn't appear to be an analogous mechanism for creating a scheduled Azure WebJob with the Azure Service Management PowerShell Module. It is certainly possible to create new WebJobs, Azure Scheduler Collections and Jobs - however I have no idea what URL or Storage Queue the Azure Scheduler is posting to to schedule Azure WebJobs.
There is a close relationship between Azure Scheduler and Azure WebJobs. Specifically Azure WebJobs does not have any internal support for scheduling, WebJobs relies on the Azure Scheduler to call into the
*.scm.azurewebsites.net
website.As such it is possible to use PowerShell cmdlets for these services to setup Azure WebJobs to be triggered on schedule using Azure Scheduler.
It's a little long winded so in plain english the above script does the following:
Hope this saves a few other developers from scratching their head trying to figure this one out.