In our last post in this series, we showed how easy it is to set up Ozcode Production Debugger to debug .NET applications on Windows IIS. In this post, I’ll show you that just as easy to set up .NET debugging with Ozcode for Azure App Services.
Azure App Services is Microsoft’s Platform-as-a-Service (PaaS) offering on Azure. It offers all the benefits of a PaaS letting you deploy and host a variety of different application types without having to worry about maintaining any hardware infrastructure, operating systems, network elements, or storage to launch your products into the world. But once your applications are out there, it won’t be long before you’ll run into some nasty errors that slipped into Production. It’s not a matter of “if”, it’s a matter of “when.” That’s when Ozcode steps in to help you debug those errors in the shortest time possible.
Getting started with Ozcode Production Debugger on an Azure App Service is done in three short steps:
- Step 1: Create or sign in to your account
- Step 2: Create your application in Ozcode Production Debugger
- Step 3: Install the Ozcode extension in your App Service
Once the Ozcode agent is connected to your App Service, it starts monitoring your application and autonomously captures the error execution flow so you don’t have to reproduce the error. The time-travel debug information captured by Ozcode lets you step through the error execution flow at the code level, just like you are used to doing when debugging in your Visual Studio IDE. Scroll down to the end of this post to see it in action.
Step 1: Creating or signing in to your account
If you already have an account, sign in at https://app.oz-code.com/sign-in. (To create a new account, click Sign up and follow the cues. You’ll get an email message for confirmation, and you’re ready to go).
Step 2: Creating your first application
If you’re signing in for the first time, Ozcode will prompt you for an application name. If you’ve already used Ozcode Production Debugger, select Add Application under the Applications menu and give your application a name.
In either case, when you click Create, Ozcode will create the application and generate your application token. Make note of the Copy button. You’ll use this later when you need to enter your application token when configuring your Azure Application Service.
Install the Ozcode extension in your app service
To connect the Ozcode agent to your app service so it can capture exceptions and send telemetry data to the Ozcode debugger, you need to install the Ozcode extension.
In your app service console, under Development Tools, search for and select Extensions. Click Add.
Scroll to and select Ozcode Production Debugger (Hint: Using CTRL+F to search for it might be easier) to initiate installation of the debugger agent. While the agent is being installed, you can go ahead and add your application token to connect the agent to the right application.
In your Azure App Service application console Settings, select Configuration, and then New application setting.
Now, remember the Copy button in the Ozcode Production Debugger console that I mentioned earlier (when you were creating your application in Ozcode)? Now’s the time to use that button and copy your application token. Then, create a new application setting called OzCode_Agent_Token and paste in your token.
Save your changes and let your application restart. The Ozcode Production Debugger will indicate once the Ozcode agent is connected and sending it telemetry data.
Here is a screencast of the complete process of getting started:
Now is when the real fun starts.
Debugging an exception
Once the agent is sending telemetry data to the debugger, you can debug exceptions as they automatically appear in your dashboard. To optimize usage of your system resources, the Ozcode agent works in 3 phases.
First time an exception is thrown, it appears in your dashboard, and you can even see it’s stack trace, but you can’t debug it yet. At this stage, the Ozcode has added instrumentation to the error execution flow so that next time the error occurs, Ozcode will know to store the debug data.
Next time the exception is throw, it will be in a Captured state and you can select it for debugging.
In the Captured state, Ozcode has stored what we call “Primary debug information” which includes the complete call stack, and variables at the point where the exception was thrown. Frequently, this is enough to determine the root cause of the error.
If you need to dig deeper, you can now request a Full Capture at the top of the screen.
At this point, Ozcode will indicate that it is waiting for the next occurrence of the exception in order to capture full time-travel debug information.
So next time the exception occurs, you will be able to step through the complete error execution flow will full visibility into the stack trace, locals, variables and method return calls at every step of the way. This is the state we call Fully captured and here’s what it looks like:
Minutes is all it takes
In case you didn’t notice, it took you longer to read this blog post than it takes to actually setup your Ozcode account, create your application in the Ozcode Production Debugger, and connect it to your Azure App Services application. Minutes is all it takes, but this will save you hours when you have to debug your application in Production.
Ozcode Production Debugger
Autonomous exception capture
Don’t chase after exceptions. They automatically appear in your dashboard.
Get insights into your code down to the deepest levels.
View the true state of your code anywhere in the execution flow of an error.