We can use the Kudu WebJob API to start or stop a continuous job
POST https://{user}:{password}@{sitename}.scm.azurewebsites.net/api/continuouswebjobs/{job name}/start
We can get user and password info from the Azure WebApp publishSetting file. And We can download the file from the portal
![enter image description here]()
Test the Rest API using the fiddler
![enter image description here]()
Note: How to create Azure function please refer to the document.
Update:
is there a way I can trigger a specific function in that continuous job?
Based on my experience, I can't find a way or Rest API to trigger a sepcific function in continuous job directly.
My work around is that we can use Webjob QueueTrigger. According the queue message info to trigger the sepcific function.
We can create a WebJob with QueueTrigger
The following is my detail steps according to your code.
1.Create an Azure storage queue for trigger
![enter image description here]()
2.Create a Webjob project and add the following code
public static void SyncData([QueueTrigger("backup")] string logMessage, TextWriter logger)
{
Console.WriteLine($"Start time:{DateTime.Now}");
switch (logMessage.ToLower())
{
case "syncall":
SyncAll(logger);
break;
case "syncbranches":
SyncBranches(logger);
break;
case "synccustomers":
SyncCustomers(logger);
break;
case "syncinventory":
SyncInventory(logger);
break;
default:
Console.WriteLine("Default case");
break;
}
Console.Write($"Endtime:{DateTime.Now}");
}
[NoAutomaticTrigger]
public static Task SyncAll(TextWriter log)
{
Console.WriteLine("SyncAll :"+DateTime.Now);
return null;
//await Task.Delay(10);
}
[NoAutomaticTrigger]
public static Task SyncBranches(TextWriter log)
{
Console.WriteLine("SyncBranches :" + DateTime.Now);
return null;
}
[NoAutomaticTrigger]
public static Task SyncCustomers(TextWriter log)
{
Console.WriteLine("SyncCustomers :" + DateTime.Now);
return null;
}
[NoAutomaticTrigger]
public static Task SyncInventory(TextWriter log)
{
Console.WriteLine("SyncInventory :" + DateTime.Now);
return null;
}
3.Use Azure Storage Queue REST API to create a queue message.
4.Check result the from the console.
![enter image description here]()