ADFS SQL Migration

You may want to move your back end ADFS dababases to a new SQL server. This guide shows you how.

This guide is intended for ADFS clusters where you have more than one ADFS server using MS SQL. There are other ways of setting up ADFS with WID (SQL Express). This guide is only for a shared MS SQL server.

Prep work:

  • Ensure you have your new ADFS SQL databases in place on the new SQL server. Just make a copy only backup and restore over the top of new blank databases on the new SQL server.
  • Ensure you have permissions setup in SQL for the new databases. Use the same permissions that were setup before.
  • IMPORTANT: Use the below commands to see what settings are currently in the ADFS servers.

$adfsSecurityTokenService = Get-WmiObject -namespace root/ADFS -class SecurityTokenService
$adfsSecurityTokenService.ConfigurationDatabaseConnectionString

Example Output: Data Source=<sqlservername>;Initial Catalog=AdfsConfigurationV3;Integrated Security=True;Min Pool Size=20

get-AdfsProperties | select artifactdbconnection

Example Output: Data Source=<sqlservername>;Initial Catalog=AdfsArtifactStore;Integrated Security=True;Min Pool Size=20

 

The trick here is that you need to run both command but the get/set-adfsproperties command only works when ADFS is running. The first WMI command will only work when ADFS is stopped. If you stop ADFS, run the first WMI command, and try to start ADFS it may fail to start. Then you can’t run the second command. So the order of these commands is very important.

How to switch it:

  1. Run the below commands while everything is running.
  2. The temp put one will fail. Ignore this.
  3. The set-adfsprops command should work (it won’t if adfs is off)
  4. Stop adfs services
  5. Run temp put again (should work now)
  6. Rename DBs on old server (to ensure you are no longer using them)
  7. Start services.
  8. Do this on both ADFS servers.

$adfsSecurityTokenService = Get-WmiObject -namespace root/ADFS -class SecurityTokenService
$adfsSecurityTokenService.ConfigurationdatabaseConnectionstring=”Data Source=<sqlservername>;Initial Catalog=AdfsConfigurationV3;Integrated Security=True;Min Pool Size=20″
$adfsSecurityTokenService.put()

Set-AdfsProperties –artifactdbconnection “Data Source=<sqlservername>;Initial Catalog=AdfsArtifactStore;Integrated Security=True;Min Pool Size=20”

 

 

 

This entry was posted in Uncategorized. Bookmark the permalink.