You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-hub/migrate-hub-arm.md
+29-56Lines changed: 29 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ ms.author: kgremban
8
8
ms.service: azure-iot-hub
9
9
ms.custom: devx-track-arm-template
10
10
ms.topic: how-to
11
-
ms.date: 04/14/2023
11
+
ms.date: 12/09/2024
12
12
---
13
13
14
14
# How to manually migrate an Azure IoT hub using an Azure Resource Manager template
@@ -35,14 +35,14 @@ The outcome of this article is similar to [How to automatically migrate an IoT h
35
35
* Migrates your device registry and your routing and endpoint information. You have to manually recreate other configuration details in the new IoT hub.
36
36
* Is faster for migrating large numbers of devices (for example, more than 100,000).
37
37
* Uses an Azure Storage account to transfer the device registry.
38
-
* Scrubs connection strings for routing and file upload endpoints from the ARM template output, and you need to manually add them back in.
38
+
* Scrubs connection strings for routing and file upload endpoints that use key-based authentication from the ARM template output, and you need to manually add them back in.
39
39
40
40
* The Azure CLI process:
41
41
42
42
* Migrates your device registry, your routing and endpoint information, and other configuration details like IoT Edge deployments or automatic device management configurations.
43
43
* Is easier for migrating small numbers of devices (for example, up to 10,000).
44
44
* Doesn't require an Azure Storage account.
45
-
* Collects connection strings for routing and file upload endpoints and includes them in the ARM template output.
45
+
* Collects connection strings for routing and file upload endpoints that use key-based authentication and includes them in the ARM template output.
46
46
47
47
## Things to consider
48
48
@@ -64,6 +64,8 @@ There are several things to consider before migrating an IoT hub.
64
64
65
65
* You need to update any certificates so you can use them with the new resources. Also, you probably have the hub defined in a DNS table somewhere and need to update that DNS information.
66
66
67
+
* Endpoints that use system-assigned managed identities for authentication can't be migrated. After migration, you need to give the new IoT hub's system-assigned managed identity access to the endpoint resources and then recreate the endpoints.
68
+
67
69
## Methodology
68
70
69
71
This is the general method we recommend for migrating an IoT hub.
@@ -84,7 +86,7 @@ This is the general method we recommend for migrating an IoT hub.
84
86
85
87
## How to handle message routing
86
88
87
-
If your hub uses [message routing](iot-hub-devguide-messages-d2c.md), exporting the template for the hub includes the routing configuration, but it doesn't include the resources themselves. If you're migrating the IoT hub to a new region, you must choose whether to move the routing resources to the new location as well or to leave them in place and continue to use them "as is". There may be a small performance hit from routing messages to endpoint resources in a different region.
89
+
If your hub uses [message routing](iot-hub-devguide-messages-d2c.md), exporting the template for the hub includes the routing configuration, but it doesn't include the resources themselves. If you're migrating the IoT hub to a new region, you must choose whether to move the routing resources to the new location as well or to leave them in place and continue to use them as-is. There might be a small performance hit from routing messages to endpoint resources in a different region.
88
90
89
91
If the hub uses message routing, you have two choices.
90
92
@@ -96,7 +98,7 @@ If the hub uses message routing, you have two choices.
96
98
97
99
1. Update the resource names and the resource keys in the new hub's template before creating the new hub. The resources should be present when the new hub is created.
98
100
99
-
* Don't move the resources used for the routing endpoints. Use them "in place".
101
+
* Don't move the resources used for the routing endpoints. Use them in-place.
100
102
101
103
1. In the step where you edit the template, you need to retrieve the keys for each routing resource and put them in the template before you create the new hub.
102
104
@@ -222,32 +224,27 @@ You have to make some changes before you can use the template to create the new
222
224
223
225
#### Edit the hub name and location
224
226
225
-
1.Remove the container name parameter section at the top. **ContosoHub**doesn't have an associated container.
227
+
1.In the **parameters**section, remove the **...connectionString** and **...containerName**parameters.
226
228
227
229
```json
228
-
"parameters": {
229
-
...
230
-
"IotHubs_ContosoHub_containerName": {
231
-
"type": "SecureString"
232
-
},
233
-
...
230
+
"IotHubs_ContosoHub_connectionString": {
231
+
"type": "SecureString"
232
+
},
233
+
"IotHubs_ContosoHub_containerName": {
234
+
"type": "SecureString"
234
235
},
235
236
```
236
237
237
-
1. Remove the **storageEndpoints** property.
238
+
1. In the **properties** section, remove the **storageEndpoints** property.
1. If you're moving the hub to a new region, change the **location** property under **resources**.
@@ -262,28 +259,10 @@ When you export the Resource Manager template for a hub that has routing configu
262
259
263
260
If you moved the routing resources as well, update the name, ID, and resource group of each endpoint as well.
264
261
265
-
1. Retrieve the keys required for any of the routing resources and put them in the template. You can retrieve the key(s) from the resource in the [Azure portal](https://portal.azure.com).
266
-
267
-
* For example, if you're routing messages to a storage container, find the storage account in the portal. Under the Settings section, select **Access keys**, then copy one of the keys. Here's what the key looks like when you first export the template:
* The same applies for the Service Bus Topics and Event Hubs connections.
262
+
* For endpoints with *key-based authentication*, retrieve the keys required for any of the routing resources and put them in the template. You can retrieve the key from each resource in the [Azure portal](https://portal.azure.com).
263
+
* For endpoints with *identity-based authentication*:
264
+
* Those that use a user-assigned managed identity have the **userAssignedIdentity** value populated with the identity ID information as a parameter.
265
+
* Those that use a system-assigned managed identity can't be migrated. Delete these endpoints and their related routes from the template and make a note to recreate them in the new IoT hub.
287
266
288
267
## Create the new hub by loading the template
289
268
@@ -315,15 +294,13 @@ Create the new hub using the edited template. If you have routing resources that
315
294
316
295
**Region**: If you selected an existing resource group, the region is filled in for you to match the location of the resource group. If you created a new resource group, this is its location.
317
296
318
-
**Connection string**: Fill in the connection string for your hub.
319
-
320
297
**Hub name**: Give the new hub a name.
321
298
322
299
:::image type="content" source="./media/migrate-hub-arm/iot-hub-custom-deployment-create.png" alt-text="Screenshot showing the custom deployment page":::
323
300
324
301
1. Select the **Review + create** button.
325
302
326
-
1. Select the **Create** button. The portal validates your template and deploys your new hub. If you have routing configuration data, it is included in the new hub, but points at the resources in the prior location.
303
+
1. Select the **Create** button. The portal validates your template and deploys your new hub. If you have routing configuration data, it's included in the new hub, but points at the resources in the prior location.
327
304
328
305
:::image type="content" source="./media/migrate-hub-arm/iot-hub-custom-deployment-final.png" alt-text="Screenshot showing the final custom deployment page":::
329
306
@@ -355,29 +332,25 @@ The application targets .NET Core, so you can run it on either Windows or Linux.
355
332
356
333
### Download the sample
357
334
358
-
1. Use the IoT C# samples here: [Azure IoT SDK for C#](https://github.com/Azure/azure-iot-sdk-csharp/archive/main.zip). Download the zip file and unzip it on your computer.
359
-
360
-
1. The pertinent code is in ./iothub/service/samples/how to guides/ImportExportDevicesSample. You don't need to view or edit the code in order to run the application.
361
-
362
-
1. To run the application, specify three connection strings and five options. You pass this data in as command-line arguments or use environment variables, or use a combination of the two. We're going to pass the options in as command line arguments, and the connection strings as environment variables.
363
-
364
-
The reason for this is because the connection strings are long and ungainly, and unlikely to change, but you might want to change the options and run the application more than once. To change the value of an environment variable, you have to close the command window and Visual Studio or Visual Studio Code, whichever you're using.
335
+
Use the IoT C# SDK's [ImportExportDevicesSample](https://github.com/Azure/azure-iot-sdk-csharp/tree/main/iothub/service/samples/how%20to%20guides/ImportExportDevicesSample). Clone or download the repo to get the sample code.
365
336
366
337
### Options
367
338
339
+
To run the application, specify three connection strings and five options. You pass this data in as command-line arguments or use environment variables, or use a combination of the two. We're going to pass the options in as command line arguments, and the connection strings as environment variables. The reason for this is because the connection strings are long and ungainly, and unlikely to change, but you might want to change the options and run the application more than once. To change the value of an environment variable, you have to close the command window and Visual Studio or Visual Studio Code, whichever you're using.
340
+
368
341
Here are the five options you specify when you run the application:
369
342
370
343
* **addDevices** (argument 1) - set this option to `True` if you want to add virtual devices that are generated for you. These devices are added to the source hub. Also, set **numToAdd** (argument 2) to specify how many devices you want to add. The maximum number of devices you can register to a hub is one million. The purpose of this option is for testing. You can generate a specific number of devices, and then copy them to another hub.
371
344
372
345
* **copyDevices** (argument 3) - set this option to `True` to copy the devices from one hub to another.
373
346
374
-
* **deleteSourceDevices** (argument 4) - set this option to `True` to delete all of the devices registered to the source hub. We recommend waiting until you are certain all of the devices have been transferred before you run this. Once you delete the devices, you can't get them back.
347
+
* **deleteSourceDevices** (argument 4) - set this option to `True` to delete all of the devices registered to the source hub. We recommend waiting until you're certain that all of the devices were transferred before you run this. Once you delete the devices, you can't get them back.
375
348
376
349
* **deleteDestDevices** (argument 5) - set this option to `True` to delete all of the devices registered to the destination hub. You might want to do this if you want to copy the devices more than once.
377
350
378
351
The basic command is *dotnet run*, which tells .NET to build the local csproj file and then run it. You add your command-line arguments to the end before you run it.
379
352
380
-
Your command-line will look like these examples:
353
+
Your command-line looks like these examples:
381
354
382
355
``` console
383
356
// Format: dotnet run add-devices num-to-add copy-devices delete-source-devices delete-destination-devices
@@ -393,7 +366,7 @@ Your command-line will look like these examples:
393
366
394
367
### Use environment variables for the connection strings
395
368
396
-
1. To run the sample, you need the connection strings to the old and new IoT hubs, and to a storage account you can use for temporary work files. We will store the values for these in environment variables.
369
+
1. To run the sample, you need the connection strings to the old and new IoT hubs, and to a storage account you can use for temporary work files. We'll store the values for these connection strings in environment variables.
397
370
398
371
1. To get the connection string values, sign in to the [Azure portal](https://portal.azure.com).
399
372
@@ -438,7 +411,7 @@ Now you have the environment variables in a file with the SET commands, and you
438
411
dotnet run arg1 arg2 arg3 arg4 arg5
439
412
```
440
413
441
-
The dotnet command builds and runs the application. Because you're passing in the options when you run the application, you can change the values of them each time you run the application. For example, you may want to run it once and create new devices, then run it again and copy those devices to a new hub, and so on. You can also perform all the steps in the same run, although we recommend not deleting any devices until you're certain you're finished with the migration. Here's an example that creates 1000 devices and then copies them to the other hub.
414
+
The dotnet command builds and runs the application. Because you're passing in the options when you run the application, you can change the values of them each time you run the application. For example, you may want to run it once and create new devices, then run it again and copy those devices to a new hub, and so on. You can also perform all the steps in the same run, although we recommend not deleting any devices until you're certain you're finished with the migration. Here's an example that creates 1,000 devices and then copies them to the other hub.
442
415
443
416
``` console
444
417
// Format: dotnet run add-devices num-to-add copy-devices delete-source-devices delete-destination-devices
@@ -511,7 +484,7 @@ If you decide to roll back the changes, here are the steps to perform:
511
484
512
485
* Update each device to change the IoT Hub Hostname to point the IoT Hub Hostname for the old hub. You should do this using the same method you used when you first provisioned the device.
513
486
514
-
* Change any applications you have that refer to the new hub to point to the old hub. For example, if you're using Azure Analytics, you may need to reconfigure your [Azure Stream Analytics input](../stream-analytics/stream-analytics-define-inputs.md#stream-data-from-iot-hub).
487
+
* Change any applications you have that refer to the new hub to point to the old hub. For example, if you're using Azure Analytics, you might need to reconfigure your [Azure Stream Analytics input](../stream-analytics/stream-analytics-define-inputs.md#stream-data-from-iot-hub).
Copy file name to clipboardExpand all lines: articles/iot-hub/migrate-hub-state-cli.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,14 +32,14 @@ The outcome of this article is similar to [How to migrate an Azure IoT hub using
32
32
* Migrates your device registry, your routing and endpoint information, and other configuration details like IoT Edge deployments or automatic device management configurations.
33
33
* Is easier for migrating small numbers of devices (for example, up to 10,000).
34
34
* Doesn't require an Azure Storage account.
35
-
* Collects connection strings for routing and file upload endpoints and includes them in the ARM template output.
35
+
* Collects connection strings for routing and file upload endpoints that use key-based authentication and includes them in the ARM template output.
36
36
37
37
* The manual process:
38
38
39
39
* Migrates your device registry and your routing and endpoint information. You have to manually recreate other configuration details in the new IoT hub.
40
40
* Is faster for migrating large numbers of devices (for example, more than 100,000).
41
41
* Uses an Azure Storage account to transfer the device registry.
42
-
* Scrubs connection strings for routing and file upload endpoints from the ARM template output, and you need to manually add them back in.
42
+
* Scrubs connection strings for routing and file upload endpoints that use key-based authentication from the ARM template output, and you need to manually add them back in.
43
43
44
44
## Prerequisites
45
45
@@ -79,7 +79,7 @@ When we talk about migrating the state of an IoT hub, we're referring to a combi
79
79
* Device identities and twins
80
80
* Module identities and twins
81
81
82
-
Any IoT Hub property or configuration not listed here may not be exported or imported correctly.
82
+
Any IoT Hub property or configuration not listed here might not be exported or imported correctly.
83
83
84
84
## Export the state of an IoT hub
85
85
@@ -165,15 +165,15 @@ If you include the `--replace` flag in the import command, then the following Io
165
165
166
166
***ARM**: Any uploaded certificates on the destination hub are deleted. If a certificate is present, it needs an etag to be updated.
167
167
***Devices**: All devices and modules, edge and non-edge, are deleted.
168
-
***Configurations**: All ADM configurations and IoT Edge deployments are deleted.
168
+
***Configurations**: All device management configurations and IoT Edge deployments are deleted.
169
169
170
170
## Migrate an IoT hub
171
171
172
172
Use the [az iot hub state migrate](/cli/azure/iot/hub/state#az-iot-hub-state-migrate) command to migrate the state of one IoT hub to a new or existing IoT hub.
173
173
174
174
This command wraps the export and import steps into a single command, but has no output files. All of the guidance and limitations described in the [Export the state of an IoT hub](#export-the-state-of-an-iot-hub) and [Import the state of an IoT hub](#import-the-state-of-an-iot-hub) sections apply to the `state migrate` command as well.
175
175
176
-
If you're migrating a device registry with many devices (for example, a few hundred or a few thousand) you may find it easier and faster to run the export and import commands separately rather than running the migrate command.
176
+
If you're migrating a device registry with many devices (for example, a few hundred or a few thousand) it might be easier and faster to run the export and import commands separately rather than running the migrate command.
0 commit comments