0
votes

For an Azure Function(AF) one can select Application Insights (AI) in Azure Portal. All information put into ILogger in .Net application will be sent to this AI. But in my case AF and AI are running under different accounts. Is there any way to specify a sink for Ilogger using just the Instrumentation key?

I could directly use TelemetryClient from AI libraries, but I am not sure if all information will be sent before AF shuts down, and calling Flush at the end of each function seems wrong.

Edit: Different accounts means, different Active directories.

1
what do you mean that they are running under different accounts?Ivan Yang
I mean different AD. Resources in one do not have access to anotherKamil Aliyev

1 Answers

0
votes

You can directly add the application insights via Application Settings.

  1. Nav to azure portal -> your function app -> Configuration -> Application Settings.

  2. Then add these 2 settings:

    Key name: APPINSIGHTS_INSTRUMENTATIONKEY, and the value is the instrumentation key like xx22-xxdsds333.

    key name: APPLICATIONINSIGHTS_CONNECTION_STRING, and the value is InstrumentationKey=the instrumentation key.

    Then click the Save button.

    The screenshot is as below:

    enter image description here

  3. At last, you can use ILogger to write messages to application insights.