Skip to content

Update remote-debugging-azure-app-service.md #10339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions docs/debugger/remote-debugging-azure-app-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This article describes how to attach the Visual Studio debugger to an ASP.NET Co

## Enable remote debugging

Before you can debug this issue with Visual Studio, you must enable the remote debugging feature on the App Service. This setting will allow the Visual Studio debugger to connect to the main App Service web hosting process.
Before you can debug this issue with Visual Studio, you must enable the remote debugging feature on the App Service. This setting allows the Visual Studio debugger to connect to the main App Service web hosting process.

1. Sign into your own [Azure portal](https://portal.azure.com/).

Expand All @@ -45,16 +45,14 @@ Your app service instance now supports remote debugging through Visual Studio.

## Configure debugging settings

Make sure you have completed the following steps in Visual Studio before debugging an app in Azure to ensure success.

1. First, make sure you have successfully built your project at least one time. A successful build ensures the source code and any necessary compiled files are ready to go. If your application is running locally, make sure to stop the app.
1. Build your app without errors. Stop your app if it's running locally.

> [!NOTE]
> Make sure the state of your local code matches what was deployed to Azure. This ensures that the local symbol files and source code line up with the deployed app.

1. Select **Debug > Options** from the top Visual Studio menu. Ensure that **Enable Just My code** is *unchecked* (as shown below), and then select **OK**.

Changing this setting allows Visual Studio to debug the optimized code that was deployed to Azure using the necessary symbol files from your local bin folder. Symbol files are used by the debugger as a bridge between compiled, executing code and the source code in Visual Studio, which is why it's important that your local source code matched the deploy app.
Changing this setting allows Visual Studio to debug the optimized code that was deployed to Azure using the necessary symbol files from your local bin folder. Symbol files are used by the debugger as a bridge between compiled, executing code and the source code in Visual Studio. Matching symbol files are required for remote debugging.

:::image type="content" source="../debugger/media/vs-2022/visual-studio-remote-debug-settings.png" alt-text="A screenshot of the Visual Studio debugging settings.":::

Expand All @@ -70,14 +68,17 @@ Make sure you have completed the following steps in Visual Studio before debuggi

1. Locate and select the App Service instance you created in the previous step, and then choose **OK**.

1. The `w3wp.exe` process should appear in the list of available processes to connect to, which is the main process of the Azure App Service that hosts the deployed application. Select that process and then choose **Attach** in the bottom right to connect the Visual Studio debugger.
1. The `w3wp.exe` process should appear in the list of available processes to connect to. `w3wp.exe` is the main process of the Azure App Service that hosts the deployed application. Select the `w3wp.exe` process and then choose **Attach** in the bottom right.

:::image type="content" source="../debugger/media/vs-2022/visual-studio-remote-debug-attach-to-process.png" alt-text="A screenshot of the attach to process features." lightbox="../debugger/media/vs-2022/visual-studio-remote-debug-attach-to-process.png":::

1. In a C# application file such as `Index.cshtml.cs`, set a breakpoint by clicking in the left margin. (Or, right-click and choose **Breakpoint** > **Insert breakpoint**.)
1. In a C# application file such as `Index.cshtml.cs`, set a breakpoint by clicking in the left margin. Alternatively, right-click and choose **Breakpoint** > **Insert breakpoint**.

1. Take action in the web app to hit the breakpoint. If you're attached to the process but can't hit the breakpoint, make sure your publish profile in Visual Studio is set to a Debug configuration instead of a Release configuration.
1. In the web app, navigate to the endpoint with the breakpoint. If you're attached to the process but can't hit the breakpoint, make sure your publish profile in Visual Studio is set to a Debug configuration instead of a Release configuration.

1. (Optional) you can also verify that Visual Studio has loaded the symbol files for your debugging session. Navigate to **Debug > Windows > Modules** to open the modules window. This window should indicate that the symbol files were successfully loaded after the **Just my code** configuration changes you made earlier.
1. Optional: To verify that Visual Studio has loaded the symbol files for your debugging session. Navigate to **Debug > Windows > Modules** to open the modules window. This window indicates that the symbol files were successfully loaded after the **Just my code** configuration changes you made earlier.

:::image type="content" source="../debugger/media/vs-2022/visual-studio-symbol-files.png" alt-text="A screenshot of the symbol files window.":::

> [!NOTE]
> For subsequent debugging of the app service, select the select **Debug** > **Reattach to w3wp.exe** or use the Shift+Alt+P hot keys.