Relocate Azure Event Grid system topics to another region
This article covers the recommended approach, guidelines, and practices to relocate Event Grid system topics to another region.
There are various reasons why you may want to move your existing Azure resources from one region to another. You may want to:
- Take advantage of a new Azure region.
- Deploy features or services available in specific regions only.
- Meet internal policy and governance requirements.
- Align with company mergers and acquisitions
- Meet capacity planning requirements.
Here are the high-level steps covered in this article:
- Export the resource group that contains the Azure Storage account and its associated system topic to a Resource Manager template. You can also export a template only for the system topic. If you go this route, remember to move the Azure event source (in this example, an Azure Storage account) to the other region before moving the system topic. Then, in the exported template for the system topic, update the external ID for the storage account in the target region.
- Modify the template to add the
endpointUrl
property to point to a webhook that subscribes to the system topic. When the system topic is exported, its subscription (in this case, it's a webhook) is also exported to the template, but theendpointUrl
property isn't included. So, you need to update it to point to the endpoint that subscribes to the topic. Also, update the value of thelocation
property to the new location or region. For other types of event handlers, you need to the update only the location. - Use the template to deploy resources to the target region. You'll specify names for the storage account and the system topic to be created in the target region.
- Verify the deployment. Verify that the webhook is invoked when you upload a file to the blob storage in the target region.
- To complete the move, delete resources (event source and system topic) from the source region.
Prerequisites
- Complete the Quickstart: Route Blob storage events to web endpoint with the Azure portal in the source region. This step is optional. Do it to test steps in this article. Keep the storage account in a separate resource group from the App Service and App Service plan.
- 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 resource group that contains the system event source (Azure Storage account) and its associated system topic.
Sign in to the Azure portal.
Select Resource groups on the left menu. Then, select the resource group that contains the event source for which the system topic was created. In the following example, it's the Azure Storage account. The resource group contains the storage account and its associated system topic.
On the left menu, select Export template under Settings, and then, select Download on the toolbar.
Locate the .zip file that you downloaded from the portal, and unzip that file to a folder of your choice. This zip file contains template and parameters JSON files.
Open the template.json in an editor of your choice.
URL for the Webhook isn't exported to the template. So, do the following steps:
In the template file, search for WebHook.
In the Properties section, add a comma (
,
) character at the end of the last line. In this example, it's"preferredBatchSizeInKilobytes": 64
.Add the
endpointUrl
property with the value set to your Webhook URL as shown in the following example."destination": { "properties": { "maxEventsPerBatch": 1, "preferredBatchSizeInKilobytes": 64, "endpointUrl": "https://mysite.azurewebsites.net/api/updates" }, "endpointType": "WebHook" }
Note
For other types of event handlers, all properties are exported to the template. You only need to update the
location
property to the target region as shown in the next step.
Update
location
for the storage account resource to the target region or location. To obtain location codes, see Azure locations. The code for a region is the region name with no spaces, for example,West US
is equal towestus
."type": "Microsoft.Storage/storageAccounts", "apiVersion": "2019-06-01", "name": "[parameters('storageAccounts_spegridstorage080420_name')]", "location": "westus",
Repeat the step to update
location
for the system topic resource in the template."type": "Microsoft.EventGrid/systemTopics", "apiVersion": "2020-04-01-preview", "name": "[parameters('systemTopics_spegridsystopic080420_name')]", "location": "westus",
Save the template.
Redeploy
Deploy the template to create a storage account and a system topic for the storage account in the target region.
- In the Azure portal, select Create a resource.
- In Search the Marketplace, type template deployment, and then press ENTER.
- Select Template deployment.
- Select Create.
- Select Build your own template in the editor.
- 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.
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 system topic name, enter a name for the system topic that will be associated with the storage account.
For the storage account name, enter a name for the storage account to be created in the target region.
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 Goto resource group.
- On the Resource group page, verify that the event source (in this example, Azure Storage account) and the system topic are created.
- Upload a file to a container in the Azure Blob storage, and verify that the webhook has received the event. For more information, see Send an event to your endpoint.
Discard or clean up
To complete the move, delete the resource group that contains the storage account and its associated system topic in the source region.
If you want to start over, delete the resource group in the target region, and repeat steps in the Prepare and Recreate sections of this article.
To delete a resource group (source or target) by using the Azure portal:
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.