c# - 如何在 HTTP 触发器 Azure Function 3.x 中获取操作 IS。附图片

标签 c# azure appinsights

我们需要 HTTP 触发器 Azure 函数内的 OperationId 值。我们怎样才能得到它。 Highlighted OperationID in the image

Fetching OperationId.png

最佳答案

您可以使用 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");
}

enter image description here

关于c# - 如何在 HTTP 触发器 Azure Function 3.x 中获取操作 IS。附图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66346488/

相关文章:

c# - 如何在 C# 中解析 OData $filter

azure - 如何使用 Azure 媒体服务设置 DRM 保护以防止屏幕捕获

azure - 如何通过azure使用现有数据?

javascript - 如何使用 azure 搜索 javascript sdk 设置 Appinsights

azure - 如何通过 KQL 获取嵌套 json 中的子值?

Azure函数应用程序使用slf4j登录App Insights

java - 处理版本控制的设计模式

c# - 使用 DI 和 InstanceContextMode.Percall 的自定义 ServiceHost

c# - 在 Visual Studio 的工具箱上应用过滤器?

Azure 管道循环