如何使用BlobTrigger绑定到Azure函数中的CloudBlockBlob? [英] How can I use a BlobTrigger to bind to CloudBlockBlob in an Azure Function?

查看:78
本文介绍了如何使用BlobTrigger绑定到Azure函数中的CloudBlockBlob?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中具有以下功能:

I have the following function in my project:

[FunctionName("my-func")]
public static async Task Run([BlobTrigger("data/{name}")] CloudBlockBlob blob, string name, TraceWriter log)
{
    log.Info($"Started Processing: {name}");

    await blob.DeleteAsync();

    log.Info($"Finished Processing: {name}");
}

当我尝试使用Azure Functions CLI v1.0.4在本地运行该函数时,出现此错误:

When I attempt to run the function locally using v1.0.4 of the Azure Functions CLI I get this error:

Microsoft.Azure.WebJobs.Host: Error indexing method 'SampleFunction.Run'. Microsoft.Azure.WebJobs.Host: Can't bind BlobTrigger to type 'Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob'.

我所见过的所有有关Azure Functions和WebJobs SDK的文档都说支持.

All documentation I have seen for Azure Functions and WebJobs SDK say this is supported.

https ://github.com/Azure/azure-webjobs-sdk/wiki/Blobs#-types-that-you-can-bind-blobs

推荐答案

您可能正在引用某些NuGet程序包,该程序包依赖于WindowsAzure.Storage程序集(版本8.x.x)的不兼容版本.如果是这样,请确保将其删除.除非您使用其他绑定,否则您的csproj引用应该看起来像这样简单:

You are probably referencing some NuGet package that has a dependency on non-compatible version of WindowsAzure.Storage assembly (version 8.x.x). If so, be sure to remove it. Unless you are using some additional binding, your csproj references should look as simple as this:

<ItemGroup>           
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.6" />
</ItemGroup>

这篇关于如何使用BlobTrigger绑定到Azure函数中的CloudBlockBlob?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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