Skip to content

No way to turn on App Insights in a Web App through Azure CLI #30030

Open

Description

Describe the bug

az monitor app-insights component connect-webapp is used to link a web app to an app insights instance. However, as far as I have been able to find, there is not an automated way of turning on app insights in the web app as you can on the Azure Portal:

image

Related command

az monitor app-insights component connect-webapp

Errors

There are no errors associated, just missing functionality.

Issue script & Debug output

Currently configuring Azure Monitor as follows:

# create log analytics workspace
az monitor log-analytics workspace create `
    --name $LogWorkspace `
    --resource-group $ResourceGroup

# create app insights
az monitor app-insights component create `
    --app $AppInsights `
    --location $Location `
    --resource-group $ResourceGroup `
    --workspace $LogWorkspace

# connect webapp to app insights
az monitor app-insights component connect-webapp `
    --app $AppInsights `
    --web-app $AppName `
    --resource-group $ResourceGroup

I have tried using az webapp config appsettings to compare the webapp configuration before and after turning on Application Insights.

Adjusting the following configuration values seemed to turn on app insights, but it was not actually receiving telemetry data from my deployed web app:

az webapp config appsettings set `
    --name $AppName `
    --resource-group $ResourceGroup `
    --settings `
    ApplicationInsightsAgent_EXTENSION_VERSION=~3 `
    XDT_MicrosoftApplicationInsights_Mode=recommended `
    APPINSIGHTS_PROFILERFEATURE_VERSION=1.0.0 `
    DiagnosticServices_EXTENSION_VERSION=~3 `
    APPINSIGHTS_SNAPSHOTFEATURE_VERSION=1.0.0

Expected behavior

One of the following two scenarios:

  1. When executing az monitor app-insights component connect-webapp, this should subsequently turn on Application Insights if it is not currently.

  2. An az webapp sub-command should allow you to explicitly turn on / off application insights.

Environment Summary

azure-cli                         2.64.0

core                              2.64.0
telemetry                          1.1.0

Extensions:
application-insights               1.2.2

Dependencies:
msal                              1.30.0
azure-mgmt-resource               23.1.1

Python location '/opt/az/bin/python3'
Extensions directory '/home/jaime/.azure/cliextensions'

Python (Linux) 3.11.8 (main, Aug 28 2024, 05:45:18) [GCC 11.4.0]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Auto-AssignAuto assign by botMonitoraz monitorService AttentionThis issue is responsible by Azure service team.Similar-IssueWeb Appsaz webappapp-service-logging-monitoringcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions