如何使用命令式绑定诊断Azure功能写入存储Blob的问题?

时间:2017-02-14 21:24:14

标签: azure-storage-blobs azure-functions

在之前的讨论主题中 (How to output multiple blobs from an Azure Function?) 它向我解释了如何使用命令式绑定从单个输出多个blob Azure函数调用。我采用这种方法取得了部分成功,需要指导 在诊断这个问题。我的函数触发blob,处理它并生成 多输出blob。基本上它是按日期划分大数据表。

当我用小blob(8K)触发它时它工作正常。当我处理更大的斑点(2M)时, 函数中的所有日志记录表明它已成功,但功能监视器 刀片显示它失败了:

失败:操作被取消。

同样,函数日志记录了所有日志,没有错误。

成功的调用耗时1785ms。

调用日志中多个条目失败的调用(我假设是因为 博客没有标记为已处理)。他们的时间都在12,000毫秒左右。那时 完全在函数的五分钟限制范围内。

我认为我已经通过命令式绑定超时达到了一些限制。 我正在寻求有关如何诊断和解决此问题的指导。我实际需要处理的文件最多可达20M,因此处理时间更长,但仍然不到5分钟。

function.json:

{
  "bindings": [
    {
      "name": "myBlob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "dms/{blobname}",
      "connection": "deal2_STORAGE"
    },
    {
      "type": "queue",
      "name": "emailQueueItem",
      "queueName": "emailqueue",
      "connection": "deal2_STORAGE",
      "direction": "out"
    }
  ],
  "disabled": false
}

run.csx

public static async Task Run(Stream myBlob, string blobname, IAsyncCollector<string> emailQueueItem, Binder binder, TraceWriter log)

{
  ...

    try {

    ...

        foreach (var dt in dates) {
                blobPath = $"json/{fileNamePart}_{dateString}";
                var attributes = new Attribute[] {
                  new BlobAttribute(blobPath),
                  new StorageAccountAttribute("deal2_STORAGE")
                };

                using (var writer = await binder.BindAsync<TextWriter>(attributes).ConfigureAwait(false)) {
                    writer.Write( jsonString.ToString() );
                }

        }

        ...

        await emailQueueItem.AddAsync( $"{{\"script\":\"DmsBlobTrigger\",\"tsvFileName\":\"{tsvFileName}\",\"status\":\"{retval}\",\"message\":\"{statusMessage}\"}}" );

    } catch (Exception excp) {
        Logger.Info(excp.ToString());
    }

}

0 个答案:

没有答案