azure - 类型或命名空间 "BlobAttribute"未找到

标签 azure azure-functions azure-blob-storage csx

我正在学习 Pluralsight 教程,它有点过时了,所以我试图填补空白。它说使用 BlobAttribute 来设置文件名,但我不断收到错误消息,指出未找到类型或命名空间。

我正在使用 CSX,但我一生都无法让它工作。当我将该行复制到 C# 测试函数应用程序中时,它工作得很好。我现在不想切换到该路线,因为它不是教程的一部分,我试图坚持他们的流程,但他们也没有解释这一点。 Microsoft.Azure.WebJobs using 语句主要是我在尝试让它工作。

有什么想法可以让 BlobAttribute 在 CSX 中工作吗?

#r "Newtonsoft.Json"
#r "Microsoft.Azure.WebJobs"
#r "Microsoft.Azure.WebJobs.Extensions"

using System;
using Newtonsoft.Json;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions;

public class Order
{
public string OrderID {get;set;}
public string ProductID {get;set;}
public string Email{get;set;}
public decimal Price {get;set;}
}

public static void Run(Order myQueueItem, ILogger log, IBinder binder)
{    
log.LogInformation($"C# Queue trigger function processed: 
{myQueueItem.OrderID}");

using(var outputBlob = binder.Bind<TextWriter>(new BlobAttribute($"{myQueueItem.OrderID}.lic")))    
{
    outputBlob.WriteLine($"OrderID: {myQueueItem.OrderID}");
    outputBlob.WriteLine($"ProductID: {myQueueItem.ProductID}");
    outputBlob.WriteLine($"Email: {myQueueItem.Email}");
    outputBlob.WriteLine($"Price: {myQueueItem.Price}");
    outputBlob.WriteLine($"Purchase Date: {DateTime.UtcNow}");

    var md5 = System.Security.Cryptography.MD5.Create();
    var hash = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(myQueueItem.Email + "secret"));
    outputBlob.WriteLine($"Secret Code: 
{BitConverter.ToString(hash).Replace("-","")}");
    }
}

最佳答案

解决同样的问题

  1. Visual Studio

Tools > NuGet Package Manager > Package Manager Console > Install-Package Microsoft.Azure.WebJobs.Extensions.Storage -Version 3.0.6

  • Visual Studio 代码
  • Terminal > cd <Working dir> > dotnet add package Microsoft.Azure.WebJobs.Extensions.Storage

    关于azure - 类型或命名空间 "BlobAttribute"未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54621615/

    相关文章:

    .net - 刚刚通过 NuGet 更新了 ImageResizer,无法运行应用程序,因为它找不到 BundleAttribute

    azure - 在 Azure 数据工厂 DataFlow 中根据文件名创建动态文件夹

    azure - 在 cspkg 中包含引用的程序集的配置

    azure - 为通过 Azure 函数输出绑定(bind)添加到 Azure 队列的消息设置 VisibilityTimeout

    node.js - 如何从适用于 Node.js 的 Azure blob v12 SDK 中删除 blob

    sql-server - BCP命令输出文件直接保存到云存储

    powershell - 使用 Azure SSAS 中的自动化帐户刷新多维数据集

    java - 如何更改 Azure Functions 中的日志级别

    c# - Azure 队列触发器与服务总线队列触发器,我需要哪一个?

    c# - Azure Function Blob 触发器将文件复制到文件共享