Reputation: 1631
I have an Azure function triggered by an EventGridEvent
. I'm trying to store all events in Azure tables and give each table the name of the event.
This is how I would solve it without binding:
[FunctionName("MyFunction")]
public static async Task MyFunction([EventGridTrigger] EventGridEvent eventGridEvent)
{
var table = CloudStorageAccount.Parse(Environment.GetEnvironmentVariable("AzureWebJobsStorage")).CreateCloudTableClient().GetTableReference(eventGridEvent.EventType);
await table.CreateIfNotExistsAsync();
// etc...
}
But I would like to accomplish it with bindings.
This is what I tried:
[FunctionName("MyFunction")]
public static async Task MyFunction(
[EventGridTrigger] EventGridEvent eventGridEvent,
[Table("{EventType}")] CloudTable table)
{
}
I'm getting this error:
Microsoft.Azure.WebJobs.Host: Error indexing method 'MyFunction'. Microsoft.Azure.WebJobs.Host: Unable to resolve binding parameter 'EventType'. Binding expressions must map to either a value provided by the trigger or a property of the value the trigger is bound to, or must be a system binding expression (e.g. sys.randguid, sys.utcnow, etc.).
Surely EventType
is a property of EventGridEvent
which the trigger is bound to?
How should I access EventGridEvent.EventType
in the binding?
Upvotes: 1
Views: 815
Reputation: 6508
Unfortunately, for Event Grid trigger/binding, that kind of property binding expression (e.g. {EventType}
) is not supported. That's why you don't see that in Event Grid trigger doc as opposed to places where such binding is supported (e.g. Service Bus)
Upvotes: 3