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:
- Pre-generate Instrumentation Key for production environment (follow doc)
- Create environment specific ApplicationInsights.config like Web.config.
- 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.