简体   繁体   English

如何使用BlobTrigger绑定到Azure函数中的CloudBlockBlob?

[英]How can I use a BlobTrigger to bind to CloudBlockBlob in an Azure Function?

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

When I attempt to run the function locally using v1.0.4 of the Azure Functions CLI I get this error: 当我尝试使用Azure Functions CLI的v1.0.4在本地运行该函数时,出现以下错误:

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

All documentation I have seen for Azure Functions and WebJobs SDK say this is supported. 我所见过的有关Azure Functions和WebJobs SDK的所有文档都说支持。

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

You are probably referencing some NuGet package that has a dependency on non-compatible version of WindowsAzure.Storage assembly (version 8.xx ). 您可能引用了某些依赖于WindowsAzure.Storage程序集(版本8.xx )的不兼容版本的NuGet程序包。 If so, be sure to remove it. 如果是这样,请确保将其删除。 Unless you are using some additional binding, your csproj references should look as simple as this: 除非使用其他绑定,否则您的csproj引用应该看起来像这样简单:

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

Make sure you are running the Azure Storage Emulator: 确保您正在运行Azure存储模拟器:

cd C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator

C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator> AzureStorageEmulator.exe start
Windows Azure Storage Emulator 5.2.0.0 command line tool
Autodetect requested. Autodetecting SQL Instance to use.
Looking for a LocalDB Installation.
Probing SQL Instance: '(localdb)\MSSQLLocalDB'.
Found a LocalDB Installation.
Probing SQL Instance: '(localdb)\MSSQLLocalDB'.
Found SQL Instance (localdb)\MSSQLLocalDB.
Creating database AzureStorageEmulatorDb52 on SQL instance '(localdb)\MSSQLLocalDB'.

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

相关问题 Azure Function VS2017预览工具-如何绑定到CloudBlockBlob? - Azure Function VS2017 preview tooling - how to bind to CloudBlockBlob? 如何在HTTP触发的Azure函数中绑定模型集合? - How can I bind a collection of models in a HTTP triggered Azure Function? 如何将输出值绑定到异步Azure功能? - How can I bind output values to my async Azure Function? Azure 函数 blobtrigger 不应在子文件夹上触发 - Azure function blobtrigger should not trigger on subfolders Azure功能版本2.0 - 应用程序blobTrigger无法正常工作 - Azure function version 2.0 - app blobTrigger not working Azure 函数 - 在新 blob 上设置 CloudBlockBlob 元数据 - Azure function - Setting CloudBlockBlob metadata on a new blob 如何基于函数触发器中的属性绑定天蓝色函数输入? - How can I bind an azure function input, based on a property in the function trigger? Azure Web 作业 BlobTrigger - 重置 Scaninfo 以触发现有 Blob 的功能 - Azure Web Job BlobTrigger - Reset Scaninfo to trigger function for existing blobs 是否可以在上传 Azure CloudBlockBlob 的同时在其上设置元数据? - Can you set metadata on an Azure CloudBlockBlob at the same time as uploading it? 如何在Azure函数中绑定到MessageSender? - How to bind to MessageSender in an Azure function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM