So I had an application recently that needed to use AppInsights. The application was deployed using Visual Studio Release Management so everything needed to be deployed using the Azure Resource Management template.
You can’t specify an instrumentation key. It is created automatically upon creation.
Retrieve the key directly from within the template.
Here’s a trimmed down version of an ARM template that does exactly this.
See that little AppSettings named
InstrumentationKey? That’s where the magic happens.
Your instrumentation key is now bound to your WebApp AppSettings without carrying magic strings.