Question

Difficulty: MediumDiagnose and Log App Service Web Apps

You need to download the diagnostic log files from a Windows-based Azure App Service named `contoso-web` by using the Kudu REST API. You want to retrieve all log files compiled into a single compressed ZIP file.

Arrange the actions in the correct order to configure the request, authenticate, and download the logs.

  1. 1Retrieve the publishing profile or deployment credentials for the App Service.
  2. 2Construct the target URL using the App Service SCM domain and the `/api/zip/LogFiles/` path.
  3. 3Send an HTTP GET request to the constructed URL using the retrieved credentials for Basic Authentication.
  4. 4Save and extract the downloaded ZIP archive locally to access individual log files.

Answer

Retrieve the deployment credentials, construct the SCM endpoint URL targeting the zip API, execute the authenticated HTTP GET request, and extract the downloaded ZIP file.
To download logs using the Kudu API, you must first obtain valid publishing credentials to satisfy authentication requirements. Then, you construct the endpoint URL using the app's SCM site name and the `/api/zip/LogFiles/` directory path. Next, you send the authenticated GET request to receive the compressed log archive. Finally, you extract the ZIP locally to view the logs.

Step-by-Step Solution

1
Obtain the deployment credentials from the Azure portal or CLI.
You have the publishing username and password required for Kudu authentication.
The Kudu REST API endpoint is secured and requires authentication.
2
Formulate the URL using the format: `https://contoso-web.scm.azurewebsites.net/api/zip/LogFiles/`.
You have the target URL pointing to the LogFiles zip API.
The SCM endpoint is separate from the production site and hosts the Kudu service tools.
3
Make an HTTP GET request to the URL using the publishing credentials in the Authorization header.
The server returns a binary stream representing the zipped LogFiles directory.
This initiates the download process from the Azure server.
4
Save the binary stream to a local file and extract its contents.
You have access to files like web server logs, application logs, and detailed errors locally.
Extracting the ZIP is required to read the text-based log files directly.

Key Concept

Accessing App Service diagnostic logs via the Kudu (SCM) REST API zip endpoint.
Rate this question