1
votes

I would like to link diagnostic data from an azure resource to Application Insights which is similarly described here: https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-dotnet-diagnostics-applicationinsights#configure-azure-diagnostics-to-send-data-to-application-insights

However, I would like to set up this data sending with automated deployments such as an ARM template or Azure CLI.

1

1 Answers

0
votes

By configuring Application Insights, Visual Studio adds an InstrumentationKey tag in ApplicationInsights.config file.

<InstrumentationKey>xxxx-xxxx-xxxx-xxxx-xxxx</InstrumentationKey>

Instrumentation Key is unique for each resource you want to send data to Application Insights. Following steps can be followed:

  1. Pre-generate Instrumentation Key for production environment (follow doc)
  2. Create environment specific ApplicationInsights.config like Web.config.
  3. CI-CD will pick environment specific config file.

Note - You can even automate Step# 1 as initial step in CI-CD pipeline using PowerShell scripts. And another step to modify config file accordingly, again using PowerShell.

Edit - After comments it is known that some diagnostics log from Stream Analytics need to be sent to Application Insights. I would recommend using Azure Functions along with Stream Analytics. Azure Functions can send data to App Insights. It will depend on how diagnostic log is getting generated.

Any Azure deployment can be done using ARM templates. Or you can create this set up on Dev environment and then export the ARM template, edit it for other environments.