TFS4JIRA Self-Hosted | How to establish a connection between the TFS synchronizer and MS-SQL database installed on different machines

In this article, you can find instructions on setting up the environment to use the TFS4JIRA synchronizer app installed in a different machine/server of the database, in this case, MS-SQL DB.

Instructions:

The below keys are used to differentiate the two servers:

  • Server-1: TFS4JIRA Synchronizer Server.

  • Server-2: MS-SQL Database Server.

 

  1. Initially, on Server-1, install Microsoft® SQL Server® Compact 4.0 SP1 - download link: https://www.microsoft.com/en-us/download/details.aspx?id=30709.

  2. Then, proceed with the installation of TFS4JIRA on Server-1, follow the steps described here:
    https://appfire.atlassian.net/wiki/spaces/TFS4JIRA/pages/148193439/Installation.

  3. Next, open tfs-jira-synchronizer using http://localhost/tfs-jira-synchronizer. When the synchronizer is opened, install the Export SQLCe tool on Server-1.

  4. Stop the TFS4Jira Synchronizer application pool in IIS on Server-1.

  5. Export SQL CE db into a .sql script (schema and data) on Server-1.

  6. On Server-1 run the command: C:\Users\Administrator\Downloads\ExportSqlCe40.exe "Data Source=C:\inetpub\wwwroot\tfs-jira-synchronizer\App_Data\config.sdf" Synchronizer.sql in the directory where you downloaded the export SQLCE tool (it requires opening the terminal as administrator).

  7. Once the command is executed, the Synchronizer.sql file is created in path C:\inetpub\wwwroot\tfs-jira-synchronizer\App_Data\.

  8. Now on Server-2, create a new DB in MSSQL using the below script.

The PASSWORD = 'YOUR_PASSWORD' should be changed as per your standards.

sp_configure 'contained database authentication', 1; GO RECONFIGURE; GO -- Create database for synchronizer CREATE DATABASE TFS4JIRA; GO -- enable contained db auth on the level of a db Use MASTER; GO ALTER DATABASE TFS4JIRA SET RESTRICTED_USER WITH ROLLBACK IMMEDIATE; ALTER DATABASE TFS4JIRA SET containment=partial; ALTER DATABASE TFS4JIRA SET MULTI_USER; GO SELECT containment_desc FROM sys.databases WHERE name='TFS4JIRA' -- create user with password, contained in the db USE [TFS4JIRA] CREATE USER TFS4JIRA_Synchronizer_User WITH PASSWORD = 'YOUR_PASSWORD'; GO -- add the user to the db_owner role - because EF will alter schema on migrations -- (otherwise db_data_reader and _writer would be enough) USE [TFS4JIRA] ALTER ROLE db_owner ADD MEMBER TFS4JIRA_Synchronizer_User GO
  1. Enable the “SQL Server and Windows Authentication mode” on Server-2.

    1. Open SSMS

    2. Right-click the server and choose Properties.

    3. Open the “Security” section.

    4. Change the “Server Authentication” option to "SQL Server and Windows Authentication Mode" and click “OK”

    5. Restart SQL Express instance to apply authentication changes

  2. Copy the Synchronizer.sql file from Server-1 to Server-2.
    Run the following command in Server-2 command prompt:
    sqlcmd -S <your-device-name>\SQLEXPRESS,1433 -U TFS4JIRA_Synchronizer_User -P B$3K94ynVQf7aD -d TFS4JIRA -i C:\Users\Administrator\Desktop\Synchronizer.sql

  3. Updated connection string in Web.config on Server-1.
    Update the “forced type” application setting by changing its value to “SyncProfileContextExpressConnection.”
    Change the value for SyncProfileContextExpressConnection in <connectionStrings>
    <add name="SyncProfileContextExpressConnection" connectionString="Data Source=<your-device-name>\TFS4JIRA,1433; Database=TFS4JIRA; User Id=TFS4JIRA_Synchronizer_User; Password=B$3K94ynVQf7aD; MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />

  4. Restart the TFS4Jira Synchronizer application pool in IIS on Server-1.

 

After all those steps, you have the TFS4Jira Synchronizer installed on one machine, Server-1, and the database installed on a different machine, Server-2. This might help to comply with the security policies of your company.