Can I invoke an Azure webjob from an Azure website and pass it parameters?

LeeKay picture LeeKay · Mar 8, 2014 · Viewed 12.4k times · Source

I have an Azure webjob that I want to invoke from an Azure website. I want to pass string parameters from the website to the webjob.

I know I can invoke the webjob as a REST API (https://github.com/projectkudu/kudu/wiki/Web-jobs).
So I can invoke the webjob without any parameters: POST jobs/triggered/myjobname/run

But adding parameters at the end doesn't appear to be working, i.e. jobs/triggered/myjobname/run?myparam1=value1

The information I see on using attributes in Microsoft.WindowsAzure.Jobs for binding doesn't mention my case, just binding to Azure storage items (http://blogs.msdn.com/b/jmstall/archive/2014/01/28/trigger-bindings-and-route-parameters-in-azurejobs.aspx).

Is what I want to do doable? Do I need to do something like create a new item in an Azure storage queue to trigger my webjob?

Thanks.

Answer

Cristian picture Cristian · Jul 15, 2015

You can invoke an azure webjob with parameters using the address: "https://mywebsite.scm.azurewebsites.net/api/triggeredwebjobs/mywebjob/run?arguments=myparameter"

class Program
{
    static void Main(string[] args)
    { 
        if (args[0]=="myparameter")
        ... 
    }
}

Some info in: https://github.com/projectkudu/kudu/pull/1183