How to: Use a Third Party Hosting Service with the Service Bus
It is possible to run an application that uses the Windows Azure Service Bus on a third-party hosting platform. There are no special settings that you must use in order to deploy your application on the hosting service, other than what the hosting service requires. There are also no special security requirements for accessing the Service Bus from a third-party system. However, in order to get your application to run correctly, there are two things to note, which are very similar to running an application on Windows Azure:
The hosting service may not install the Windows Azure SDK
If the hosting service does not have the Windows Azure SDK installed, you cannot know for sure that the Microsoft.ServiceBus.dll assembly is available for your application to use. Therefore, you must make sure that the appropriate assembly is packaged and redistributed with your application. To do so, see the following procedure.
The hosting service may not have the appropriate listings in the Machine.config file
Because the third-party hosting service may not have the Windows Azure SDK installed, the Machine.config file on the host has no information about Service Bus bindings or endpoints. Due to security restrictions on many hosting services, you will likely not be able to install the SDK on the host computer in order to add those configuration elements to the Machine.config file. Therefore, the App.config file for your Service Bus application will likely not have any information specific to Windows Azure in it.
There are two solutions to this issue.
The recommended solution is to use the Windows Azure APIs to programmatically configure your application. For example, although you could store name and password information in the App.config file, you would programmatically set any relay binding configurations. For more information about setting the configuration programmatically, see Configuring a WCF Service to Register with the Service Bus.
The second solution is to manually modify the App.config file for your application by adding all of the relevant Service Bus information. Once you do this, you can use the App.config file to configure bindings and endpoints. To do so, you can see the Machine.config file on a computer that has the Windows Azure SDK installed, find all Windows Azure related configuration information, and copy it to the App.config file for your application. Although this will let you use the App.config file on the host service, it will be difficult to test your code: you may experience duplication issues with the Machine.config file on the local test computer, which will already have the Windows Azure SDK installed. Therefore, we recommend that you use the previous option, and set everything programmatically.
- The recommended solution is to use the Windows Azure APIs to programmatically configure your application. For example, although you could store name and password information in the App.config file, you would programmatically set any relay binding configurations. For more information about setting the configuration programmatically, see Configuring a WCF Service to Register with the Service Bus.
To package the Service Bus assembly with your application
In Solution Explorer, add the Microsoft.ServiceBus.dll assembly to your project as a reference.
This step is the standard process for adding a reference to an assembly.
In the Reference folder, right-click Microsoft.ServiceBus. Then click Properties.
In the Properties dialog, set Copy Local to True.
Doing so makes sure that the Microsoft.ServiceBus.dll assembly is copied to the local \bin path and available to your application when it runs on the host service.