Friday, February 20, 2015

Migrating your ADFS 2012 R2 SQL Database to a new or different SQL Server

I couldn't find good instructions on exactly how to migrate an existing ADFS SQL configuration to a new SQL server.  In my case, I was migrating from a stand alone SQL server to an AlwaysOn SQL Server for higher availability. 

ADFS has two databases it uses - AdfsConfiguration and AdfsArtifactStore.  So you have two places that you need up update the path to the new SQL Server.

Here are the steps I performed:

1.  Stop all ADFS Servers in your ADFS Farm.  ADFS Proxy servers are OK to leave up.
2.  Copy the two DB's to the new SQL server.
3.  Run the following command on each ADFS server in your farm to get the current information and take screenshots in case you need to revert the changes:

Get-WmiObject -namespace root/ADFS -class SecurityTokenService






Get-AdfsProperties


4. Run the following commands to update the location of the  "Adfsconfiguration" DB on each ADFS server you have: 
 

PS:\>$temp= Get-WmiObject -namespace root/ADFS -class SecurityTokenService
PS:\>$temp.ConfigurationdatabaseConnectionstring=”data source=<YourSQLServer>;initial catalog=adfsconfiguration;integrated security=true”
PS:\>$temp.put()

5.   Start ADFS Services now because the following command cannot be run with ADFS Service off.

6.  Run the below command on one of your ADFS server to update the location of the "ADFSArtifactStore" DB (Doesn't have to be run on all ADFS servers like the first command):


PS:\> Set-AdfsProperties –artifactdbconnection ”Data source=<YourSQLServer>;Initial Catalog=AdfsArtifactStore;Integrated Security=True”

7.  After the command is run, it will let you know to restart ADFS services on all servers in the farm, so do so at this time. 



8.   Run the following commands to verify that everything is now pointing at the new SQL server location:


Get-WmiObject -namespace root/ADFS -class SecurityTokenService
Get-AdfsProperties

9.  Test your configuration. You should now be pointing to the new SQL server.