我正在关注 Pluralsight 教程,它有点过时了,所以我试图填补空白。它说使用 BlobAttribute 来设置文件名,但我不断收到错误消息,指出找不到类型或命名空间。
我正在使用 CSX,但我一辈子都无法让它工作。当我将该行复制到 C# 测试函数应用程序中时,它工作得很好。我现在不想切换到那条路线,因为它不是教程的一部分,我试图坚持他们的流程,但他们也没有解释这一点。Microsoft.Azure.WebJobs using statements 主要只是我尝试让它工作。
任何想法如何让 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("-","")}");
}
}