【问题标题】:“The type or namespace ‘BlobTrigger’ could not be found”“找不到类型或命名空间‘BlobTrigger’”
【发布时间】:2020-08-13 01:29:10
【问题描述】:

所以我是 C# 中 Azure 函数的新手,我正在尝试在 Visual Studio 中使用 BlobStorage 触发器进行创建。在遵循模板时,我得到了一个看起来像这样的文件:

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

提前致谢!

【问题讨论】:

  • 这就是你在 Azure Function 项目中的所有代码吗?
  • 是的,除了 local.settings.json 和 host.json 文件,但我没碰这些

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


【解决方案1】:

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

我有这个在你分享的代码中看不到的命名空间

使用 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" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-25
    • 2017-07-12
    • 2011-05-13
    • 2021-03-01
    • 2018-11-18
    • 1970-01-01
    相关资源
    最近更新 更多