Azure WebJobs-未找到功能-如何进行无触发器作业? [英] Azure WebJobs - No functions found - How do I make a trigger-less job?

查看:79
本文介绍了Azure WebJobs-未找到功能-如何进行无触发器作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Azure WebJobs的新手,我运行了一个示例,其中用户将图像上载到Blob存储并将记录插入到队列中,然后作业从队列中检索该记录作为信号,以执行调整大小的操作上传的图片.基本上,在代码中,作业使用公共静态方法上的QueueTrigger属性来完成所有操作.

I'm new to Azure WebJobs, I've run a sample where a user uploads an image to blob storage and inserts a record into the Queue, then the job retrieves that from the queue as a signal to do something like resizing the uploaded image. Basically in the code the job uses QueueTrigger attribute on a public static method to do all that.

现在,我需要一项工作,该工作每小时执行一次操作,例如将记录插入数据库表中,它没有任何类型的触发器,它本身就可以运行.我该怎么办?

Now I need a job that just does something like inserting a record into a database table every hour, it does not have any type of trigger, it just runs itself. How do I do this?

我试图有一个静态方法,在其中我执行了对db的插入操作,虽然确实开始了工作,但是却收到一条消息,提示:

I tried to have a static method and in it I do the insert to db, the job did start but I got a message saying:

未找到功能.尝试公开职业分类和方法公开 静态的.

No functions found. Try making job classes public and methods public static.

我想念什么?

修改 Victor回答后,我尝试了以下方法,

Edit After Victor's answer I tried the following,

static void Main()
{
    JobHost host = new JobHost();
    host.Call(typeof(Program).GetMethod("ManualTrigger"));
}

[NoAutomaticTrigger]
public static void ManualTrigger()
{
    // insert records to db
}

但是这次我得到了InvalidOperationException

无法从Azure WebJobs SDK调用'Void ManualTrigger()'.是否缺少Azure WebJobs SDK属性?

'Void ManualTrigger()' can't be invoked from Azure WebJobs SDK. Is it missing Azure WebJobs SDK attributes?

推荐答案

如果您不使用WebJobs SDK中的任何输入/输出属性(QueueTrigger,Blob,Table等),则必须使用NoAutomaticTrigger SDK可以识别的属性.

If you don't use any input/output attributes from the WebJobs SDK (QueueTrigger, Blob, Table, etc), you have to decorate the job with the NoAutomaticTrigger Attribute to be recognized by the SDK.

这篇关于Azure WebJobs-未找到功能-如何进行无触发器作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆