Jaa


How to modify Windows Service Bus Connection string in an existing Service Bus Farm

If you have an already configured  Service Bus Farm, and you need to modify some or all of the Service Bus Connection strings (Gateway, SBFarm and Message Containers ) for whatever reason, such as SQL databases have been moved/renamed, wanted to add ‘Failover Partner’ attribute for Mirroring support, etc. please follow below steps (no information will be lost):

Please notice that Direct update of DB is not possible as – to adhere to Windows Server Security Guidelines all Secure strings are encrypted. Also – modifying db is not just enough – as there are many places where this info is present.

As an example, let’s imagine that we need to modify SB connection string to add “Failover Partner” attribute. The cmdlet would be like below:

 1.  Execute "SB-GetFarm" cmdlet, to collect information about your current configuration: Certificates thumbprint, connection string, RunAsAccount , MessageBrokerPort , etc. You will need that info on step 3.

 2.  Remove all nodes from the Service Bus Farm

 3. On one of the farm nodes, Restore the SBFarm using the new Connection string. As an example, let’s imagine that we need to modify SB connection string to add “Failover Partner” attribute. The cmdlet would be like below:

Restore-SBFarm -FarmCertificateThumbprint F91C37410FBE53B92E1B24FAC7A0D82EA4391B81 -GatewayDBConnectionString "Data Source=<SQL Server>;Failover Partner=<SQL Mirroring Server>;Initial Catalog=SbGatewayDatabase;Integrated Security=True;Encrypt=False" -SBFarmDBConnectionString "Data Source=<SQL Server>;Failover Partner= Mirroring Server>;Initial Catalog=SbManagementDBNew;Integrated Security=True;Encrypt=False" -EncryptionCertificateThumbprint  91C37410FBE53B92E1B24FAC7A0D82EA4391B81 -RunAsAccount <YourAccount> -MessageBrokerPort <MessageBrokerPort> -HttpsPort <HttpsPort> -TCPPort <TCPPort>

Note: The Restore-SBFarm cmdlet creates a new Service Bus for Windows Server farm database (SbManagementDBNew). You can delete the old Service Bus for Windows Server farm database. Once above cmdlet is executed, next two connections strings will have been changed: GatewayDBConnectionString and SBFarmDBConnectionString

4. On all new farm nodes, run the Add-SBHost :

$secure_string_pwd = convertto-securestring "<Your Password>" -asplaintext -force

Add-SBHost -SBFarmDBConnectionString "Data Source=<SQL Server>;Failover Partner=<SQL Mirroring Server>;Initial Catalog=SbManagementDBNew;Integrated Security=True;Encrypt=False" -RunAsPassword $secure_string_pwd -EnableFirewallRules $T

5. Call the Stop-SBFarm cmdlet to stop all Service Bus for Windows Server services on all hosts, that’s a prerequisite for next step.

6. Restore the message containers. This step is required to modify the connection string to the message containers. Remember that you can have more than one (For more information, see the Get-SBMessageContainer cmdlet).

  Restore-SBMessageContainer -Id 1 -ContainerDBConnectionString "Data Source=<SQL Server>;Failover Partner=<SQL Mirroring Server>;Initial Catalog=SBMessageContainer01;Integrated Security=True;Encrypt=False"

7. Call the Start-SBFarm cmdlet to start all Service Bus for Windows Server services on all hosts.

 

Hope you find it interesting!!

Comments