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 AzureAILogs.html page with these 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 use the page:

      1. Enter  the Application ID and API key values.
      2. Click Update roles to look for roles (CM, CD, and so on) in the environment.
      3. Select the roles you need and logs recency.
      4. Optionally, to retrieve only errors and fatals, select the Only errors check box, .
      5. Click Get logs from AI. Logs are retrieved from Azure AI.
      6. Preview the latest logs, from newest to oldest, in the bottom of the page. The preview number is defined by the Show latest entries field value.
      7. Click Download logs to download related logs, which are compatible with the Sitecore Log Analyzer.

      This page does not require Sitecore XP to work. For logs analysis, you can use Azure AI parameters to download the required logs, or these parameters can be provided 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 Portal:

      1. Go to Azure Portal (https://portal.azure.com).
      2. Select the specific Application Insights object related to Sitecore XP deployment.
      3. In the Overview section, click the Analytics tab at the top of the page.
      4. On the Application Insights Analytics Portal page, create a new tab and enter the relevant query to the Sitecore logs storage (for a single instance in the environment):
        traces
        | where customDimensions contains "<CloudRole>-<WebApp>"
        | where timestamp > now(-14d)
        | project timestamp, message
        | sort by timestamp desc
        • WebApp — name of Web Application.
        • InstanceName — a self-descriptive name of a solution.
        • CloudRole — a name of a cloud role. Each scaled-out instance is associated with several cloud roles containing their own logs.

          Note: You can use the following query to determine the "CloudRole" value for the needed instance (CM, CD, Processing, Reporting, Single):

          traces
          | extend scinstancename=parsejson(customDimensions).InstanceName
          | where timestamp > now(-1d)
          | summarize count(), any(tostring(scinstancename)) by cloud_RoleInstance
          | extend InstanceName=any_scinstancename
          | extend CloudRole=cloud_RoleInstance
          | project InstanceName, CloudRole
          | order by InstanceName asc

      After the logs are retrieved, you can export them to a CSV file.

      For more details about writing custom queries, use the analytics query reference from Microsoft Azure documentation.

  • Accessing Sitecore Configs and other files via FTP

    To access deployed application files and configuration data, Azure Web Apps provides full FTP access. To enable FTP access and browse useful data:

    1. Enable the FTP credentials for the Sitecore XP instance:
      • Go to the Azure Portal (https://portal.azure.com).
      • Select a particular Web App.
      • Navigate to the Deployment Credentials section.
      • Enable an FTP user with admin access.
    2. Use any FTP client (for example, FileZilla) and connect to the Web App's FTP endpoint using the credentials created before. The endpoint can be retrieved in the Azure Portal by selecting a particular Web App and finding the FTP hostname parameter in the Overview section.

    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
March 29, 2018

Keywords: 

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