Azure Function Blob触发器CloudBlockBlob绑定 [英] Azure Function Blob Trigger CloudBlockBlob binding

查看:99
本文介绍了Azure Function Blob触发器CloudBlockBlob绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当文件上传到Blob存储时,我触发了以下Azure函数

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");
    }

我想处理已上传的Blob,因此理想情况下,我希望将其作为CloudBlockBlob而不是Stream.然后,我可以做一些工作,然后删除该Blob.

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()

是否有一种简单的方法可以将Stream转换或转换为CloudBlockBlob,还是需要使用输入/输出绑定或其他方法?

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?

在文档中浏览,我看到了使用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?

推荐答案

使用此语法进行绑定.诀窍是在属性中指定FileAccess.ReadWrite.出于某种原因,这些文档将其称为"inout".

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

这篇关于Azure Function Blob触发器CloudBlockBlob绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆