我的项目中有以下功能:
[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 在本地运行函数时,出现此错误:
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的文档都说这是受支持的。
https://github.com/Azure/azure-webjobs-sdk/wiki/Blobs#-types-that-you-can-bind-to-blobs
你可能
引用了某个依赖于不兼容版本的WindowsAzure.Storage
程序集(版本 8.x.x
)的 NuGet 包。如果是这样,请务必将其删除。除非使用其他绑定,否则csproj
引用应如下所示:
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.6" />
</ItemGroup>
请确保运行的是 Azure 存储模拟器:
cd C:Program Files (x86)Microsoft SDKsAzureStorage Emulator
C:Program Files (x86)Microsoft SDKsAzureStorage 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'.