Access logs and diagnostics data in Sitecore XP on Azure Web Apps

  • Description

    Sitecore XP fully supports Azure PaaS from the 8.2 Update-1 release. This includes support of Azure Web Apps for hosting Sitecore applications.

    You access Sitecore XP logs and diagnostics information on Azure Web Apps differently than you do in an on-premise solution. This article explains how to collect basic Sitecore diagnostics information, such as logs and configuration data, for a Sitecore XP solution deployed to Azure Web Apps.

  • Accessing Sitecore Logs

    There are several options to collect Sitecore XP logs from Azure Application Insights (AI):

    • Using Azure Application Insights REST API

      To utilize this approach, use the latest version of the AzureTools.aspx page with the following two Azure AI parameters:

      • Application ID
      • API key

      To retrieve these parameters:

      1. Locate the following tab in the related resource group: Azure Portal -> Resource Group -> Application Insights -> Configure section -> API Access.
      2. Retrieve the Application ID from this tab.
      3. On the same tab, create an API key (Read telemetry) and save its value. Note: When the key creation dialog is closed, you cannot access the key value.

      To collect logs using this page:

      1. Open the page using one of the following approaches:
        • Sitecore XP (website/sitecore/admin/AzureTools.aspx)
        • http://localhost/AzureTools.aspx (C:\inetpub\wwwroot\AzureTools.aspx, only with IIS configured to use ASP.NET)
      2. Select the Logs tab and enter Application ID and API key values.
      3. Click Find existing roles to look for roles (CM, CD, and so on) in the environment.
      4. Select the roles you need and logs recency.
      5. Optionally, you can select the Extended checkbox to see more options.
      6. Click Download logs to download related logs, which are compatible with the Sitecore Log Analyzer.

      For logs analysis, you can use Azure AI parameters to download the required logs, or you can provide these parameters to Sitecore Support.

      If access to Azure AI logs is no longer needed, the API key can be deleted (Azure Portal -> Right-click on the API key -> Delete).

    • Using Application Insights Analytics Portal

      To access enhanced logging data of a Sitecore XP instance deployed to Azure Web Apps, we recommend you browse preconfigured Application Insights records using the Application Insights Analytics page:

      1. Go to the Azure Portal (https://portal.azure.com).
      2. Open related resource group and select Application Insights.
      3. In the Overview section, click the Analytics button at the top of the page.
      4. On the opened page, paste and run the needed query to retrieve logs. In this following example, logs for last 14 days from a Single Sitecore XP role are retrieved.
        traces
        | where tostring(customDimensions.Role) == "Single"
        | where timestamp > now(-14d)
        | project timestamp, message
        | sort by timestamp desc
      5. The following roles can be used for the above query: Single, CM, CD, Processing, Reporting, DDS.
      6. To see all available fields for logs filtering (like customDimensions.InstanceName or severityLevel), the following simple query can be executed:
        traces

      After the logs are retrieved, they can be exported to a CSV file.

      For more details about writing custom queries, consider reading the azure log analytics articles.

  • Accessing Sitecore Configs and other files via FTP

    To access deployed application files and configuration data, Azure Web Apps provides full FTP access. For browsing the needed data:

    1. Extract FTP credentials for the needed Sitecore XP instance:
      • Go to the Azure Portal (https://portal.azure.com).
      • Select a particular Web app.
      • Download a file with credentials by clicking the Get publish profile button at the top of the Overview tab.
      • Extract FTP credentials:
        • publishUrl="ftp://host-name-here/site/wwwroot"
        • userName="user-name-here"
        • userPWD="password-here"
    2. Using any FTP client (for example, FileZilla), connect to the FTP endpoint using the extracted credentials.

    After connecting to the FTP, you can browse the following:

    • /LogFiles — access to various diagnostics information including the EventLog from the system running the Azure Web App.
    • /site/wwwroot — deployed Sitecore application root folder, with all configs and binaries.

Applies to:

CMS 8.2 Update-1+

January 10, 2017
September 10, 2018

Keywords: 

  • Azure,
  • Azure,
  • Azure,
  • Azure,
  • Azure,
  • CMS,
  • CMS,
  • CMS,
  • CMS,
  • CMS