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

How do I enable the cscfg overrides to work with NServiceBus 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");

您是否打开了 azure 配置源?您可以在总线配置上使用以下扩展方法:

.AzureConfigurationSource()