简体   繁体   中英

Azure Functions - Dynamic blob container in Blob binding

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

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM