Azure Function Blob Trigger CloudBlockBlob binding

烈酒焚心 提交于 2019-12-10 10:13:08

问题


I have the following Azure function triggered when a file is uploaded to Blob Storage

[FunctionName("ImageAnalysis")]
    public static async void Run(
        [BlobTrigger("imageanalysis/{name}", Connection = "AzureWebJobsStorage")] Stream myBlob, 
        string name, 
        TraceWriter log)
    {
        log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
    }

I want to process the Blob that has been uploaded so ideally I would like it as a CloudBlockBlob instead of a Stream. Then I can just do some work and then delete the blob.

myBlob.DeleteIfExists()

Is there an easy way to cast or convert my Stream to CloudBlockBlob or do I need to use input/output bindings or something else?

Looking through the docs I see examples which use CloudBlockBlob but I can't seem to get it to work so think I am missing something?


回答1:


Use this syntax for the binding. The trick is specifying FileAccess.ReadWrite in the attribute. The docs rather confusingly refer to this as "inout" for some reason.

[Blob("imageanalysis/{name}", FileAccess.ReadWrite, Connection = "AzureWebJobsStorage")] CloudBlockBlob blob, string name


来源:https://stackoverflow.com/questions/49384959/azure-function-blob-trigger-cloudblockblob-binding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!