Question

Difficulty: MediumDiagnose and Log App Service Web Apps

You are troubleshooting an application error on a Windows-based Azure App Service named `marketing-prod` in a resource group named `marketing-rg`.

You need to perform the following tasks:
1. Enable verbose-level application logging to the file system.
2. Monitor the log messages in real-time as they occur.
3. Generate telemetry by sending HTTP requests to the application.
4. Download the historical log files locally for offline review.

Which sequence of Azure CLI commands and actions should you perform? To answer, arrange the actions in the correct order.

  1. 1Run `az webapp log config --name marketing-prod --resource-group marketing-rg --application-logging true --level verbose`
  2. 2Run `az webapp log tail --name marketing-prod --resource-group marketing-rg`
  3. 3Send HTTP requests to the web application endpoint to trigger the application logic.
  4. 4Run `az webapp log download --name marketing-prod --resource-group marketing-rg`

Answer

First, configure the application logging to the file system with verbose level. Second, start the log tail stream to listen for logs. Third, make HTTP requests to generate log data. Finally, download the consolidated logs using the Azure CLI.
The correct sequence begins by configuring the App Service to log application traces to the filesystem at a verbose level. Next, starting the log stream ensures that the developer can monitor incoming events in real-time. Tailing must occur before sending requests so that transient startup log entries are not missed. Once the stream is active, generating traffic triggers the application logic and records the diagnostic information. Finally, downloading the log files aggregates all of the persistent log data for deep offline analysis.

Step-by-Step Solution

1
Configure the web app log settings.
FileSystem application logging is enabled with the verbose severity level.
Before logs can be streamed or downloaded, logging must be explicitly enabled and configured on the App Service instance.
2
Initiate the log streaming session.
A persistent connection to the App Service log streaming endpoint is established.
Starting the tail session before sending requests ensures that the live stream captures the initial errors as they occur.
3
Generate web application traffic.
Application events and errors are triggered and written to the filesystem and the stream.
This generates the diagnostic data required to identify the root cause of the application error.
4
Download the diagnostic logs.
A ZIP archive containing the log files is saved to the local machine.
This retrieves the complete set of log files for offline analysis and permanent archiving.

Key Concept

Azure App Service built-in diagnostic logging and log streaming lifecycle via Azure CLI
Rate this question