How to perfom switching config in Azure Websites Application Insights

0 votes
I have an Azure Website. For the sake of this question, the production version of the website runs on example.com, and a test version of the website runs on sandbox.example.com.

The only difference between the two is that they have a different configuration.

At present, they are running under different websites, and I deploy the same website to each azure website via git.

I'd like to separate out the Application Insights data. Is there a technique or process that anyone uses - apart from editing the ApplicationInsights.config file in the sandbox environment post deploy?

Or would using a deployment slot handle this in some way?
Sep 24, 2018 in Azure by null_void
• 3,220 points
687 views

1 answer to this question.

0 votes

There was a new blog post about exactly this today: Application Insights Support for Multiple Environments, Stamps and App Versions.

The destination of the telemetry is determined by the instrumentation key (iKey), which is sent along with every telemetry message. In the Application Insights portal, similar events and metrics with the same iKey are aggregated to give you charts of average durations, event counts, the sum of users, and so on. The iKey appears in two places in your project. One is in ApplicationInsights.config: <InstrumentationKey>94843456-2345-3456-4567-324562759284</InstrumentationKey>

If your application has web pages, the iKey also appears in a script in the head of every web page. Usually, it’s only coded once in a master page such as Views\Shared\_Layout.cshtml.

To direct telemetry to different application resources, we can create several resources with different iKeys. Then we only have to change the iKeys in the application at each transition in its lifecycle – along with other configuration data such as connection strings, certificates, and subscriptions.

The article then goes on how to do this in code, confg, etc:

1) Add iKey as a property in Web.config:

2) Instead of using the iKey from ApplicationInsights.config, we’ll set it in the code. In global.asax.cs.

To avoid confusion, remove the <InstrumentationKey> node from ApplicationInsights.config.

3) Configure the web pages to pick up instrumentationKey: "@Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey". This is the script usually found in View\Shared\_Layout.cshtml.

4) Don’t forget to update your Web.config with appropriate iKey configuration during the deployment process. You might devise a way of setting it appropriately as part of your build, but I’ll leave that to you.

answered Sep 24, 2018 by club_seesharp
• 3,450 points

Related Questions In Azure

0 votes
1 answer

How to automatically install Application Initialization in Azure Web Role (SDK v1.8) ?

Follow these steps - Install the feature using ...READ MORE

answered Apr 11, 2019 in Azure by Prerna
• 1,960 points
932 views
0 votes
1 answer

How to determine the number of messages in an Azure Services Bus Queue?

You will get error when you try ...READ MORE

answered Jun 12, 2018 in Azure by null_void
• 3,220 points
4,642 views
0 votes
1 answer

How to identify a deadlock in SQL Azure?

Monitoring of SQL Azure is more limited ...READ MORE

answered Jun 19, 2018 in Azure by club_seesharp
• 3,450 points
2,664 views
0 votes
1 answer

Azure Blob: How to open a file in browser without downloading it?

First, because I was using a byte[] the controller ...READ MORE

answered Jun 20, 2018 in Azure by club_seesharp
• 3,450 points
24,749 views
0 votes
1 answer

How to get the list of names of Azure blob files in a container?

We can get some additional info like Size, ...READ MORE

answered Jun 27, 2018 in Azure by club_seesharp
• 3,450 points
21,898 views
0 votes
1 answer

How to Unzip file uploaded to Azure Websites?

One way is to upload the command ...READ MORE

answered Aug 14, 2018 in Azure by null_void
• 3,220 points
2,715 views
0 votes
1 answer

How to serialize and de-serialize a PFX certificate in Azure Key Vault?

Here's a PowerShell script for you. Replace ...READ MORE

answered Sep 24, 2018 in Azure by club_seesharp
• 3,450 points
1,770 views
0 votes
1 answer

How to enable full WebJob logs in Azure?

The way to enable full (continuous) WebJobs ...READ MORE

answered Sep 24, 2018 in Azure by null_void
• 3,220 points
5,585 views
0 votes
1 answer

How can I remove/hide/disable excessive HTTP response headers in Azure/IIS7 without having to use UrlScan?

MSDN published an article on how to ...READ MORE

answered May 22, 2018 in Azure by club_seesharp
• 3,450 points
3,797 views
0 votes
1 answer

How to add an App Settings to existing Azure Web Application using Azure Power Shell?

The example is for slot-specific settings, if ...READ MORE

answered Jun 13, 2018 in Azure by club_seesharp
• 3,450 points
1,442 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP