Reputation: 41
I need to created single azure function listening for multiple blob container. Is it possible?
Upvotes: 3
Views: 2879
Reputation: 15551
No, each Azure Function has exactly one trigger. However, there is an alternative. You can implement the processing of the blob in a generic method, define several Functions and have them all call the generic method.
Something like (pseudo code):
[FunctionName("BlobTriggerContainer1")]
public static async Task Run([BlobTrigger("container1/{name}")]Stream fileBlob, string name)
{
await DoTheMagicAsync(fileBlob, name);
}
[FunctionName("BlobTriggerContainer2")]
public static async Task Run([BlobTrigger("container2/{name}")]Stream fileBlob, string name)
{
await DoTheMagicAsync(fileBlob, name);
}
private void DoTheMagicAsync(Stream stream, string name)
{
// Do your (async) magic here
}
An alternative solution would be to use Azure Event Grid. For more info on how to combine these services, see Tutorial: Automate resizing uploaded images using Event Grid.
Upvotes: 3