如何将应用程序洞察力发布到REST API而不是ASP.NET Core应用程序中的Azure?

发布于 2025-02-10 07:08:34 字数 908 浏览 1 评论 0原文

我有一个ASP.NET Core 5.0 MVC Web应用程序和应用程序Insights启用。我正在尝试将应用程序洞察力数据发布到REST API,我使用nodejs开发了API。

我的appSettings.json详细信息如下。在这里,API得到触发,但我没有得到任何身体内容(Insight的数据)。

请引导我。提前致谢。

{
  "Logging": {
    "ApplicationInsights": {
      "LogLevel": {
        "Default": "Information",
        "Microsoft": "Warning",
        "Microsoft.Hosting.Lifetime": "Information"
      }
    },
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "ApplicationInsights": {
    "InstrumentationKey": "123",
    "TelemetryChannel": {
      "EndpointAddress": "http://localhost:3000/v2/track"
    }
  }
}

I have an ASP.NET Core 5.0 MVC web application and app insights enabled. I am trying to post application insights data to REST API, which I developed using nodejs.

My appsettings.json details are below. Here, API got trigger, but I'm not getting any body content (Insight's data).

Please guide me. Thanks in advance.

{
  "Logging": {
    "ApplicationInsights": {
      "LogLevel": {
        "Default": "Information",
        "Microsoft": "Warning",
        "Microsoft.Hosting.Lifetime": "Information"
      }
    },
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "ApplicationInsights": {
    "InstrumentationKey": "123",
    "TelemetryChannel": {
      "EndpointAddress": "http://localhost:3000/v2/track"
    }
  }
}

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

锦上情书 2025-02-17 07:08:34
  • 您将无法直接通过应用程序获取数据
    它不会直接将申请见解发送给您,但是
    将以BLOB存储的形式将其保存在存储帐户中。

  • 您可以做的是直接通过存储获取数据
    帐户或您可以从应用程序见解中获取数据。

  • 如果要从存储帐户中获取数据,则必须
    使用@azure/storage-blob带有节点JS的NPM软件包。

      const container = blobserviceclient.getContainerClient(continerName);
    const blockblob = contain.getBlockBlobClient(blobName); 
      const download =等待blockblob.download(0);
     
  • 您可以从容器部分下的门户中获取contain name
    存储帐户的

  • 另一种方法是在应用程序见解中运行查询。这可以通过提出HTTP请求来实现,并且必须通过Azure AD令牌或门户中的访问密钥来验证该请求。

      http获取https://api.applicationinsights.io/v1/apps/ {appid }/query?query= {query}
     

参考:
从应用程序见解中导出遥测 Anton Fritz

=“ https://learn.microsoft.com/en-us/rest/rest/api/application-insights/query/get” rel =“ nofollow noreferrer”>使用查询数据导出数据

  • You won't be able to get the data directly through the application as
    it will not send the application insights directly to you, but it
    will save it in the storage account in form of blob storage.

  • What you can do is either get the data directly through the storage
    account or you can get data from the application insights.

  • If you want to take data from the storage account, you will have to
    use @azure/storage-blob npm package with node js .

    const container = blobServiceClient.getContainerClient(containerName);
    const blockBlob = container.getBlockBlobClient(blobName); 
      const download = await blockBlob.download(0);
    
  • you can get containername from the portal under containers section
    of the storage account.

  • Another way would be to run a query in the application insights. This can be achieved by making http requests and the request has to be authenticated by either azure ad token or the access key which is in the portal.

     HTTP GET  https://api.applicationinsights.io/v1/apps/{appId}/query?query={query}
    

Reference:
Export telemetry from Application Insights by Anton Fritz

Export data using Query

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文