您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

将 Azure 服务总线命名空间移动到另一个区域Move an Azure Service Bus namespace to another region

在各种情况下,你想要将现有的服务总线命名空间从一个区域移到另一个区域。There are various scenarios in which you'd want to move your existing Service Bus namespace from one region to another. 例如,可能需要创建一个具有相同配置的命名空间,以便进行测试。For example, you may want to create a namespace with the same configuration for testing. 灾难恢复规划过程中,可能还需要在另一个区域中创建辅助命名空间。You may also want to create a secondary namespace in another region as part of disaster recovery planning.

下面是概要步骤:Here are the high-level steps:

  1. 将当前区域中的服务总线命名空间导出到 Azure 资源管理器模板。Export the Service Bus namespace in the current region to an Azure Resource Manager template.
  2. 更新模板中资源的位置。Update location for resources in the template. 此外,请从模板中删除默认订阅筛选器,因为你无法创建默认规则,因为它是自动创建的。Also, remove the default subscription filter from the template because you can't create a default rule as it's automatically created for you.
  3. 使用模板将服务总线命名空间部署到目标区域。Use the template to deploy the Service Bus namespace to the target region.
  4. 验证部署以确保所有主题的命名空间、队列、主题和订阅都已在目标区域中创建。Verify the deployment to ensure that the namespace, queues, topics, and subscriptions for topics are all created in the target region.
  5. 在处理完所有消息后,通过从源区域中删除命名空间来完成移动。Complete the move by deleting the namespace from the source region after processing all messages.

必备条件Prerequisites

确保你的帐户使用的 Azure 服务总线和功能在目标区域中受支持。Ensure that Azure Service Bus and features that your account uses are supported in the target region.

准备Prepare

若要开始,请导出资源管理器模板。To get started, export a Resource Manager template. 此模板包含描述服务总线命名空间的设置。This template contains settings that describe your Service Bus namespace.

  1. 登录 Azure 门户Sign in to the Azure portal.

  2. 选择 " 所有资源 ",然后选择服务总线命名空间。Select All resources and then select your Service Bus namespace.

  3. 选择“设置” > “导出模板”。 Select > Settings > Export template.

  4. 选择“导出模板”页中的“下载”。 Choose Download in the Export template page.

    下载资源管理器模板

  5. 找到从门户下载的 .zip 文件,并将该文件解压缩到所选的文件夹。Locate the .zip file that you downloaded from the portal, and unzip that file to a folder of your choice. 此 zip 文件包含模板和参数 JSON 文件。This zip file contains the template and parameters JSON files.

  6. 在提取的文件夹中打开文件上的 template.js。Open the template.json file in the extracted folder.

  7. 搜索 location ,将属性的值替换为该区域或位置的新名称。Search for location, and replace the value for the property with the new name for the region or location. 若要获取位置代码,请参阅 Azure 位置To obtain location codes, see Azure locations. 区域的代码是不带空格的区域名称,例如 West US 等同于 westusThe code for a region is the region name with no spaces, for example, West US is equal to westus.

  8. 删除类型为的资源的定义 Microsoft.ServiceBus/namespaces/topics/subscriptions/rulesRemove definitions of resources of type: Microsoft.ServiceBus/namespaces/topics/subscriptions/rules. 别忘了删除 , 此部分前面的逗号 () 字符,以使 JSON 保持有效。Don't forget to remove the comma (,) character preceding this section to keep JSON valid.

    备注

    不能使用资源管理器模板为订阅创建默认规则。You can't create a default rule for a subscription by using a Resource Manager template. 当在目标区域中创建订阅时,将自动创建默认规则。The default rule is automatically created when the subscription is created in the target region.

移动Move

部署模板以在目标区域中创建服务总线命名空间。Deploy the template to create a Service Bus namespace in the target region.

  1. 在 Azure 门户中,选择“创建资源”。In the Azure portal, select Create a resource.

  2. "搜索应用商店" 中,键入搜索文本的 模板部署 ,选择 " **模板部署 (使用自定义模板进行部署") **,然后按 enterIn Search the Marketplace, type template deployment for the search text, select Template deployment (deploy using custom templates), and then press ENTER.

    下载资源管理器模板

  3. 在“模板部署”页面上,选择“创建”。On the Template deployment page, select Create.

    下载资源管理器模板

  4. 在“自定义部署”页上,选择“在编辑器中生成自己的模板”。On the Custom deployment page, select Build your own template in the editor.

    下载资源管理器模板

  5. 在“编辑模板”页的工具栏上选择“加载文件”,然后按照说明加载你在上一部分下载的 template.json 文件。On the Edit template page, select Load file on the toolbar, and then follow the instructions to load the template.json file that you downloaded in the last section.

    下载资源管理器模板

  6. 选择“保存”以保存该模板。Select Save to save the template.

    下载资源管理器模板

  7. 在“自定义部署”页上执行以下步骤:On the Custom deployment page, follow these steps:

    1. 选择 Azure 订阅。Select an Azure subscription.

    2. 选择现有的资源组或创建一个资源组。Select an existing resource group or create one.

    3. 选择目标位置或区域。Select the target location or region. 如果选择了现有资源组,则此设置为只读。If you selected an existing resource group, this setting is read-only.

    4. 输入新的命名空间名称Enter a new name for the namespace.

    5. 选择“查看 + 创建” 。Select Review + create.

      下载资源管理器模板

    6. 在 " 查看 " 和 "创建" 页上,选择页面底部的 " 创建 "。On the Review + create page, select Create at the bottom of the page.

验证Verify

  1. 在部署成功后,选择“转到资源组”。After the deployment is successful, select Go to resource group.

    下载资源管理器模板

  2. 在 " 资源组 " 页上,选择服务总线命名空间。On the Resource group page, select the Service Bus namespace.

    下载资源管理器模板

  3. 在 " 服务总线命名空间 " 页上,验证你是否看到了源区域中的队列、主题和订阅。On the Service Bus namespace page, verify that you see the queues, topics, and subscriptions from the source region.

    1. 在右侧窗格底部的命名空间中可以看到 队列You see queues in the namespace at the bottom of the right pane.

      下载资源管理器模板

    2. 切换到 " 主题 " 选项卡以查看命名空间中的主题Switch to the Topics tab to see topics in the namespace

      下载资源管理器模板

    3. 选择用于验证是否已创建订阅的主题。Select the topic to verify subscriptions are created.

      下载资源管理器模板

丢弃或清理Discard or clean up

部署后,如果你想要从头开始,则可以删除 目标服务总线命名空间,并重复本文 准备移动 部分所述的步骤。After the deployment, if you want to start over, you can delete the target Service Bus namespace, and repeat the steps described in the Prepare and Move sections of this article.

若要提交更改并完成服务总线命名空间的移动,请删除 源服务总线命名空间To commit the changes and complete the move of a Service Bus namespace, delete the source Service Bus namespace. 请确保在删除命名空间前处理所有消息。Make sure that you process all messages before deleting the namespace.

若要使用 Azure 门户 (源或目标) 删除服务总线命名空间,请执行以下操作:To delete a Service Bus namespace (source or target) by using the Azure portal:

  1. 在 "Azure 门户顶部的" 搜索 "窗口中,键入" Service bus",然后从搜索结果中选择" 服务总线 "。In the search window at the top of Azure portal, type Service Bus, and select Service Bus from search results. 列表中会显示服务总线命名空间。You see the Service Bus namespaces in a list.

  2. 选择要删除的目标命名空间,并从工具栏中选择“删除”。Select the target namespace to delete, and select Delete from the toolbar.

    删除命名空间 - 按钮

  3. 在 " 删除资源 " 页上,验证所选的资源,并通过键入 "是" 确认删除,然后选择 " 删除"。On the Delete Resources page, verify the selected resources, and confirm the deletion by typing yes, and then select Delete.

    其他选项是删除具有服务总线命名空间的资源组。Other option is to delete the resource group that has the Service Bus namespace. 在 " 资源组 " 页上,选择工具栏上的 " 删除资源组 ",然后确认删除。On the Resource group page, select Delete resource group on the toolbar, and then confirm the deletion.

后续步骤Next steps

在本教程中,已将 Azure 服务总线命名空间从一个区域移到另一个区域,并清理了源资源。In this tutorial, you moved an Azure Service Bus namespace from one region to another and cleaned up the source resources. 若要详细了解如何在区域之间移动资源,以及如何在 Azure 中进行灾难恢复,请参阅:To learn more about moving resources between regions and disaster recovery in Azure, refer to: