【发布时间】:2019-06-09 16:47:51
【问题描述】:
我的 C# 预编译 Azure 函数的最终输出是以 JSON 文件的形式写入 Blob 存储。我写错了 Blob 存储吗?我在函数末尾的大括号上设置了断点,看起来它退出了函数。大约 20 秒后,我得到了异常:
执行函数时出现异常:ServiceBusTriggeredProcessAccepted。 Microsoft.Azure.WebJobs.Host:在函数返回后处理参数 outboundStringForBlobStorage 时出错:。 Microsoft.WindowsAzure.Storage:远程服务器返回错误:(500) 内部服务器错误。
Azure 函数是服务总线触发的事件。处理失败后,服务总线排队的项目会自动递增和重试,总共 10 次,然后才被移动到死信队列。应该注意的是对象的大小足够大,以至于常规队列对它们来说太小了。
public class SomeObject
{
//15 Properties all string and boolean
public string Attachment{ get; set;}
public string AnotherProperty{ get; set;}
public bool IsConditionMet { get; set; }
//Maybe these aren't needed now since it's blob storage but it's part of the object currently
public string PartitionKey { get; set; }
public string RowKey { get; set; }
}
[FunctionName("ServiceBusTriggeredProcessAccepted")]
public static void Run([ServiceBusTrigger("accepted")]
SomeObject someObject,
TraceWriter log,
[Blob("accepted-attachments/{Attachment}", FileAccess.Read)] Byte[] blobContent
, [Blob("accepted-sent/{rand-guid}.json")] out string outboundStringForBlobStorage
)
{
someObject.PartitionKey = "email";
someObject.RowKey = Guid.NewGuid().ToString();
//Business Logic to execute here
SomeService.SomeFunctionToSendBlobFile(someObject, blobContent)
outboundStringForBlobStorage = JsonConvert.SerializeObject(someObject);
}
我正在使用:
Azure Functions SDK NuGet 包 1.0.21
Microsoft.Azure.Webjobs 2.2.0
WindowsAzure.ServiceBus 5.0.0
DotNetFramework 4.6.1
Windows Azure 存储模拟器 5.8.0.0
运行时版本=1.0.11702.0
是否必须以某种方式对序列化进行清理?过去我不必进行消毒,但该对象中的数据已经改变,这就是问题开始发生的时候。我希望文件立即写入 blob 存储或立即返回异常,而不是在退出函数后 20 秒。
【问题讨论】:
标签: c# azure azure-functions azure-servicebus-queues azure-blob-storage