Home > Blockchain >  Azure Functions - Dynamic blob container in Blob binding
Azure Functions - Dynamic blob container in Blob binding

Time:08-10

I need to add files to an Azure Storage Account using an Azure Function App with a Queuetrigger. But the container needs to be added dynamically. How is that possible?

        public static async Task Run(
            [QueueTrigger("activitylogevents", Connection = "StorageConnectionAppSetting")] Log activitylogevents,
Dynamic ==> [Blob("{dynamicc container}/dev/bronze/logs.json", FileAccess.Read)] Stream streamIn,
            ILogger log)
        { ... Code doing stuff ... }

Thanks

CodePudding user response:

You can make use of IBinder to dynamically define your BlobAttribute:

public static void MyFunction1(
[QueueTrigger("activitylogevents", Connection = "StorageConnectionAppSetting")] Log activitylogevents,
IBinder binderIn,
ILogger log)
{
    var blobInAttribute = new BlobAttribute(myUrl, FileAccess.Read) { Connection = "StorageConnectionAppSetting" };
    var streamIn = binderIn.Bind<Stream>(blobInAttribute);
    //other code
}
  • Related