简体   繁体   English

Azure功能Blob触发器CloudBlockBlob绑定

[英]Azure Function Blob Trigger CloudBlockBlob binding

I have the following Azure function triggered when a file is uploaded to Blob Storage 当文件上传到Blob存储时,我触发了以下Azure功能

[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. 我想处理已经上传的Blob,理想情况下我想将它作为CloudBlockBlob而不是Stream。 Then I can just do some work and then delete the blob. 然后我可以做一些工作,然后删除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? 有没有一种简单的方法可以将我的Stream转换或转换为CloudBlockBlob,还是需要使用输入/输出绑定或其他东西?

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? 通过文档查看我看到使用CloudBlockBlob的示例,但我似乎无法让它工作,所以想想我错过了什么?

Use this syntax for the binding. 使用此语法进行绑定。 The trick is specifying FileAccess.ReadWrite in the attribute. 诀窍是在属性中指定FileAccess.ReadWrite The docs rather confusingly refer to this as "inout" for some reason. 由于某些原因,文档相当混淆地将其称为“inout”。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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