|
| 1 | +--- |
| 2 | +title: "Time Travel Debugging live ASP.NET Azure virtual machines" |
| 3 | +description: "Learn how to record and replay live ASP.NET apps on Azure virtual machines using the Snapshot Debugger." |
| 4 | +ms.custom: "" |
| 5 | +ms.date: "04/11/2019" |
| 6 | +ms.topic: "conceptual" |
| 7 | +helpviewer_keywords: |
| 8 | + - "debugger" |
| 9 | +author: "poppastring" |
| 10 | +ms.author: "madownie" |
| 11 | +manager: andster |
| 12 | +monikerRange: '>= vs-2019' |
| 13 | +ms.workload: |
| 14 | + - "aspnet" |
| 15 | + - "azure" |
| 16 | +--- |
| 17 | +# Record and replay live ASP.NET apps on Azure virtual machines using the Snapshot Debugger |
| 18 | + |
| 19 | +The Time Travel Debugging (TTD) preview in Visual Studio Enterprise provides the ability to record a Web app running on a Azure Virtual Machine (VM) and then accurately reconstruct and replay the execution path. TTD integrates with our Snapshot Debugger offering and allows you to rewind and replay each line of code however many times you want, helping you isolate and identify problems that might only occur in production environments. |
| 20 | + |
| 21 | +Capturing a TTD recording will not halt the application, however, recording will add significant overhead to your running process, slowing it down based on factors that include the process size and the number of active threads. |
| 22 | + |
| 23 | +This feature is in preview for the release of Visual Studio 2019 with a go live license. |
| 24 | + |
| 25 | +In this tutorial, you will: |
| 26 | + |
| 27 | +> [!div class="checklist"] |
| 28 | +> * Start the Snapshot Debugger with Time Travel Debugging enabled |
| 29 | +> * Set a snappoint and Collect a Time Travel recording |
| 30 | +> * Start Debugging a Time Travel recording |
| 31 | +
|
| 32 | +## Prerequisites |
| 33 | + |
| 34 | +* Time Travel Debugging for Azure Virtual Machines (VM) is only available for Visual Studio 2019 Enterprise or higher with the **Azure development workload**. (Under the **Individual components** tab, you find it under **Debugging and testing** > **Snapshot debugger**.) |
| 35 | + |
| 36 | + If it's not already installed, install [Visual Studio 2019 Enterprise](https://visualstudio.microsoft.com/vs/). |
| 37 | + |
| 38 | +* Time Travel Debugging is available for the following Azure VM web apps: |
| 39 | + * ASP.NET applications (AMD64) running on .NET Framework 4.8 or later. |
| 40 | + |
| 41 | +## Open your project and start the Snapshot Debugger with Time Travel Debugging enabled |
| 42 | + |
| 43 | +1. Open the project that you would like to Collect a Time Travel recording. |
| 44 | + |
| 45 | + > [!IMPORTANT] |
| 46 | + > To start TTD, you need to open the *same version of source code* that is published to your Azure VM service. |
| 47 | +
|
| 48 | +1. Choose **Debug > Attach Snapshot Debugger...**. Select the Azure VM your web app is deployed to and an Azure storage account. Select the **Enable the Time Travel Debugging** preview option and then click **Attach**. |
| 49 | + |
| 50 | +  |
| 51 | + |
| 52 | + > [!IMPORTANT] |
| 53 | + > The first time you select **Attach Snapshot Debugger** for your VM, IIS is automatically restarted. |
| 54 | +
|
| 55 | + The metadata for the **Modules** will not initially be activated, navigate to the web app and the **Start Collection** button will become active. Visual Studio is now in snapshot debugging mode. |
| 56 | + |
| 57 | +  |
| 58 | + |
| 59 | + > [!NOTE] |
| 60 | + > The Application Insights site extension also supports Snapshot Debugging. If you encounter a "site extension out of date" error message, see [troubleshooting tips and known issues for snapshot debugging](../debugger/debug-live-azure-apps-troubleshooting.md) for upgrading details. |
| 61 | +
|
| 62 | + The **Modules** window shows you when all the modules have loaded for the Azure VM (choose **Debug > Windows > Modules** to open this window). |
| 63 | + |
| 64 | +  |
| 65 | + |
| 66 | +## Set a snappoint and Collect a Time Travel recording |
| 67 | + |
| 68 | +1. In the code editor, click the left gutter in a method you are interested in to set a snappoint. Make sure it is code that you know will execute. |
| 69 | + |
| 70 | +  |
| 71 | + |
| 72 | +1. Right-click the snappoint icon (the hollow ball) and choose **Actions**. In the Snapshot Settings window click the **Action** check box. Then click the **Collect a time travel trace to the end of this method** check box. |
| 73 | + |
| 74 | +  |
| 75 | + |
| 76 | +1. Click **Start Collection** to turn on the snappoint. |
| 77 | + |
| 78 | +  |
| 79 | + |
| 80 | +## Take a snapshot |
| 81 | + |
| 82 | +When a snappoint is turned on, it will capture a snapshot whenever the line of code where the snappoint is placed executes. This execution can be caused by a real request on your server. To force your snappoint to hit, go to the browser view of your web site and take any actions required that cause your snappoint to be hit. |
| 83 | + |
| 84 | +## Start Debugging a Time Travel recording |
| 85 | + |
| 86 | +1. When the snappoint is hit, a snapshot appears in the Diagnostic Tools window. To open this window, choose **Debug > Windows > Show Diagnostic Tools**. |
| 87 | + |
| 88 | +  |
| 89 | + |
| 90 | +1. Click the View Snapshot link to open the Time Travel recording in the code editor. |
| 91 | + |
| 92 | + You can execute every line of code recorded by the TTD by using the **Continue** and **Reverse Continue** buttons. Additionally the the Debug toolbar can be used to **Show Next Statement**, **Step Into**, **Step Over**, **Step Out**, **Step Back Into**, **Step Back Over**, **Step Back Out**. |
| 93 | + |
| 94 | +  |
| 95 | + |
| 96 | + You can also use the **Locals**, **Watches**, and **Call Stack** windows, and also evaluate expressions. |
| 97 | + |
| 98 | +  |
| 99 | + |
| 100 | + The website itself is still live and end users aren't impacted by any subsequent TTD activity. Only one snapshot is captured per snappoint by default: after a snapshot is captured the snappoint turns off. If you want to capture another snapshot at the snappoint, you can turn the snappoint back on by clicking **Update Collection**. |
| 101 | + |
| 102 | +**Need help?** See the [Troubleshooting and known issues](../debugger/debug-live-azure-apps-troubleshooting.md) and [FAQ for snapshot debugging](../debugger/debug-live-azure-apps-faq.md) pages. |
| 103 | + |
| 104 | +## Set a conditional snappoint |
| 105 | + |
| 106 | +If it is difficult to recreate a particular state in your app, consider whether the use of a conditional snappoint can help. Conditional snappoints help you avoid collecting a Time Travel recording until the app enters a desired state, such as when a variable has a particular value that you want to inspect. [You can set conditions using expressions, filters, or hit counts](../debugger/debug-live-azure-apps-troubleshooting.md). |
| 107 | + |
| 108 | +## Next steps |
| 109 | + |
| 110 | +In this tutorial, you've learned how to collect a Time Travel recording for Azure Virtual Machines. You may want to read more details about Snapshot Debugger. |
| 111 | + |
| 112 | +> [!div class="nextstepaction"] |
| 113 | +> [FAQ for snapshot debugging](../debugger/debug-live-azure-apps-faq.md) |
0 commit comments