Debug your live apps running in Azure Virtual Machines and Azure Kubernetes

Mark Downie

When Visual Studio 2017 Enterprise 15.5 became generally available we introduced the Snapshot Debugger, an innovative diagnostic tool that allows developers to quickly and accurately evaluate problems in their Azure production environments without stopping the process and with minimal performance impact.

When an unanticipated issue occurs in production it can be difficult to replicate the exact conditions in your testing environment and almost impossible to do so on your local development machine. You might consider asking your DevOps team to “turn up” production logging but this relies on you having already anticipated where issues might occur prior to deployment. You may also request that a process dump be taken, but that requires perfect timing and some luck to capture the most important details, you also must gauge how your collection strategy might negatively impact performance.

The Snapshot Debugger provides a familiar and powerful debugging experience, allowing developers to set Snappoints and Logpoints in code, similar to debugger breakpoints and tracepoints. When a Snappoint is hit in your production environment, a snapshot is dynamically created without stopping the process. Developers can then attach to these snapshots using Visual Studio and see what’s going on with variables, Locals, Watches and Call Stack windows, all this while the live site continues to serve your customers.

We are excited to announce that in our Visual Studio 2019 Enterprise preview we are expanding Snapshot Debugger support beyond Azure App Services hosting ASP.NET Core and ASP.NET applications to now also include Azure Virtual Machines (VM), Azure Virtual Machine scale sets (VMSS) and Azure Kubernetes Services (AKS)!

Azure Virtual Machines/Azure Virtual Machine scale sets

For most PaaS scenarios Azure App Services is more than capable of encapsulating a complete end to end experience. However, for developers and organizations that require greater control over of their platform and environment, VMs remain a critical option, and Snapshot Debugger is now fully supported in the latest preview of Visual Studio.

Once your VM/VMSS has been set up to host your ASP.NET or ASP.NET Core web application you can open your project in Visual Studio, click on the “Debug->Attach to Snapshot Debugger…” menu item, where you will now be able to select VM/VMSS as shown.

The UI experience remains almost identical but now you will be required to select an Azure Storage account to collect your snapshot logs and to share the snapshot collection plan (App Services will also require Azure Storage in Preview 2).

Selecting the “Install Remote Debugger Extension” option will prompt Visual Studio to install the extensions in Azure, which is necessary to view snapshots. This process also opens a specific set of ports (30398, 31398, 31399, 32398) to facilitate communication to your local machine, these ports are not required for retrieving and viewing logpoints.

Azure Kubernetes Services (AKS)

Azure provides an incredible cross platform experience and our debugging and diagnostics tools now provide feature parity in our Kubernetes service offerings.

Before attempting to use any of the Snapshot Debugger features in AKS it is vital that your Docker images include ASP.NET Core 2.2+ installed in a global location, as well as the correctly configured Snapshot Debugger and the requisite environment variables.

To help you enable support for Snapshot Debugger in AKS we have provided a repo containing a set of Dockerfiles that demonstrate the setup on Docker images. We support three variants of Linux (Debian, Alpine and Ubuntu) and they are organized according to the ASP.NET Core version, the OS platform, and the platform architecture.

For example, the ASP.NET Core 2.2 Debian 9 (Stretch) x64 Dockerfile is located at /2.2/stretch-slim/amd64/Dockerfile. This Dockerfile produces an image with Debian 9 x64 as the base with ASP.NET Core 2.2 Runtime, it includes the latest supported Snapshot Debugger backend package and sets the environment variables to load the debugger into your .NET Core application.

Try the preview

The latest Snapshot Debugger experiences are now in preview, download and try it out here.

This preview supports the following scenarios:

  • Azure App Services on the Windows OS running ASP.NET Core (2.0+) or ASP.NET (4.6.1+).
  • Virtual Machines on the Windows OS running ASP.NET Core (2.0+) or ASP.NET (4.6.1+).
  • Azure Kubernetes Services (Linux Docker Containers) running ASP.NET Core (2.2+).

If you have any issues using Snapshot Debugger please review this guide on Troubleshooting and known issues for snapshot debugging in Visual Studio.

We would love to hear your feedback. To report issues, use the Report a Problem tool in Visual Studio. You’ll be able to track your issues on the Visual Studio Developer Community site where you can also ask questions and find answers.

0 comments

Discussion is closed.

Feedback usabilla icon