通过 Webhook url 触发 Azure Web 作业

use*_*025 5 azure azure-webjobs

我在使用 Webhook url 触发 Azure webjobs 时遇到问题。

我创建了一个简单的“NoAutomaticTriggerAttribute”Azure web 作业,下面是代码

例如:

 class Program
{
    // Please set the following connection strings in app.config for this WebJob to run:
    // AzureWebJobsDashboard and AzureWebJobsStorage
    static void Main()
    {
        var test = ConfigurationManager.ConnectionStrings["AzureWebJobsDashboard"].ConnectionString.ToString();
        var config = new JobHostConfiguration(test);

        if (config.IsDevelopment)
        {
            config.UseDevelopmentSettings();
        }

        var host = new JobHost(config);
        host.Call(typeof(Functions).GetMethod("ProcessMethod"));
        // The following code ensures that the WebJob will be running continuously
        host.RunAndBlock();
    }
}
Run Code Online (Sandbox Code Playgroud)

下面是函数类代码:

 public class Functions
{
    // This function will get triggered/executed when a new message is written 
    // on an Azure Queue called queue.

    [NoAutomaticTriggerAttribute]
    public static void ProcessMethod(TextWriter log)
    {
        log.WriteLine("This is First call from Main Method.");
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试使用 webhook url 调用 webjob 时:

https://sample.scm.azurewebsites.net/api/triggeredwebjobs/SampleWebJob2/run

它给出了这个回应:

“没有为‘/api/triggeredwebjobs/SampleWebJob2/run’注册路由”

AzureWebJobsDashboard 中未捕获任何详细信息

让我知道这是否是按需调用 Azure webjobs 的正确方法。有没有我在这里遗漏的任何设置。

请指导。

Geo*_*hen 7

确实有一些需要注意的地方?

  1. 部署 WebJob 时,请确保 WebJob 运行模式为按需运行。

在此处输入图片说明

  1. RunAndBlock()在main方法中delete ,否则会不停地运行,是为了连续的WebJob。
  2. 当您请求 WEBHOOK 确保设置正确的授权时,您可以在 WebJob 属性页面中获取 webhook 和名称、密码。这是邮递员页面。

在此处输入图片说明

在此处输入图片说明

然后您将能够从 WEBHOOK 运行 webjob。

在此处输入图片说明