Azure WebJobs表触发器 [英] Azure WebJobs Table Trigger

查看:54
本文介绍了Azure WebJobs表触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

和往常一样,从来都不是简单的事情.有50亿个绑定到BLOB和队列的示例,但是我找不到任何能绑定到表的东西.我有一个名为Foo的表,当webjob运行时,我会通过Azure Storage Explorer将数据添加到(PK和RK),并且触发器永远不会被命中.这是Functions.cs中存在的方法,该方法可在启动Webjob时识别:

public static void ReadTable([Table("Foo")] ICollector<TableEntity> tableBinding, TextWriter logger)

这个签名是一个猜测,因为有无数有关旧签名的博客,等等.我尝试了3个小时,更改了所有可编译的内容,但找到了适用于WebJob和Tables的ZERO文档.

Main()是:

static void Main()
{
    var host = new JobHost();
    // The following code ensures that the WebJob will be running continuously
    host.RunAndBlock();
}

已为AzureWebJobsDashboard和AzureWebJobsStorage正确设置了2个配置条目.

也:

<package id="Microsoft.Azure.WebJobs" version="1.0.1" targetFramework="net45" />
  <package id="Microsoft.Azure.WebJobs.Core" version="1.0.1" targetFramework="net45" />

为什么这不起作用?????

解决方案

您实际上并未在代码中添加触发器".

这不是您的错,因为当前只有:Microsoft.Azure.WebJobs命名空间中的QueueTrigger和BlobTrigger.没有TableTrigger.

....

根据
 public static void TableDict([Table("mytable")] IDictionary<Tuple<string, string>, OtherStuff> dict)
  {
    ...    
  }

我能看到的监视并在Azure表的新行上触发并触发事件"的唯一方法是对表进行任何写入,而是写入新的队列消息,然后可以将所有逻辑触发为以及insert(?)...

As usual, what should be simple NEVER is. There are 5 billion examples of binding to BLOBs and queues, but I cannot find anything which works for binding to Tables. I have a table named Foo, which I add data to (PK and RK) via Azure Storage Explorer while the webjob is running and the trigger never gets hit. Here is the method living in Functions.cs which is recognized upon webjob start:

public static void ReadTable([Table("Foo")] ICollector<TableEntity> tableBinding, TextWriter logger)

This signature is a guess as there is endless blogs on old signatures, etc. I have tried for 3 hours, changing anything that compiles but have found ZERO documentation that applies forWebJob and Tables.

The Main() is:

static void Main()
{
    var host = new JobHost();
    // The following code ensures that the WebJob will be running continuously
    host.RunAndBlock();
}

The 2 config entries are properly set for both AzureWebJobsDashboard and AzureWebJobsStorage.

Also:

<package id="Microsoft.Azure.WebJobs" version="1.0.1" targetFramework="net45" />
  <package id="Microsoft.Azure.WebJobs.Core" version="1.0.1" targetFramework="net45" />

Why is this not working?????

解决方案

You didn't actually add a "Trigger" to your code.

Which is not your fault as, currently there is only : QueueTrigger and BlobTrigger in Microsoft.Azure.WebJobs namespace. No TableTrigger.

....

but (there's always a but), according to Mike Stall "Functions are not triggered on table changes. However, once a function is called for some other reason, it can bind to a table as a read/write resource for doing its task. "

 public static void TableDict([Table("mytable")] IDictionary<Tuple<string, string>, OtherStuff> dict)
  {
    ...    
  }

The only way I could see to 'monitor and fire and event on a new row on an Azure Table' would be to have whatever writes to the table, write a new Queue Message instead, which then can fire all your logic as well as do an insert(?) ...

这篇关于Azure WebJobs表触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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