API keys for querying data from Azure Monitor application insights will be retired

Danny Fournier 0 Reputation points
2025-04-24T11:01:29.45+00:00

We received an email with the following title: API keys for querying data from Azure Monitor application insights will be retired on 31 March 2026 — transition to using Azure AD.

We're currently using connection strings when sending data to Application Insights. Do we need to migrate to Azure AD?

cfg: { // Application Insights Configuration
  connectionString:"InstrumentationKey=<?= Configure::read("AppInsightInstrumentationKey") ?>;"
}});

We're also doing Curl calls by sending POST to the following API endpoint:

https://api.applicationinsights.io/v1/apps/*instrumention_key_here*/query
Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,606 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Kyle Burns 91 Reputation points Microsoft Employee
    2025-04-24T13:15:33.52+00:00

    As you are using curl, I thought it may be helpful for me to extend the previous answer with some additional context specific to curl. To help you transition from using instrumentation keys to using Azure Active Directory (Azure AD) authentication for retrieving data from Application Insights with curl, here is a detailed explanation along with relevant samples.

    Transitioning from Instrumentation Keys to Azure AD Authentication

    Step 1: Register an Application in Azure AD

    1. Go to the Azure portal and navigate to Azure Active Directory.
    2. Select App registrations and click on New registration.
    3. Provide a name for the application and click Register.
    4. Once registered, note down the Application (client) ID and Directory (tenant) ID.

    Step 2: Configure API Permissions

    1. In the registered application, go to API permissions.
    2. Click on Add a permission and select APIs my organization uses.
    3. Search for Application Insights and select it.
    4. Choose Application permissions and select Telemetry.Read.
    5. Click Add permissions and then Grant admin consent.

    Step 3: Create a Client Secret

    1. In the registered application, go to Certificates & secrets.
    2. Click on New client secret and provide a description.
    3. Set an expiration period and click Add.
    4. Note down the Value of the client secret as it will be used in the curl command.

    Step 4: Retrieve Data Using curl

    1. Obtain an access token using the client credentials flow.
    2. Use the access token to make requests to the Application Insights API.

    Here is a sample script to achieve this:

    # Variables
    
    TENANT_ID="your-tenant-id"
    
    CLIENT_ID="your-client-id"
    
    CLIENT_SECRET="your-client-secret"
    
    RESOURCE="https://api.applicationinsights.io"
    
    APP_ID="your-application-insights-app-id"
    
    # Get the access token
    
    ACCESS_TOKEN=$(curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \
    
    -d "grant_type=client_credentials&client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&resource=$RESOURCE" \
    
    "https://login.microsoftonline.com/$TENANT_ID/oauth2/token" | jq -r '.access_token')
    
    # Use the access token to query Application Insights
    
    curl -X GET -H "Authorization: Bearer $ACCESS_TOKEN" \
    
    "https://api.applicationinsights.io/v1/apps/$APP_ID/metrics/requests/duration?timespan=P1D&interval=PT1H"  
    

    The key in this example is that once you have retrieved the access token, you need to add it in the authorization header of subsequent calls using the -H argument.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.