Skip to content

RootDBA

DBA expertise: PostgreSQL, SQL Server & MySQL

Menu
  • Home
  • blog
  • PostgreSql
  • MySql
  • Sql Server
  • About AHMED – Root DBA
Menu

SQL Server Contained Availability Groups

Posted on September 2, 2025 by AHMED

Contained Availability Groups (CAGs) in SQL Server 2022 allow you to create an availability group that is independent of the instance, separating logins, jobs, and database mail from the main SQL Server instance. This is particularly useful when you want to create an availability group for a specific application while keeping its authentication and configurations isolated.

With Contained Availability Groups, a copy of the master and msdb databases is maintained within the group, ensuring that logins, jobs, and database mail settings are unique to the availability group rather than shared with the instance.

Key Features of Contained Availability Groups:

  1. Multi-Tenant Support – Ideal for database-as-a-service (DBaaS) environments, allowing customers to have isolated authentication and jobs.
  2. Automated Login Synchronization – No need for manual login synchronization, as the master database within the group is automatically replicated.
  3. Dedicated Always On Environments – Enables separate high-availability environments for different applications on the same SQL Server instance.

Contained Availability Groups are exclusively available in SQL Server 2022.
you also need ssms 19 and above

Configured Contained Availability Group

on this lab we have already setup normal Availability Group that setup for database StackOverflow2010 , we will create separate contained Availability Group for database AdventureWorks2008R2

Pasted image 20250308182001.png

to start right click on Availability Groups and select New Availability Group Wizard

Pasted image 20250308182147.png

on next window give friendly unique name to availability group and check mark

Pasted image 20250309140256.png

remaining steps are the same to regular availability group setup which consist of adding replica , configure listener with dns name , select way you want to sync database with replica

once setup is completed you notice that Availability Groups icon is changed

Pasted image 20250310111852.png
additionally if you expand Availability Databases you notice that master database and msdb copy is also added

Pasted image 20250310111835.png

Pasted image 20250310113036.png

with both copy of master and msdb you will get separate separate database for login and job for this AG that is separated from instance .

contained AG limitation

  • jobs can only run from primary nodes of the AG
  • contained AG doesn’t support replication
  • Backups of contained databases are portable, but restoring them outside the AG requires ensuring containment settings and users are preserved. This can lead to mismatches if not carefully managed.
0
Visited 36 times, 1 visit(s) today
Category: Sql server

Post navigation

← enable and configuring auditing and masking in mysql
How to configure Log shipping in Sql Server →
© 2025 RootDBA | Powered by Minimalist Blog WordPress Theme