如何启用cscfg覆盖以使用NServiceBus Azure配置

时间:2015-05-08 12:13:42

标签: azure nservicebus azureservicebus azure-configuration

使用NServiceBus时,传输连接字符串似乎不是首先从适用的云配置中获取,而是立即从app.config中获取。

我尝试过的选项:

使用配置部分(:

cscfg

<ConfigurationSettings>
  <Setting name="AzureServiceBusQueueConfig.ConnectionString" value="Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yyy" />
</ConfigurationSettings>

app.config

<AzureServiceBusQueueConfig ConnectionString="Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yyy" />

使用自定义连接字符串名称:

cscfg

<ConfigurationSettings>
  <Setting name="NServiceBus.Transport" value="Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yyy" />
</ConfigurationSettings>

app.config

<connectionStrings>
    <add name="NServiceBus.Transport" connectionString="Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yyy"/>
</connectionStrings>

还尝试使用以下代码行覆盖它,因为此问题仍处于打开状态(https://github.com/Particular/NServiceBus.AzureServiceBus/issues/20):

configuration.UseTransport<AzureServiceBusTransport>().ConnectionString(CloudConfigurationManager.GetSetting("AzureServiceBusQueueConfig.ConnectionString"));

或者尝试手动设置连接字符串名称,使用app.config再次工作,但不允许cscfg覆盖。

configuration.UseTransport<AzureServiceBusTransport>().ConnectionStringName("NServiceBus.Transport");

1 个答案:

答案 0 :(得分:2)

您是否打开了天蓝色配置源?您可以在总线配置上使用以下扩展方法来执行此操作:

.AzureConfigurationSource()