Configuring for cloud services hosting
Cloud services is a hosting model provided by the Azure cloud, which is specifically designed for hosting large applications. For a detailed description of the cloud service configuration in Azure, see What is the Cloud Service model packaging.
When NServiceBus is hosted in cloud services, it needs to connect to a specific Azure storage account (for Azure Storage Queues) or an Azure Service Bus namespace. For more information on required connection string formats, refer to the Windows Azure connection string formats article.
Configuring an endpoint
When an endpoint is hosted in a cloud service, it should be configured by implementing the IConfigureThisEndpoint
interface.
public class EndpointConfig :
IConfigureThisEndpoint,
AsA_Worker
{
public void Customize(BusConfiguration busConfiguration)
{
// Configure transport, persistence, etc.
}
}
Convention to override configuration
NServiceBus is typically configured using an app.
file, however Azure Cloud Services have their own configuration model. That makes settings management between various environments (e.g. local machine and production) complicated. To simplify the process, NServiceBus supports a convention-based configuration which allows for adding any NServiceBus setting to the service configuration file. The value specified in the service configuration file will override the value specified in the app.
file.
The configuration source can be turned on like this:
busConfiguration.AzureConfigurationSource();
Names used for property overrides always have the following structure: TagName.
. Tags can be nested: ParentTagName.
. It's currently not possible to override parent tags that contain multiple child tags with the same name, therefore MessageEndpointMappings
can't be overridden using this approach.
The default value set in the config section has the lowest priority. It can be overridden by the value specified in the app.
file. The value provided in the service configuration file takes precedence over the value specified in the app.
file.
Applying configuration changes
Azure cloud services allow changing the configuration settings from within the Azure portal. However, the changes made in the Azure portal are not automatically applied to the all NServiceBus components.
If configuration changes should result in a reconfiguration of the endpoint, consider instructing the RoleEnvironment
to restart the role instances by subscribing to the RoleEnvironment.Changing event and setting e.
If at least two role instances are running, this will result in a configuration change without inflicting downtime on the overall system. Each instance may reboot individually in the process, but this is orchestrated across update and fault domains so that at any point in time an instance is operational.