Forum Discussion
Aaida_Aboobakkar
Microsoft
Feb 25, 2025LAB: Set up DR for SQL in Azure VM by using Always on feature
Why create DR for SQL in azure VMs?
Creating a disaster recovery (DR) plan for SQL Server in Azure Virtual Machines (VMs) is crucial to ensure business continuity and data protection. Azure VMs offer flexible and scalable solutions for high availability and disaster recovery, such as Always On availability groups, failover clustering, and geo-replication.
These features help minimize downtime and data loss during unexpected events, ensuring that your SQL Server databases remain accessible and resilient. By leveraging Azure's built-in DR capabilities, organizations can meet their recovery time objectives (RTO) and recovery point objectives (RPO), safeguarding critical business operations.
Architectural diagram
Steps
- Create two SQL Server VM, one for on-premises and another for azure (for sake of lab I am creating both in azure vm. The experience is same for both scenario)
- Follow the below steps in both SQL VMs to prep for DR.
- Set domain for sql servers
- Restart VM (Very Important to make changes effective)
- Make sure the sql servers are joined to same domain
- system--> Advanced setting--> computer name-->Change domain
- Restart VM
- Create Secondary VM using SQL supported image ( I am selecting standard SQL edition option)
- Add roles and features
In Features select Failover clustering
- Complete installation
- Enable Always on feature
Repeat step for both VMs
- Create a primary db in SQL1
In primary create test database and add data
-- Create the database
CREATE DATABASE userdatabase;
-- Switch to the new database
USE userdatabase;
-- Create the table
CREATE TABLE userinfo (
email VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL
);
-- Insert dummy data into the userinfo table
INSERT INTO userinfo (email, name) VALUES ('john.doe@example.com', 'John Doe');
INSERT INTO userinfo (email, name) VALUES ('jane.smith@example.com', 'Jane Smith');
INSERT INTO userinfo (email, name) VALUES ('alice.jones@example.com', 'Alice Jones');
INSERT INTO userinfo (email, name) VALUES ('bob.brown@example.com', 'Bob Brown');
SELECT * from userinfo
- Create cluster
Create Availability group
Now you can see both servers are part of same availability group
test failover
No RepliesBe the first to reply