Skip to the content.

SQL-Managed Instance: Disaster Recovery Reference Architecture

Step by Step Implementation Guide

SQL Managed Instance Installation process. - Step by Step to Disaster Recovery - Ready for Massive roll out;

This document provide the Best Practice guidence for the SQL-Managed Instance implementation considering a Disaster Recovery Architecture with a full Failover Group configured.

The entire process can be implemented by Azure Resource Manager configuration, Powershell, ARM Templates or Infrastructure as a Code using Terraform. This Step by Step guide covers the first scenario which is using Azure Resouce Manager.

In order to undertand the SQL Managed Instance Resource Limits, check here for more information. Few points to higlight.

Topics that you will work in this guide:

Introduction

SQL Database Managed Instance is a deployment option in Azure SQL Database that is highly compatible with SQL Server, providing out-of-the-box support for most SQL Server features and accompanying tools and services. Managed Instance also provides native virtual network (VNET) support for an isolated, highly-secure environment to run your applications. Now you can combine the rich SQL Server programming surface area in the cloud with the operational and financial benefits of an intelligent, fully-managed database service, making Managed Instance the best PaaS destination for your SQL Server workloads.

E2E Architecture

In order to ilustrate what you will have at the end of this deployment, please find here the end to end Architecture.

E2E SQL-Managed Instance Architecture:

E2E Architecture (visio)

The Visio version can be found here

Requirements to have your Disaster Recovery Implementation working:

For the First Step, let’s create your Infrastructure, which include the following:

Step 1: Main Activity: Create two Resources Groups - SQL-MI and Network

drawing

drawing

drawing

drawing

drawing

drawing

Step 2: DDoS Standard Design (Optional)

Search for DDoS protection plans and then create a protection plan following the steps below:

drawing

drawing

drawing

drawing

drawing

drawing

Step 3: Create the Virtual Network on both Regions

drawing

drawing

drawing

drawing

drawing

Step 4: Create the Network Gateways to connect the both Regions (In this scenario, EAST-US2 and CENTRAL-US)

Enabling geo-replication between managed instances and their VNets: (this reference can be found here

When you set up a failover group between primary and secondary managed instances in two different regions, each instance is isolated using an independent virtual network. To allow replication traffic between these VNets ensure these prerequisites are met:

  1. The two managed instances need to be in different Azure regions.
  2. The two managed instances need to be the same service tier, and have the same storage size.
  3. Your secondary managed instance must be empty (no user databases).
  4. The virtual networks used by the the managed instances need to be connected through a VPN Gateway or Express Route. When two virtual networks connect through an on-premises network, ensure there is no firewall rule blocking ports 5022, and 11000-11999. Global VNet Peering is not supported.
  5. The two managed instance VNets cannot have overlapping IP addresses.
  6. You need to set up your Network Security Groups (NSG) such that ports 5022 and the range 11000~12000 are open inbound and outbound for connections from the other managed instanced subnet. This is to allow replication traffic between the instances Important Misconfigured NSG security rules leads to stuck database copy operations.
  7. The secondary instance is configured with the correct DNS zone ID. DNS zone is a property of a managed instance and its ID is included in the host name address. The zone ID is generated as a random string when the first managed instance is created in each VNet and the same ID is assigned to all other instances in the same subnet. Once assigned, the DNS zone cannot be modified. Managed instances included in the same failover group must share the DNS zone. You accomplish this by passing the primary instance’s zone ID as the value of DnsZonePartner parameter when creating the secondary instance.

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

Step 5: Create the SQL Managed Instance on the first region

drawing

drawing

drawing

drawing

drawing

drawing

drawing

Step 6: SSMS Connection to your SQL Managed Instance

In this Step, a Windows Jumpbox will be created on the same vnet, separated subnet, so you will be able to access the SQL Managed Instance using SSMS.

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

drawing

USE master
GO
IF NOT EXISTS (
   SELECT name
   FROM sys.databases
   WHERE name = N'TutorialDB'
)
CREATE DATABASE [TutorialDB]
GO

drawing

drawing

drawing

-- Create a new table called 'Customers' in schema 'dbo'
-- Drop the table if it already exists
IF OBJECT_ID('dbo.Customers', 'U') IS NOT NULL
DROP TABLE dbo.Customers
GO
-- Create the table in the specified schema
CREATE TABLE dbo.Customers
(
   CustomerId        INT    NOT NULL   PRIMARY KEY, -- primary key column
   Name      [NVARCHAR](50)  NOT NULL,
   Location  [NVARCHAR](50)  NOT NULL,
   Email     [NVARCHAR](50)  NOT NULL
);
GO

drawing

drawing

-- Insert rows into table 'Customers'
INSERT INTO dbo.Customers
   ([CustomerId],[Name],[Location],[Email])
VALUES
   ( 1, N'Orlando', N'Australia', N''),
   ( 2, N'Keith', N'India', N'keith0@adventure-works.com'),
   ( 3, N'Donna', N'Germany', N'donna0@adventure-works.com'),
   ( 4, N'Janet', N'United States', N'janet1@adventure-works.com')
GO
-- Select rows from table 'Customers'
SELECT * FROM dbo.Customers;

drawing

Step 7: Create a Second SQL Managed Instance.

drawing

drawing

drawing

drawing

drawing

7.6 After around 4 to 6 hours, the second Instance will be ready for use. As you can see, at this moment there are 2 Managed Instated created (EAST-US2 and CENTRAL-US)

drawing

Step 8: Check the connectivity to the Second Managed Instance withthe SSMS installed in another Region - E2E Architecture Test

drawing

drawing

drawing

drawing

drawing

Step 9: Create the Failover Group

drawing

drawing

drawing

drawing

drawing