Continuous Azure WebJob with Http Features Launched

I currently have an azure webjob that performs daily synchronization from one database to another, but would like to add the ability to manually start synchronization. I created the following functions in a webjob project:

public static void SyncData([TimerTrigger("0 0 5 * * *", RunOnStartup = false)] TimerInfo timerInfo) { }

[NoAutomaticTrigger]
public static Task SyncAll(TraceWriter log){ }
[NoAutomaticTrigger]
public static Task SyncBranches(TraceWriter log){ }
[NoAutomaticTrigger]
public static Task SyncCustomers(TraceWriter log){ }
[NoAutomaticTrigger]
public static Task SyncInventory(TraceWriter log){ }

I can see the functions in the Kudu control panel under the webjob, but I donโ€™t know how I can run the functions with the http request specified in the MS documentation ( here ):

http://<yourapp>.azurewebsites.net/api/<funcname> 

When I make a request to this endpoint, I get a 404 response - what do I need to do to start these functions manually through an HTTP request?

Thanks Ryan

+4
source share
2 answers

Kudu API WebJob

POST https://{user}: {password} @{sitename}.scm.azurewebsites.net/api/continuwebjobs/{ }/start

Azure WebApp publishSetting.

enter image description here

API Rest

enter image description here

. Azure, .

Update:

, ?

, Rest API .

, Webjob QueueTrigger. , sepicific. WebJob QueueTrigger

.

1. Azure

enter image description here

2. Webjob

 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. Azure API- REST .

4. .

enter image description here

+3

Azure, , WebJobs ( Azure).

Azure Functions , .

0

Source: https://habr.com/ru/post/1672391/


All Articles