Azure AD Connect: How to recover from LocalDB 10-GB limit
Azure AD Connect requires a SQL Server database to store identity data. You can either use the default SQL Server 2019 Express LocalDB installed with Azure AD Connect or use your own full SQL. SQL Server Express imposes a 10-GB size limit. When using LocalDB and this limit is reached, Azure AD Connect Synchronization Service can no longer start or synchronize properly. This article provides the recovery steps.
There are two common symptoms:
Azure AD Connect Synchronization Service is running but fails to synchronize with “stopped-database-disk-full” error.
Azure AD Connect Synchronization Service is unable to start. When you attempt to start the service, it fails with event 6323 and error message "The server encountered an error because SQL Server is out of disk space."
Short-term recovery steps
This section provides the steps to reclaim DB space required for Azure AD Connect Synchronization Service to resume operation. The steps include:
- Determine the Synchronization Service status
- Shrink the database
- Delete run history data
- Shorten retention period for run history data
Determine the Synchronization Service status
First, determine whether the Synchronization Service is still running or not:
Log in to your Azure AD Connect server as administrator.
Go to Service Control Manager.
Check the status of Microsoft Azure AD Sync.
If it is not running, try to start the service. If the service starts successfully, skip Shrink the database step and go to Delete run history data step. Otherwise, continue with Shrink the database step.
Shrink the database
Use the Shrink operation to free up enough DB space to start the Synchronization Service. It frees up DB space by removing whitespaces in the database. This step is best-effort as it is not guaranteed that you can always recover space. To learn more about Shrink operation, read this article Shrink a database.
Skip this step if you can get the Synchronization Service to run. It is not recommended to shrink the SQL DB as it can lead to poor performance due to increased fragmentation.
The name of the database created for Azure AD Connect is ADSync. To perform a Shrink operation, you must log in either as the sysadmin or DBO of the database. During Azure AD Connect installation, the following accounts are granted sysadmin rights:
- Local Administrators
- The user account that was used to run Azure AD Connect installation.
- The Sync Service account that is used as the operating context of Azure AD Connect Synchronization Service.
- The local group ADSyncAdmins that was created during installation.
Back up the database by copying ADSync.mdf and ADSync_log.ldf files located under
%ProgramFiles%\Microsoft Azure AD Sync\Datato a safe location.
Start a new PowerShell session.
Navigate to folder
%ProgramFiles%\Microsoft SQL Server\110\Tools\Binn.
Start sqlcmd utility by running the command
./SQLCMD.EXE -S "(localdb)\.\ADSync" -U <Username> -P <Password>, using the credential of a sysadmin or the database DBO.
To shrink the database, at the sqlcmd prompt (
DBCC Shrinkdatabase(ADSync,1);, followed by
GOin the next line.
If the operation is successful, try to start the Synchronization Service again. If you can start the Synchronization Service, go to Delete run history data step. If not, contact Support.
Delete run history data
By default, Azure AD Connect retains up to seven days’ worth of run history data. In this step, we delete the run history data to reclaim DB space so that Azure AD Connect Synchronization Service can start syncing again.
Start Synchronization Service Manager by going to START → Synchronization Service.
Go to the Operations tab.
Under Actions, select Clear Runs…
You can either choose Clear all runs or Clear runs before… <date> option. It is recommended that you start by clearing run history data that are older than two days. If you continue to run into DB size issue, then choose the Clear all runs option.
Shorten retention period for run history data
This step is to reduce the likelihood of running into the 10-GB limit issue after multiple sync cycles.
Open a new PowerShell session.
Get-ADSyncSchedulerand take note of the PurgeRunHistoryInterval property, which specifies the current retention period.
Set-ADSyncScheduler -PurgeRunHistoryInterval 2.00:00:00to set the retention period to two days. Adjust the retention period as appropriate.
Long-term solution – Migrate to full SQL
In general, the issue is indicative that 10-GB database size is no longer sufficient for Azure AD Connect to synchronize your on-premises Active Directory to Azure AD. It is recommended that you switch to using the full version of SQL server. You cannot directly replace the LocalDB of an existing Azure AD Connect deployment with the database of the full version of SQL. Instead, you must deploy a new Azure AD Connect server with the full version of SQL. It is recommended that you do a swing migration where the new Azure AD Connect server (with SQL DB) is deployed as a staging server, next to the existing Azure AD Connect server (with LocalDB).
- For instruction on how to configure remote SQL with Azure AD Connect, refer to article Custom installation of Azure AD Connect.
- For instructions on swing migration for Azure AD Connect upgrade, refer to article Azure AD Connect: Upgrade from a previous version to the latest.
Learn more about Integrating your on-premises identities with Azure Active Directory.