|
| 1 | +--- |
| 2 | +title: Migrate Azure SQL Database to availability zone support |
| 3 | +description: Learn how to migrate your Azure SQL Database to availability zone support. |
| 4 | +author: rsetlem |
| 5 | +ms.service: sql |
| 6 | +ms.topic: conceptual |
| 7 | +ms.date: 06/29/2023 |
| 8 | +ms.author: anaharris |
| 9 | +ms.custom: references_regions, subject-reliability |
| 10 | +--- |
| 11 | + |
| 12 | +# Migrate Azure SQL Database to availability zone support |
| 13 | + |
| 14 | +This guide describes how to migrate [Azure SQL Database](/azure/azure-sql/) from non-availability zone support to availability support. |
| 15 | + |
| 16 | +Enabling zone redundancy for Azure SQL Database guarantees high availability as the database utilizes Azure Availability Zones to replicate data across multiple physical locations within an Azure region. By selecting zone redundancy, you can make your databases and elastic pools resilient to a larger set of failures, such as catastrophic datacenter outages, without any changes of the application logic. |
| 17 | + |
| 18 | +## Prerequisites |
| 19 | + |
| 20 | +Before you migrate to availability zone support, refer to the following table to ensure that your Azure SQL Database is in a supported service tier and deployment model. Make sure that your tier and model is offered in a [region that supports availability zones](/azure/reliability/availability-zones-service-support). |
| 21 | + |
| 22 | +| Service tier | Zone redundancy availability | |
| 23 | +|-----|------| |
| 24 | +| Premium | [All regions that support availability zones](availability-zones-service-support.md#azure-regions-with-availability-zone-support)| |
| 25 | +| Business Critical | [All regions that support availability zones](availability-zones-service-support.md#azure-regions-with-availability-zone-support) | |
| 26 | +| General Purpose | [Selected regions that support availability zones](/azure/azure-sql/database/high-availability-sla?view=azuresql&tabs=azure-powershell&preserve-view=true#general-purpose-service-tier-zone-redundant-availability)| |
| 27 | +| Hyperscale (Preview) |[All regions that support availability zones](availability-zones-service-support.md#azure-regions-with-availability-zone-support) | |
| 28 | + |
| 29 | + |
| 30 | +## Downtime requirements |
| 31 | + |
| 32 | +Migration for Premium, Business Critical, and General Purpose service tier is an online operation with a brief disconnect towards the end to finish the migration process. If you have implemented [retry logic for standard transient errors](/azure/azure-sql/database/troubleshoot-common-connectivity-issues?view=azuresql&preserve-view=true#retry-logic-for-transient-errors), you won't notice the failover. |
| 33 | + |
| 34 | +For Hyperscale service tier, zone redundancy support can only be specified during database creation and can't be modified once the resource is provisioned. If you wish to move to availability zone support, you'll need to transfer the data with database copy, point-in-time restore, or geo-replica. If the target database is in a different region than the source or if the database backup storage redundancy for the target differs from the source database, then downtime is proportional to the size of the data operation. |
| 35 | + |
| 36 | +## Migration (Premium, Business Critical, and General Purpose) |
| 37 | + |
| 38 | +For the Premium, Business Critical, and General Purpose service tiers, migration to zone redundancy is possible. |
| 39 | + |
| 40 | +Follow the steps below to perform migration for a single database or an elastic pool. |
| 41 | + |
| 42 | +### Migrate a single database |
| 43 | + |
| 44 | +# [Azure portal](#tab/portal) |
| 45 | + |
| 46 | +1. Go to the [Azure portal](https://portal.azure.com) to find your database. Search for and select **SQL databases**. |
| 47 | + |
| 48 | +1. Select the database that you want to migrate. |
| 49 | + |
| 50 | +1. Under **Settings** select **Compute + Storage**. |
| 51 | + |
| 52 | +1. Select **Yes** for **Would you like to make this database zone redundant?** |
| 53 | + |
| 54 | +1. Select **Apply**. |
| 55 | + |
| 56 | +1. Wait to receive an operation completion notice in **Notifications** in the top menu of the Azure portal. |
| 57 | + |
| 58 | +1. To verify that zone redundancy is enabled, select **Overview** and then select **Properties**. |
| 59 | + |
| 60 | +1. Under the **Availability** section, confirm that zone redundancy is set to **Enabled**. |
| 61 | + |
| 62 | +# [PowerShell](#tab/powershell) |
| 63 | + |
| 64 | +Open PowerShell as Administrator and run the following command (replace the placeholders in "<>" with your resource names). Note that `<server_name>` should not include `.database.windows.net`. |
| 65 | + |
| 66 | +```powershell |
| 67 | +Connect-AzAccount |
| 68 | +$subscriptionid = <'your subscription id here'> |
| 69 | +Set-AzContext -SubscriptionId $subscriptionid |
| 70 | +
|
| 71 | +$parameters = @{ |
| 72 | + ResourceGroupName = '<Resource_Group_Name>' |
| 73 | + ServerName = '<Server_Name>' |
| 74 | + DatabaseName = '<Database_Name>' |
| 75 | +} |
| 76 | +Set-AzSqlDatabase @parameters -ZoneRedundant |
| 77 | +``` |
| 78 | + |
| 79 | +# [Azure CLI](#tab/cli) |
| 80 | + |
| 81 | + |
| 82 | +Use Azure CLI to run the following command (replace the placeholders in "<>" with your resource names): |
| 83 | + |
| 84 | +```azurecli |
| 85 | + az sql db update --resource-group “<Resource_Group_Name>” --server “<Server_Name>” --name “<Database_Name>” --zone-redundant |
| 86 | +``` |
| 87 | + |
| 88 | +# [ARM](#tab/arm) |
| 89 | + |
| 90 | +To enable zone redundancy, see [Databases - Create Or Update in ARM](/rest/api/sql/2022-05-01-preview/databases/create-or-update?tabs=HTTP) and use the `properties.zoneRedundant` property. |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +### Migrate an elastic pool |
| 95 | + |
| 96 | + |
| 97 | +>[!IMPORTANT] |
| 98 | +>Enabling zone redundancy support for elastic pools makes all databases within the pool zone redundant. |
| 99 | +
|
| 100 | + |
| 101 | +# [Azure portal](#tab/portal) |
| 102 | + |
| 103 | +1. Go to the [Azure portal](https://portal.azure.com) to find and select the elastic pool that you want to migrate. |
| 104 | + |
| 105 | +1. Select **Settings**, and then select **Configure**. |
| 106 | + |
| 107 | +1. Select **Yes** for **Would you like to make this elastic pool zone redundant?**. |
| 108 | + |
| 109 | +1. Select **Save**. |
| 110 | + |
| 111 | +1. Wait to receive an operation completion notice in **Notifications** in the top menu of the Azure portal. |
| 112 | + |
| 113 | +1. To verify that zone redundancy is enabled, select **Configure** and then select **Pool settings**. |
| 114 | + |
| 115 | +1. The zone redundant option should be set to **Yes**. |
| 116 | + |
| 117 | + |
| 118 | +# [PowerShell](#tab/powershell) |
| 119 | + |
| 120 | + |
| 121 | +Open PowerShell as Administrator and run the following command (replace the placeholders in "<>" with your resource names). Note that `<server_name>` should not include `.database.windows.net`. |
| 122 | + |
| 123 | +```powershell |
| 124 | +Connect-AzAccount |
| 125 | +$subscriptionid = <'your subscription id here'> |
| 126 | +Set-AzContext -SubscriptionId $subscriptionid |
| 127 | +
|
| 128 | +$parameters = @{ |
| 129 | + ResourceGroupName = '<Resource_Group_Name>' |
| 130 | + ServerName = '<Server_Name>' |
| 131 | + ElasticPoolName = '<Elastic_Pool_Name>' |
| 132 | +} |
| 133 | +
|
| 134 | +Set-AzSqlElasticPool @parameters -ZoneRedundant |
| 135 | +``` |
| 136 | + |
| 137 | + |
| 138 | +# [Azure CLI](#tab/cli) |
| 139 | + |
| 140 | +Use Azure CLI to run the following command (replace the placeholders in "<>" with your resource names): |
| 141 | + |
| 142 | +```azurecli |
| 143 | + az sql elastic-pool update --resource-group “<Resource_Group_Name>” --server “<Server_Name>” --name “<Elastic_Pool_Name>” --zone-redundant |
| 144 | +``` |
| 145 | + |
| 146 | + |
| 147 | +# [ARM](#tab/arm) |
| 148 | + |
| 149 | +To enable zone redundancy, see [Elastic Pools - Create Or Update in ARM](/rest/api/sql/2022-05-01-preview/elastic-pools/create-or-update?tabs=HTTP). |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +## Redeployment (Hyperscale) |
| 154 | + |
| 155 | +For the Hyperscale service tier, zone redundancy support can only be specified during database creation and can't be modified once the database is provisioned. If you wish to gain zone redundancy support, you need to perform a data transfer from your existing Hyperscale service tier single database. To perform the transfer and enable the zone redundancy option, a clone must be created using database copy, point-in-time restore, or geo-replica. |
| 156 | + |
| 157 | +### Redeployment considerations |
| 158 | + |
| 159 | +- There are two modes of redeployment (online and offline): |
| 160 | + |
| 161 | + - The **Database copy and point-in-time restore methods (offline mode)** create a transactionally consistent database at a certain point in time. As a result, any data changes performed after the copy or restore operation have been initiated won't be available on the copied or restored database. |
| 162 | + |
| 163 | + - **Geo-replica method (online mode)** is a redeployment wherein any data changes from source are synchronized to target. |
| 164 | + |
| 165 | +- Connection string for the application must be updated to point to the zone redundant database. |
| 166 | + |
| 167 | +### Redeploy a single database |
| 168 | + |
| 169 | +#### Database copy |
| 170 | + |
| 171 | +To create a database copy and enable zone redundancy with Azure portal, PowerShell, or Azure CLI, follow the instructions in [copy a transactionally consistent copy of a database in Azure SQL Database](/azure/azure-sql/database/database-copy?tabs=azure-powershell&view=azuresql&preserve-view=true#copy-using-the-azure-portal). |
| 172 | + |
| 173 | + |
| 174 | +#### Point-in-time restore |
| 175 | + |
| 176 | +To create a point-in-time database restore and enable zone redundancy with Azure portal, PowerShell, or Azure CLI, follow the instructions in [Point-in-time restore](/azure/azure-sql/database/recovery-using-backups?view=azuresql&preserve-view=true&tabs=azure-portal#point-in-time-restore). |
| 177 | + |
| 178 | +##### Geo-replica |
| 179 | + |
| 180 | +To create a geo-replica of the database: |
| 181 | + |
| 182 | +1. Follow the instructions with Azure portal, PowerShell, or Azure CLI in [Configure active geo-replication and failover (Azure SQL Database)](/azure/azure-sql/database/active-geo-replication-configure-portal?view=azuresql&preserve-view=true&tabs=portal) and enable zone redundancy under **Compute + Storage** |
| 183 | + |
| 184 | +1. The replica is seeded, and the time taken for seeding the data depends upon size of source database. You can monitor the status of seeding in the Azure portal or by running the following TSQL queries on the replica database: |
| 185 | + |
| 186 | + ```sql |
| 187 | + SELECT * FROM sys.dm_geo_replication_link_status; |
| 188 | + SELECT * FROM sys.dm_operation_status; |
| 189 | + ``` |
| 190 | + |
| 191 | +1. Once the database seeding is finished, perform a planned (no data loss) failover to make the zone redundant target database as primary. Use the [sys.dm_geo_replication_link_status](/sql/relational-databases/system-dynamic-management-views/sys-dm-geo-replication-link-status-azure-sql-database?view=azuresqldb-current&preserve-view=true) to view the status of the geo-replication state. The `replication_state_desc` is `CATCH_UP` when the secondary database is in a transactionally consistent state. In the [sys.dm_operation_status](/sql/relational-databases/system-dynamic-management-views/sys-dm-operation-status-azure-sql-database?view=azuresqldb-current&preserve-view=true) dynamic management view, look for `state_desc` to be `COMPLETED` when the seeding operation has completed. |
| 192 | + |
| 193 | +1. Update the server name in the connection strings for the application to reflect the new zone redundant database. |
| 194 | + |
| 195 | +1. To clean up, consider removing the original non-zone redundant database from the geo replica relationship. You can choose to delete it. |
| 196 | + |
| 197 | + |
| 198 | +## Next steps |
| 199 | + |
| 200 | +> [!div class="nextstepaction"] |
| 201 | +> [Azure services and regions that support availability zones](availability-zones-service-support.md) |
0 commit comments