Application Insights Module: Switch to Entra Auth

Application Insights for Sitcore Module

In February 2024, Microsoft Azure retired the 'Classic Application Insights' and forced people to migrate to 'Workplace-based' resources. In reality the migration involved very little effort or change, just a few clicks of the button. Luckily there was no change needed to the applications that sent the telemetry data and the instrumentation key remained the same in most situations.

What became apparent though is that Microsoft are also planning on retiring access to their application insights API using PI keys. This will be retired by 31 March 2026, this will be replaced by Microsoft Entra authentication for Application Insights. This currently how our Applications Insights Module queries the resource, so its clear some action is required to bring it up to date.

Switching to Entra

Microsoft advise you can either use a Managed Identity or a Service Principle. Whilst they recommend the former, I am more familar with service principles, so opted to take that route.

Register an App

  1. To register an app, open the Active Directory (Entra) Overview page in the Azure portal.
  2. Select App registrations from the side bar.
  3. Select New registration
  4. On the Register an application page, enter a Name for the application.
  5. Select Register
  6. On the app's overview page, select Certificates and Secrets
  7. Note the Application (client) ID. It's used in the HTTP request for a token.
  8. In the Client secrets tab Select New client secret
  9. Enter a Description and select Add
  10. Copy and save the client secret Value.

More info microsoft site: Register app for token

Set up authentication

  1. On the app's overview page, select API permissions.
  2. Select Add a permission.
  3. On the APIs my organization uses tab, search for Application Insights and select Application Insights API from the list.
  4. Select Delegated permissions.
  5. Select the Data.Read checkbox.
  6. Select Add permissions.

Grant access to your resource

  1. From your Application Insights resource overview page, select Access control (IAM).
  2. Select Add role assignment.
  3. Select the Reader role and then select Members.
  4. On the Members tab, choose Select members.
  5. Enter the name of your app in the Select box.
  6. Select your app and choose Select.
  7. Select Review + assign.

More info on microsoft site: Azure AD Authenticatoin

Configure / Reconfigure Sitecore Module

In order to start using Microsoft Entra Authentication with this module, you will need to download the latest version (from GitHub). When you install the new sitecore items, you will see the module root page (sitecore/system/Modules/ApplicationInsights) has some additional settings:

  • Enter Client ID
    find this in overview screen for Entra App - labelled 'Application (client) ID'
  • Entra Client Secret
    You should have saved this in step 10 of Register an App
  • Tenant ID
    find this in overview screen for Entra App - labelled 'Directory (tenant) ID'

If you are setting this up for the first time, you need to obtain the Application ID for each of the Application Insight resources that you want to monitor. You can find this by going to the resource and selecting the "API Access" pane. At the top of that screen you will see the required Application ID.

You then need to create a child under the main module root (page shown above), for each resource you want to monitor. Then add the Application ID and also title.

Application Insight config

Note: If you are upgrading the module, you will notice that the previous field ApplicationInsightsSecret has been removed. This is only required when querying the application Insights API using the old API keys method.

Finally, once you have added all of the resources. You can go back and define any dependencies between them, by selecting another resource in the dependencies. This determines which other resources to show in the graphic display at the top of the page (with arrows between them).

If you then go to Dashboard => Application Insights - You should see the module in action.

Leave a Reply

Your email address will not be published. Required fields are marked *