Webjob始终发布为连续而非触发(Webjob always publishes as Continuous and not Triggered)

系统教程 行业动态 更新时间:2024-06-14 17:02:18
Webjob始终发布为连续而非触发(Webjob always publishes as Continuous and not Triggered)

我有一个Azure WebJob,我将从Visual Studio 2017发布到标准S1应用程序服务,WebJob应该由CRON触发但总是发布为Continuous,我无法弄清楚我做错了什么(其他两个WebJobs发布正常)

我在应用程序设置中将App Service设置为“Always On”

我的日程安排在根目录中有一个settings.job文件

{ "schedule": "0 3 5 * * 1-5" }

我的课程班

namespace EventPushUpdater { using Microsoft.Azure.WebJobs; using MBL.AzureKeyVaultHelpers; internal class Program { private static void Main() { Properties.Settings s = Properties.Settings.Default; IKeyVault kv = new KeyVaultHelper(s.ClientId, s.ClientKey, s.KeyVaultRoot); var config = new JobHostConfiguration(); config.DashboardConnectionString = kv.GetSecretValue(s.DashboardConnectionString); config.StorageConnectionString = kv.GetSecretValue(s.DashboardConnectionString); var host = new JobHost(config); host.Call(typeof(Functions).GetMethod("PushEvents"), new { keyVault = kv }); } } }

并调用该函数

public class Functions { [NoAutomaticTrigger] public static void PushEvents(IKeyVault keyVault) { // do stuff } }

I have an Azure WebJob which I am publishing from visual studio 2017 to a Standard S1 App Service, the WebJob should be Triggered by CRON but always publishes as Continuous and I cannot figure out what I have done wrong (two other WebJobs publish fine)

I have the App Service set to 'Always On' in application settings

I have a settings.job file in the root with my schedule

{ "schedule": "0 3 5 * * 1-5" }

My Program class

namespace EventPushUpdater { using Microsoft.Azure.WebJobs; using MBL.AzureKeyVaultHelpers; internal class Program { private static void Main() { Properties.Settings s = Properties.Settings.Default; IKeyVault kv = new KeyVaultHelper(s.ClientId, s.ClientKey, s.KeyVaultRoot); var config = new JobHostConfiguration(); config.DashboardConnectionString = kv.GetSecretValue(s.DashboardConnectionString); config.StorageConnectionString = kv.GetSecretValue(s.DashboardConnectionString); var host = new JobHost(config); host.Call(typeof(Functions).GetMethod("PushEvents"), new { keyVault = kv }); } } }

And the function being called

public class Functions { [NoAutomaticTrigger] public static void PushEvents(IKeyVault keyVault) { // do stuff } }

最满意答案

当您第一次选择“发布为WebJob”时,它会询问您是否需要连续或按需(包括已安排):

WebJob发布

如果您选择了错误的选项,只需删除属性下的webjob-publish-settings.json ,然后重试。

顺便说一句,您的代码过于复杂,因为您不必使用WebJobs SDK 。 相反,您的代码可以简单地:

static void Main() { // Do Stuff }

The first time you chose 'Publish as a WebJob', it asks you if you want Continuous or On Demand (which includes scheduled):

WebJob publish

If you picked the wrong choice, simply delete webjob-publish-settings.json under Properties, and try again.

As an aside, your code is overly complex as you're needlessly using WebJobs SDK. Instead, your code can simply be:

static void Main() { // Do Stuff }

更多推荐

本文发布于:2023-04-21 19:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/b8e2c77fce420ad82241dbc996395a43.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而非   Webjob   publishes   Triggered   Continuous

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!