问题
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?????
回答1:
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(?) ...
来源:https://stackoverflow.com/questions/29222974/azure-webjobs-table-trigger