我们需要 HTTP 触发器 Azure 函数内的 OperationId 值。我们怎样才能得到它。 Highlighted OperationID in the image
最佳答案
您可以使用 Activity.Current.RootId
获取门户中 HTTP 触发器内的操作 ID。
代码:
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using System.Diagnostics;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
log.LogInformation($"Activity Current RootId:{Activity.Current.RootId}");
string operationId = Activity.Current.RootId;
return new OkObjectResult("success");
}
关于c# - 如何在 HTTP 触发器 Azure Function 3.x 中获取操作 IS。附图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66346488/