title: Azure Cli How to enable Application Insights for webapp
body: <p>Consider the following code. It creates an application insight, then it retrieves the instrumentationkey and assigns it to my webapp.</p>
  <pre><code>    az monitor app-insights component create -g $resourceGroup --app $webapp --application-type web --kind web --tags $defaultTags
      
      $instrumentationKey = az monitor app-insights component show -g $resourceGroup -a $webapp --query 'instrumentationKey' -o tsv
      az webapp config appsettings set -g $resourceGroup -n $webapp --settings APPINSIGHTS_INSTRUMENTATIONKEY=$instrumentationKey APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=$instrumentationKey
  </code></pre>
  <p>However, this does not turn on application insight for the webapp as shown in this screen capture. I cannot figure out how to turn it on from azure cli.</p>
  <p><a href="https://i.stack.imgur.com/uHBnU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uHBnU.png" alt="enter image description here" /></a></p>