Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Snapshot Debugging and Azure Functions

I've been trying to get Snapshot Debugging working with Azure functions all to no avail and was wondering if anyone else has had much joy with this.

In essence it seems very simple to get working (and it does work for azure websites) and just involves included a reference to Microsoft.ApplicationInsights.SnapshotCollector.

However, try as I might, I cannot get it working for Azure functions. I've tried adding the same reference and using the telemetry client with TrackException and sure enough the exception appears in the Insight blade of the Portal, but I just get the 'Collect debug snapshots...' link rather than the 'Open debug snapshot' one.

thanks

like image 918
Ishyc Avatar asked Mar 28 '26 02:03

Ishyc


2 Answers

Azure functions team has released a fix for this issue. You need to do two things.

  • Install the NuGet package as in the link. https://www.nuget.org/packages/Microsoft.ApplicationInsights.SnapshotCollector
  • Add the below code to host.Json and deploy your changes.
    {
   
      "version": "2.0",
      "logging": {
        "applicationInsights": {
          "snapshotConfiguration": {
            "IsEnabled": true
          }
        }
      }
    }

As of now only 2.x versions of .Net core is supported. Net framework works just fine.

enter image description here

For more details, see the issue, https://github.com/MicrosoftDocs/azure-docs/issues/24999

like image 102
Karthikeyan VK Avatar answered Mar 29 '26 15:03

Karthikeyan VK


Member of the Snapshot Debugger team,

To enable Snapshot Debugger in your Function app, you have to update your host.json file by adding the property snapshotConfiguration as defined below and redeploy your function.

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "snapshotConfiguration": {
        "isEnabled": true
      }
    }
  }
}

Snapshot Debugger is pre-installed as part of the Azure Functions runtime, which by default it's disabled

Since Snapshot Debugger it's included in the Azure Functions runtime, it isn't needed to add extra NuGet packages nor application settings.


We have created the proper documentation of how to enable Application Insights Snapshot Debugger in Azure Function, see below: https://learn.microsoft.com/azure/azure-monitor/app/snapshot-debugger-function-app

Renato Gutiérrez

[edited to include how to enable Snapshot Debugger snippet in the answer]

like image 41
Renato Gutierrez Avatar answered Mar 29 '26 14:03

Renato Gutierrez