Search⌘ K
AI Features

Logging and Backups in Azure App Service

Explore how to enable and manage logging in Azure App Service to track application exceptions and runtime details. Learn how to configure automatic and manual backups, schedule them, and restore your app to a previous stable state. Understand the use of Azure portal and CLI commands to ensure reliable app monitoring and recovery.

Now that we have some knowledge of Azure web apps, it’s time to get familiar with its key features. You can see the sample code below that just prints statements over the console. Let’s discuss its use cases and why we should consider it.

C#
using System;
class AzureCloud
{
static void Main()
{
try
{
System.Console.WriteLine("Hello, Cloud Engineers !!");
int x= 10/0;
}
catch(Exception ex){
System.Console.WriteLine(ex.ToString());
}
}
}

Our primary focus here is on exception handling. You can see the exception is printed on the screen using the Console.Writeline() statements in C#. We can log this exception so that we can track what the issue is so we can fix it later on. This is useful for applications used by large enterprises to find code leaksCode leaks can be referred to as bugs. in the application.

Azure App Service logging

Let’s say we deployed the code, and it crashed in production. For scenarios like this, we log exceptions. But what if our application doesn’t boot up? Then what?

Azure App Service offers a service called App Service logs. Once we enable this service, every time a request is made on our app’s endpoint, it will show us what’s happening behind the scenes. This way, we can figure out why the app is crashing.

Let’s look at the steps on how to enable this service:

  1. Open your deployed web app and move to the “Monitoring” section. There you can find the “App Service logs” and “Log stream” options.

  2. Click the “App ...