Today I will show you how to initiate a manual failover and how to perform a fallback on your IOT-hub

By default, the IoT Hub service provides intra-region High Availability by implementing redundancies in almost all layers of the service. The SLA published by the IoT Hub service is achieved by making use of these redundancies. No additional work is required by the developers of an IoT solution to take advantage of these High Availability features.

Although IoT Hub offers a reasonably high uptime guarantee, transient failures can still be expected as with any distributed computing platform. If you’re just getting started with migrating your solutions to the cloud from an on-premise solution, your focus needs to shift from optimizing “mean time between failures” to “mean time to recover”. In other words, transient failures are to be considered normal while operating with the cloud in the mix. Appropriate retry policies must be built into the components interacting with a cloud application to deal with transient failures.

Manual failover is a feature of the IoT Hub service that allows customers to failover their hub’s operations from a primary region to the corresponding Azure geo-paired region. Manual failover can be done in the event of a regional disaster or an extended service outage. You can also perform a planned failover to test your disaster recovery capabilities, although it is recommended that a test IoT hub is used rather than one running in production as the solution is unavailable during the failover process.

Azure IoT Hub Manual Failover You should note that there is a limit of two failovers and two failbacks per day for an IoT Hub.

Complete the following steps:
1. In your Web browser, to open your Azure portal, navigate to the portal.azure.com. When you log into Azure you will arrive at the Azure portal home page for your Azure account.

2. In the top-left corner of your Azure portal, under Favorites click Resource groups.
3. In the Resource groups blade, select the resource group name you are using.
4. In the Resource group blade, in the list of resources, click the Storage account you have created.
5. Under Resiliency on the IoT Hub blade, click Manual failover (preview).
6. On the Manual Failover pane, read and note the warning: Use this feature to failover your IoT hub to the secondary location. This action will cause down time and telemetry loss to your solution.

This is a long running operation and could take several minutes to finish. Please exercise with caution when using it.

7. On the Manual failover pane, you see the IoT Hub Primary Location and the IoT Hub Secondary Location.

The primary location is initially set to the location you specified when you created the IoT hub, and always indicates the location in which the hub is currently active. The secondary location is the standard Azure geo-paired region that is paired to the primary location. You cannot change the location values.

8. At the top of the Manual failover pane, click Initiate failover.

9. On the Confirm manual failover pane note the warning: Warning! This action can’t be canceled. Your IoT hub will be activated in the secondary location.

In order to move your IoT hub back to the original location, you will have to trigger the failover again after the current operation succeeds.

10. Under Iot hub name, enter the name of your IoT hub and click OK. This confirms your desire to failover.

Note that you can use the mouse to select and copy the IoT hub name from another area of the web page. The amount of time it takes to perform the manual failover is proportional to the number of devices that are registered for your hub. For example, if you have 100,000 devices, it might take 15 minutes, but if you have five million devices, it might take an hour or longer.

While the manual failover process is running, there is a banner on the Manual Failover pane that tells you a manual failover is in progress. After a processing period, you will get a notification that your IoT Hub failover has been completed successfully. After it’s finished, the primary and secondary regions on the Manual Failover page are flipped and the hub is active again. Azure IoT Hub Failback After you have performed a manual failover, you can switch the hub’s operations back to the original primary region – this is called a failback. If you have just performed a failover, you must wait about an hour before you can request a failback. If you try to perform the failback in a shorter amount of time, an error message is displayed.

A failback is performed just like a manual failover.

These are the steps:
1. To perform a failback, return to the Iot Hub pane for your Iot hub.
2. Under Resiliency on the IoT Hub pane, click Manual failover.
3. At the top of the Manual failover pane, click Initiate failover. You see the Confirm manual failover pane.
4. In the Confirm manual failover pane, under Iot hub name, enter the name of your IoT hub and click OK.

As before, the amount of time it takes to perform the manual failover is proportional to the number of devices that are registered for your hub. For example, if you have 100,000 devices, it might take 15 minutes, but if you have five million devices, it might take an hour or longer. While the manual failover process is running, there is a banner on the Manual Failover pane that tells you a manual failover is in progress. After a processing period, you will get a notification that your IoT Hub failover has been completed successfully. After it’s finished, the primary and secondary regions on the Manual Failover page are flipped and the hub is active again.