我有一个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-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):
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 }更多推荐
发布评论