将 Log Analytics 工作区移到其他订阅或资源组Move a Log Analytics workspace to different subscription or resource group

本文介绍将 Log Analytics 工作区移动到同一区域中的另一个资源组或订阅的步骤。In this article, you'll learn the steps to move Log Analytics workspace to another resource group or subscription in the same region. 可在以下文章中详细了解如何通过 Azure 门户、PowerShell、Azure CLI 或 REST API 移动 Azure 资源:You can learn more about moving Azure resources through the Azure portal, PowerShell, the Azure CLI, or the REST API. 将资源移到新的资源组或订阅at Move resources to a new resource group or subscription.

Important

无法将工作区移到其他区域。You can't move a workspace to a different region.

验证 Active Directory 租户Verify Active Directory tenant

工作区源订阅与目标订阅必须在同一个 Azure Active Directory 租户中。The workspace source and destination subscriptions must exist within the same Azure Active Directory tenant. 使用 Azure PowerShell 来验证这两个订阅是否具有相同的租户 ID。Use Azure PowerShell to verify that both subscriptions have the same tenant ID.

(Get-AzSubscription -SubscriptionName <your-source-subscription>).TenantId
(Get-AzSubscription -SubscriptionName <your-destination-subscription>).TenantId

工作区移动注意事项Workspace move considerations

将使用 Log Analytics 工作区移动操作来移动工作区中安装的托管解决方案。Managed solutions that are installed in the workspace will be moved with the Log Analytics workspace move operation. 在移动后,连接的代理将保持连接状态并继续向工作区发送数据。Connected agents will remain connected and keep send data to the workspace after the move. 由于移动操作要求工作区中没有任何链接的服务,因此必须删除依赖于该链接的解决方案才能移动工作区。Since the move operation requires that there are no Linked Services from the workspace, solutions that rely on that link must be removed to allow the workspace move.

在取消链接自动化帐户之前必须先删除的解决方案:Solutions that must be removed before you can unlink your automation account:

  • 更新管理Update Management
  • 更改跟踪Change Tracking
  • 在非工作时间启动/停止 VMStart/Stop VMs during off-hours
  • Azure 安全中心Azure Security Center

在 Azure 门户中删除解决方案Delete solutions in Azure portal

在 Azure 门户中使用以下过程删除解决方案:Use the following procedure to remove the solutions using the Azure portal:

  1. 打开其中已安装任何解决方案的资源组的菜单。Open the menu for the resource group that any solutions are installed in.
  2. 选择要删除的解决方案。Select the solutions to remove.
  3. 单击“删除资源”,然后单击“删除”确认删除资源。 Click Delete Resources and then confirm the resources to be removed by clicking Delete.

删除解决方案

使用 PowerShell 删除Delete using PowerShell

若要使用 PowerShell 删除解决方案,请按以下示例中所示使用 Remove-AzResource cmdlet:To remove the solutions using PowerShell, use the Remove-AzResource cmdlet as shown in the following example:

Remove-AzResource -ResourceType 'Microsoft.OperationsManagement/solutions' -ResourceName "ChangeTracking(<workspace-name>)" -ResourceGroupName <resource-group-name>
Remove-AzResource -ResourceType 'Microsoft.OperationsManagement/solutions' -ResourceName "Updates(<workspace-name>)" -ResourceGroupName <resource-group-name>
Remove-AzResource -ResourceType 'Microsoft.OperationsManagement/solutions' -ResourceName "Start-Stop-VM(<workspace-name>)" -ResourceGroupName <resource-group-name>

删除“启动/停止 VM”解决方案的警报规则Remove alert rules for Start/Stop VMs solution

若要删除“启动/停止 VM”解决方案,还需要删除该解决方案创建的警报规则。To remove Start/Stop VMs solution, you also need to remove the alert rules created by the solution. 在 Azure 门户中使用以下过程删除这些规则。Use the following procedure in the Azure portal to remove these rules.

  1. 打开“监视”菜单,然后选择“警报”。 Open the Monitor menu and then select Alerts.

  2. 单击“管理警报规则”。Click Manage alert rules.

  3. 选择以下三个警报规则,然后单击“删除”。Select the following three alert rules, and then click Delete.

    • AutoStop_VM_ChildAutoStop_VM_Child
    • ScheduledStartStop_ParentScheduledStartStop_Parent
    • SequencedStartStop_ParentSequencedStartStop_Parent

    删除规则

在 Azure 门户中使用以下过程从工作区取消链接自动化帐户:Use the following procedure to unlink the Automation account from the workspace using the Azure portal:

  1. 打开“自动化帐户”菜单,然后选择要删除的帐户。Open the Automation accounts menu and then select the account to remove.

  2. 在菜单的“相关资源”部分,选择“链接的工作区”。 In the Related Resources section of the menu, select Linked workspace.

  3. 单击“取消链接工作区”,以从自动化帐户取消链接该工作区。Click Unlink workspace to unlink the workspace from your Automation account.

    取消工作区链接

移动工作区Move your workspace

Azure 门户Azure portal

在 Azure 门户中使用以下过程移动工作区:Use the following procedure to move your workspace using the Azure portal:

  1. 打开“Log Analytics 工作区”菜单,然后选择你的工作区。Open the Log Analytics workspaces menu and then select your workspace.

  2. 在“概述”页中,单击“资源组”或“订阅”旁边的“更改”。 In the Overview page, click change next to either Resource group or Subscription.

  3. 此时会打开一个新页,其中显示了与该工作区相关的资源列表。A new page opens with a list of resources related to the workspace. 选择要移到该工作区所在的同一目标订阅和资源组中的资源。Select the resources to move to the same destination subscription and resource group as the workspace.

  4. 选择目标“订阅”和“资源组”。 Select a destination Subscription and Resource group. 如果将工作区移到同一订阅中的另一个资源组,则看不到“订阅”选项。If you're moving the workspace to another resource group in the same subscription, you won't see the Subscription option.

  5. 单击“确定”以移动工作区和所选资源。Click OK to move the workspace and selected resources.

    门户

PowerShellPowerShell

若要使用 PowerShell 移动工作区,请按以下示例中所示使用 Move-AzResourceTo move your workspace using PowerShell, use the Move-AzResource as in the following example:

Move-AzResource -ResourceId "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup01/providers/Microsoft.OperationalInsights/workspaces/MyWorkspace" -DestinationSubscriptionId "00000000-0000-0000-0000-000000000000" -DestinationResourceGroupName "MyResourceGroup02"

Important

移动操作完成后,应重新配置已删除的解决方案和自动化帐户链接,使工作区恢复以前的状态。After the move operation, removed solutions and Automation account link should be reconfigured to bring the workspace back to its previous state.

后续步骤Next steps