How to access historical diagnostic logs after changing the destination Log Analytics Workspace in Azure?

2026-11-18T04:42:15.5033333+00:00

We have enabled diagnostic settings for multiple Azure resources, such as Azure Key Vault, App Services, and other workloads.

Currently, all diagnostic logs and events are being sent to a centralized Log Analytics Workspace (let's call it Log Analytics Workspace 1).

We are planning to change the diagnostic settings to send all future logs to a new workspace (Log Analytics Workspace 2), while keeping the same diagnostic configuration (log categories, metrics, etc.).

We understand that changing the destination workspace will not automatically delete the existing logs from Workspace 1, and the historical data will remain there according to its retention policy.

Our questions are:

  1. After changing the diagnostic settings, will the historical logs in Workspace 1 still be accessible?
  2. How can we access historical diagnostic logs from the respective Azure resources (for example, Key Vault or App Service) after the destination workspace has been changed?
  3. Is there any way to query both historical logs from Workspace 1 and new logs from Workspace 2 in a centralized manner?
  4. Is there any recommended approach or best practice for managing this transition without losing access to historical diagnostic data?

Any guidance or recommendations would be appreciated.

Azure Monitor
Azure Monitor

An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.

0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-11-18T04:43:45.5766667+00:00

    Historical records remain in Workspace 1 under its table-level retention policy after routing changes, but records outside analytics retention require a search job or restore rather than a normal Logs query.

    Access historical logs

    For direct access:

    1. In the Azure portal, open Log Analytics workspaces → Workspace 1 → Logs.
    2. Select the table that contains the resource logs:
      • AzureDiagnostics when the diagnostic setting uses Azure Diagnostics mode.
      • The applicable dedicated table when it uses resource-specific mode.
    3. Set the time picker to the required historical interval and filter by _ResourceId.

    Example:

    AzureDiagnostics
    | where TimeGenerated between (datetime(2026-01-01) .. datetime(2026-02-01))
    | where _ResourceId =~ "/subscriptions/[Subscription ID] ID]/resourceGroups/[Resource Group] Group]/providers/<provider>/<type>/<resource>"
    | order by TimeGenerated desc
    

    Workspace-context access requires query permission on Workspace 1 or the relevant tables. Log Analytics Reader provides the workspace query permissions typically required for this access.^1^

    You can also open Key Vault/App Service → Monitoring → Logs. This resource-context view retrieves records associated with that resource from accessible workspaces, including the old and new workspaces. It depends on _ResourceId being populated:

    search *
    | where isnotempty(_ResourceId)
    | summarize FirstRecord=min(TimeGenerated),
                LastRecord=max(TimeGenerated),
                Records=count()
              by Type, _ResourceId
    

    Resource read access is sufficient only when the workspace uses Use resource or workspace permissions. If Workspace 1 uses Require workspace permissions, the user also needs workspace or table permissions. Resource-context querying supports Analytics-plan tables; Basic and Auxiliary tables must be queried with the workspace as the scope.^2^

    Query both workspaces centrally

    Use an explicit cross-workspace query from Azure Monitor → Logs or either workspace. The workspace() expression accepts the workspace ID or full Azure resource ID:

    union withsource=SourceWorkspace
        workspace("<workspace-1-id>").AzureDiagnostics,
        workspace("<workspace-2-id>").AzureDiagnostics
    | where TimeGenerated >= ago(90d)
    | where _ResourceId =~ "<resource-id>"
    | project TimeGenerated, SourceWorkspace,
              ResourceProvider, ResourceType, Category, ResultType
    | order by TimeGenerated desc
    

    For resource-specific logging, replace AzureDiagnostics with the appropriate table, such as the relevant Key Vault or App Service table. Inspect both schemas before combining them if collection mode or table structure changed; align differing columns and types with project, tostring(), or other conversions.

    Cross-workspace queries require query access to both workspaces, support up to 100 workspaces, and can become slower when many workspaces or regions are involved.^1^

    After testing, save the query as a function or in a query pack and use it from shared workbooks. Review alert rules separately because cross-workspace alert support and function scoping have additional restrictions.

    Retention checks

    Before changing routing, examine Workspace 1’s retention settings:

    1. Open Workspace 1 → Settings → Usage and estimated costs → Data Retention.
    2. Check table-specific settings as well as the workspace default.
    3. Confirm both:
      • Analytics retention: data is available to ordinary interactive queries.
      • Total retention: includes any lower-cost long-term retention.

    If expected records are no longer returned by an ordinary Logs query but remain within total retention, run a search job to retrieve them. For repeated interactive analysis, restore the relevant historical range. Existing unexpired data is covered if retention is increased; shortening total retention starts a 30-day grace period before removal.^3^

    1. Preserve Workspace 1. Do not delete it, remove required RBAC assignments, or shorten retention during the historical-access period.
    2. Create temporary overlap where supported. If each resource has fewer than five diagnostic settings, add a separate setting with the same categories targeting Workspace 2. A setting can contain only one Log Analytics destination, so two workspaces require separate settings; Azure Monitor permits up to five diagnostic settings per resource.^4^
    3. Generate recognizable test activity and verify records arrive in Workspace 2 before disabling the setting for Workspace 1.
    4. Inventory and update saved queries, workbooks, alerts, automation, and Microsoft Sentinel dependencies.
    5. Keep a saved cross-workspace query during the retention overlap. Older data remains in Workspace 1 and new data is stored in Workspace 2.^5^
    6. If Workspace 1 must eventually be decommissioned, export required historical tables first. An on-demand export job can export a selected table and time range to Azure Blob Storage in Parquet format; changing diagnostic settings or enabling continuous export does not copy historical records.^6^

    References

    1. Query data across Log Analytics workspaces, applications, and resources in Azure Monitor
    2. Manage access to Log Analytics workspaces
    3. Manage data retention in a Log Analytics workspace
    4. Enable logging with Azure Monitor
    5. Relocate Azure Monitor - Log Analytics workspace to another region
    6. Log Analytics data export rules in Azure Monitor
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.