将 Azure 事件网格自定义主题移动到另一个区域Move Azure Event Grid custom topics to another region
由于多方面的原因,你可能需要将资源移动到另一个区域。You might want to move your resources to another region for a number of reasons. 例如,为了利用新的 Azure 区域,为了满足内部策略和监管要求,或者,为了应对容量规划要求。For example, to take advantage of a new Azure region, to meet internal policy and governance requirements, or in response to capacity planning requirements.
下面是本文介绍的概要步骤:Here are the high-level steps covered in this article:
将自定义主题资源导出到 Azure 资源管理器模板。Export the custom topic resource to an Azure Resource Manager template.
重要
只有自定义主题会导出到该模板。Only the custom topic is exported to the template. 该主题的任何订阅都不会导出。Any subscriptions for the topic aren't exported.
使用该模板将自定义主题部署到目标区域。Use the template to deploy the custom topic to the target region.
在目标区域中手动创建订阅。Create subscriptions manually in the target region. 在当前区域中将自定义主题导出到模板时,只有该主题会导出。When you exported the custom topic to a template in the current region, only the topic is exported. 模板中不会包括订阅,因此,在目标区域中创建自定义主题后,请手动创建这些订阅。Subscriptions aren't included in the template, so create them manually after the custom topic is created in the target region.
验证部署 。Verify the deployment . 验证目标区域中是否已创建自定义主题。Verify that the custom topic is created in the target region.
若要完成移动,请从源区域中删除自定义主题。To complete the move , delete custom topic from the source region.
先决条件Prerequisites
- 完成快速入门:在源区域中将自定义事件路由到 Web 终结点。Complete the Quickstart: Route custom events to web endpoint in the source region. 请执行此步骤,以便可以测试本文中的步骤。Do this step so that you can test steps in this article.
- 请确保在目标区域中可以使用事件网格服务。Ensure that the Event Grid service is available in the target region. 参阅各区域的产品可用性。See Products available by region.
准备Prepare
若要开始操作,请导出用于该自定义主题的资源管理器模板。To get started, export a Resource Manager template for the custom topic.
登录到 Azure 门户。Sign in to the Azure portal.
在搜索栏中,键入“事件网格主题”,然后从结果列表中选择“事件网格主题” 。In the search bar, type Event Grid topics , and select Event Grid Topics from the results list.
选择要导出到资源管理器模板的主题。Select the topic that you want to export to a Resource Manager template.
在“事件网格主题”页上,选择左侧菜单中“设置”下的“导出模板”,然后选择工具栏上的“下载” 。On the Event Grid Topic page, select Export Template under Settings on the left menu, and then select Download on the toolbar.
重要
只有主题会导出到该模板。Only the topic is exported to the template. 对该主题的订阅不会导出。Subscriptions for the topic aren't exported. 因此,需要在将主题移动到目标区域后为该主题创建订阅。So, you need to create subscriptions for the topic after you move the topic to the target region.
找到从门户下载的 .zip 文件,并将该文件解压缩到你选择的某个文件夹中。Locate the .zip file you downloaded from the portal, and unzip that file to a folder of your choice. 此 zip 文件包含模板和参数 JSON 文件。This zip file contains template and parameters JSON files.
在你选择的编辑器中打开 template.json。Open the template.json in an editor of your choice.
将主题资源的
location
更新为目标区域或位置。Updatelocation
for the topic resource to the target region or location. 若要获取位置代码,请参阅 Azure 位置。To obtain location codes, see Azure locations. 区域的代码是不带空格的区域名称,例如China North
等同于chinanorth
。The code for a region is the region name with no spaces, for example,China North
is equal tochinanorth
."type": "Microsoft.EventGrid/topics", "apiVersion": "2020-06-01", "name": "[parameters('topics_mytopic0130_name')]", "location": "chinanorth"
保存该模板。Save the template.
重新创建Recreate
部署该模板以在目标区域中创建自定义主题。Deploy the template to create a custom topic in the target region.
- 在 Azure 门户中,选择“创建资源”。In the Azure portal, select Create a resource .
- 在“搜索市场”中键入“模板部署”,然后按 ENTER 。 In Search the Marketplace , type template deployment , and then press ENTER .
- 选择“模板部署”。Select Template deployment .
- 选择“创建” 。Select Create .
- 选择“在编辑器中生成自己的模板”。Select Build your own template in the editor .
- 选择“加载文件”,然后按说明加载在上一部分下载的 template.json 文件。Select Load file , and then follow the instructions to load the template.json file that you downloaded in the last section.
- 选择“保存”以保存该模板。Select Save to save the template.
- 在“自定义部署”页上执行以下步骤:On the Custom deployment page, follow these steps:
选择 Azure 订阅。Select an Azure subscription .
选择目标区域中现有的资源组,或者创建一个资源组。Select an existing resource group in the target region or create one.
对于“区域”,请选择目标区域。For Region , select the target region. 如果选择了现有资源组,则此设置为只读。If you selected an existing resource group, this setting is read-only.
对于“主题名称”,请为该主题输入新名称。For the topic name , enter a new name for the topic.
在页面底部选择“查看 + 创建”。Select Review + create at the bottom of the page.
在“查看 + 创建”页上,查看设置,然后选择“创建” 。On the Review + create page, review settings, and select Create .
验证Verify
部署成功后,选择“转到资源”。After the deployment succeeds, select Go to resource .
请确认看到了该自定义主题的“事件网格主题”页面。Confirm that you see the Event Grid Topic page for the custom topic.
按照将自定义事件路由到 Web 终结点中的步骤,将事件发送到该主题。Follow steps in the Route custom events to a web endpoint to send events to the topic. 验证是否调用了 Webhook 事件处理程序。Verify that the webhook event handler is invoked.
丢弃或清理Discard or clean up
若要完成移动,请删除源区域中的自定义主题。To complete the move, delete the custom topic in the source region.
如果需要重新开始,请删除目标区域中的主题,然后重复本文的准备和重新创建部分中的步骤。If you want to start over, delete the topic in the target region, and repeat steps in the Prepare and Recreate sections of this article.
若要通过使用 Azure 门户来删除自定义主题,请执行以下步骤:To delete a custom topic by using the Azure portal:
- 在 Azure 门户顶部的搜索窗口中,键入“事件网格主题”,然后从搜索结果中选择“事件网格主题”。In the search window at the top of Azure portal, type Event Grid Topics , and select Event Grid Topics from search results.
- 选择要删除的主题,然后从工具栏中选择“删除”。Select the topic to delete, and select Delete from the toolbar.
- 在确认页上,输入资源组的名称,然后选择“删除”。On the confirmation page, enter the name of the resource group, and select Delete .
若要通过使用 Azure 门户删除包含自定义主题的资源组,请执行以下步骤:To delete the resource group that contains the custom topic by using the Azure portal:
- 在 Azure 门户顶部的搜索窗口中,键入“资源组”,然后从搜索结果中选择“资源组” 。In the search window at the top of Azure portal, type Resource groups , and select Resource groups from search results.
- 选择要删除的资源组,然后从工具栏中选择“删除”。Select the resource group to delete, and select Delete from the toolbar.
- 在确认页上,输入资源组的名称,然后选择“删除”。On the confirmation page, enter the name of the resource group, and select Delete .
后续步骤Next steps
你已经了解了如何将事件网格自定义主题从一个区域移动到另一个区域。You learned how to move an Event Grid custom topic from one region to another region. 若要了解如何跨区域移动系统主题、域和合作伙伴命名空间,请参阅以下文章。See the following articles for moving system topics, domains, and partner namespaces across regions.
若要详细了解在 Azure 中如何在区域之间移动资源以及如何进行灾难恢复,请参阅以下文章:将资源移动到新的资源组或订阅。To learn more about moving resources between regions and disaster recovery in Azure, see the following article: Move resources to a new resource group or subscription.