azure-search-openai-demo icon indicating copy to clipboard operation
azure-search-openai-demo copied to clipboard

App Insights is not turned on by default

Open potashkeren opened this issue 1 year ago • 3 comments

This issue is for a: (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Application Insights is not enabled by default, even though AZURE_USE_APPLICATION_INSIGHTS is set to true. After deploying the app and checking Application Insights under the web app resource in the Azure portal, I noticed that Application Insights is not enabled, no Application Insights resource was created automatically, and the web app was not connected to it. I see this page: image

To ensure that Application Insights is enabled as part of the deployment process using Bicep, we need to add the one property in the appservice.bicep file under the resource configAppSettings:

ApplicationInsightsAgent_EXTENSION_VERSION: '~2' 

The final code should look like this after adding the line above:

  resource configAppSettings 'config' = {
    name: 'appsettings'
    properties: union(appSettings,
      {
        SCM_DO_BUILD_DURING_DEPLOYMENT: string(scmDoBuildDuringDeployment)
        ENABLE_ORYX_BUILD: string(enableOryxBuild)
        ApplicationInsightsAgent_EXTENSION_VERSION: '~2'
      },
      runtimeName == 'python' ? { PYTHON_ENABLE_GUNICORN_MULTIWORKERS: 'true' } : {},
      !empty(applicationInsightsName) ? { APPLICATIONINSIGHTS_CONNECTION_STRING: applicationInsights.properties.ConnectionString } : {},
      !empty(keyVaultName) ? { AZURE_KEY_VAULT_ENDPOINT: keyVault.properties.vaultUri } : {})
  }

Thanks for your help!

Any log messages given by the failure

None

Expected/desired behavior

Application Insights is enabled by default.

OS and Version?

Debian GNU/Linux 12 (bookworm)

azd version?

1.10.1 (commit 31409a33266fb4a5fdbb644bc83988e725d6c7c9)

Mention any other details that might be useful


Thanks! We'll be in touch soon.

potashkeren avatar Oct 06 '24 13:10 potashkeren

I checked with the App Service team and they confirmed the need for the env var as well. It's documented here: https://learn.microsoft.com/en-us/azure/azure-monitor/app/codeless-app-service?tabs=python#automate-monitoring

If you want to send a PR for the change, I'm happy to review. Otherwise I'll make the PR when I'm able.

pamelafox avatar Oct 21 '24 19:10 pamelafox

I think it should be ~3, not ~2, per that documentation. Testing now.

pamelafox avatar Oct 25 '24 21:10 pamelafox

Hi @pamelafox Sorry for the delayed reply, I was on a long vacation. Are you responsible for closing the issue, or is there anything else I can help with?

Thanks, Keren

potashkeren avatar Oct 29 '24 10:10 potashkeren

I discussed this with the App Insights team, and they said that variable is only relevant if you're using auto-instrumentation, as it will turn on the auto-instrumentation. We are using manual instrumentation, so it's not relevant (and in fact, does not work). I've asked them to perhaps add a note in that "App Insights" blade that App Insights might still be enabled, even if it hasn't been auto-enabled. So there's nothing we can do on our end, as far as I can see. I'll close this issue.

pamelafox avatar Jan 06 '25 17:01 pamelafox