c# - 找不到“The type or namespace ‘BlobTrigger’”

标签 c# azure .net-core compiler-errors azure-functions

所以我对 C# 中的 Azure 函数不熟悉,我正在尝试使用 BlobStorage 触发器在 Visual Studio 中创建。在遵循模板时,我得到了一个如下所示的文件:

using System;
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host.Triggers;
using Microsoft.Extensions.Logging;

namespace BasicAzureFunction
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([BlobTrigger("samples-workitems/{name}", Connection = "")]Stream myBlob, string name, ILogger log)
        {
            log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
        }
    }
}

我总是收到此错误:

The type or namespace name 'BlobTriggerAttribute' could not be found (are you missing a using directive or an assembly reference?)

我很确定我拥有所有包(这实际上是模板)。我错过了什么?

使用.Net Core

提前致谢!

最佳答案

我有一个也使用 BlobTrigger 的 Azure 函数,并且它对我来说工作正常。

我有这个命名空间,但在您共享的代码中没有看到

使用 Microsoft.WindowsAzure.Storage.Blob;

我的项目中有这些 Nuget 包

<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />

关于c# - 找不到“The type or namespace ‘BlobTrigger’”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61493675/

相关文章:

c# - XPathExpression AddSort 失败

azure - 在azure资源管理中通过template.json删除资源组

asp.net-core - 使用 dotnet pack 包含所有依赖项

c# - 传递参数以作为控制台或 GUI 应用程序启动?

java - 从继承类引用抽象类中声明的变量

c# - 无法将流作为参数传递给 aspnet.core.NodeServices 中的 JS

azure - 订阅未获取账单数据

azure - 将虚拟网络中的 Azure 云服务连接到 Azure SQL 数据库

azure - 从本地连接到 Azure Redis 时出现 Dapr 超时问题

unit-testing - dotnet 测试 Coverlet 错误覆盖