0

我在 Azure 门户中开发了一个 Azure 时间触发功能,每天触发一次。触发函数昨天工作正常,但今天函数在运行该函数时突然返回以下错误。

2019-08-26T05:10:55.509 [Error] Function compilation error
2019-08-26T05:10:55.509 [Error] error CS0041: Unexpected error writing debug information -- 'The version of Windows PDB writer is older than required: 'diasymreader.dll''
2019-08-26T05:10:55.539 [Error] Exception while executing function: Functions.TimerTriggerCSharp1. Microsoft.Azure.WebJobs.Script: Script compilation failed.
2019-08-26T05:10:55.586 [Error] Function completed (Failure, Id=361874a9-10d7-4fc2-9a53-ec17f7a65a78, Duration=100ms)

下面是我创建的 project.json 文件。

{
  "frameworks": {
    "net46":{
      "dependencies": {
        "Microsoft.Azure.DocumentDB": "2.0.0"
      }
    }
   }
}

下面是 .csx 文件

#r "Microsoft.Azure.Documents.Client"

    using System;
    using Microsoft.Azure.Documents;
    using Microsoft.Azure.Documents.Client;
    using Microsoft.Azure.WebJobs.Host;
    using Newtonsoft.Json;

    public static async Task Run(TimerInfo myTimer,  IEnumerable<dynamic> 
    inputDocument, TraceWriter log)
    {
    log.Info($"C# Timer trigger function started at: {DateTime.Now}");

    // Get the date 6 months before from Current Time in IST and convert to Epoch value. 
    TimeZoneInfo INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India 
    Standard Time");
    DateTime indianTime =  
    TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow.AddDays(-180), 
    INDIAN_ZONE);


    long epochTime = (long)(indianTime - new DateTime(1970, 1, 
    1)).TotalSeconds;

    DocumentClient client;
    string endpoint = "https://***cosmosdb.documents.azure.com:443/";
    string key = "****";
    client = new DocumentClient(new Uri(endpoint), key);

    foreach (var doc in inputDocument)
        {
            string partKey = doc.NUM;
            StoredProcedureResponse<bool> sprocResponse = await 
    client.ExecuteStoredProcedureAsync<bool>(

   "/dbs/DB_NAME/colls/COLLECTION_NAME/sprocs/STORED PROC_NAME/",new 
    RequestOptions { PartitionKey = new PartitionKey(partKey) });

            log.Info($"Cosmos DB is updated at: {DateTime.Now}");
        }
    }

由于它昨天工作正常,这个错误突然失败的原因可能是什么?如何解决这个问题?触发函数是在 Azure 门户中开发的。

4

1 回答 1

0

但是该函数是时间触发函数,如果它抛出相同的错误会影响函数执行吗?

是的,它会影响函数的执行,无论是定时器触发还是队列触发。正如日志所说,Function completed (Failure,这意味着函数执行失败。

于 2019-08-28T09:00:11.310 回答