Search code examples
c#asp.net-coreazure-active-directoryazure-application-insightsazure-application-insights-profiler

Retrieve logs from Application Insights Using C# .NET Core function


I am building an Azure Function application to write and retrieve logs in ApplicationInsights. I can able to write logs using instrumentation key.

But I don't know how to retrieve the logs from Application Insights. I have googled and got some references to retrieve it through AD credentials but I don't have AD access. Without AD credentials (ClientId, SecretKey), how can I retrieve the logs data from Application Insights?

I need some guidance. Thanks


Solution

  • After My test, I found a good blog and verify it. If you don't have AD credentials (ClientId, SecretKey), you can use AppInsightsId, AppInsightsAPIKey. You can find it like below.

    enter image description here

    There will be some problems in the direct test of the official document(you may found simillar issue here), please rest assured that the official should already know the existence of this problem. My sample Sample works fine. Please check the steps below.

    Steps

    1. Find the AppInsights Id and Key like the picture above.

    2. Test in Postman.

      enter image description here

    3. For more details, you can check the blog.

      RETRIEVE APP INSIGHTS LOGS FROM A FUNCTION USING API REST