c# - CloudConfigurationManager.GetSetting() 使用 Azure Configuration Manager 3.0 返回 null

标签 c# azure azure-worker-roles

我刚刚升级(通过 nuget)到最新版本的 Azure 配置管理器 (3.0.0):

https://www.nuget.org/packages/Microsoft.WindowsAzure.ConfigurationManager/3.0.0

一旦我这样做了 - 并进行了一些命名空间调整 - 看起来它已经停止返回我的 Azure 辅助角色配置的值。

我正在检索如下连接字符串值:

var storageCs = CloudConfigurationManager.GetSetting("Microsoft.Storage.ConnectionString");

我的服务定义文件如下所示:

<?xml version="1.0"?>
<ServiceDefinition name="Payboard.Worker" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2014-06.2.4">
  <WorkerRole name="Payboard.Worker.Events" vmsize="Small">
    <ConfigurationSettings>
      <Setting name="Microsoft.Storage.ConnectionString" />
      <Setting name="PayboardEntities" />
      <Setting name="cacheSystem" />
      <Setting name="Microsoft.WindowsAzure.Plugins.Caching.ClientDiagnosticLevel" />
      <Setting name="redisCacheConnectionString" />
    </ConfigurationSettings>
    <Imports>
      <Import moduleName="RemoteAccess" />
      <Import moduleName="RemoteForwarder" />
    </Imports>
    <Startup priority="-2">
    </Startup>
  </WorkerRole>
</ServiceDefinition>

我的服务配置文件如下(删除敏感信息):

<?xml version="1.0"?>
<ServiceConfiguration serviceName="Payboard.Worker" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2014-06.2.4">
  <Role name="Payboard.Worker.Events">
    <Instances count="1" />
    <ConfigurationSettings>
      <Setting name="Microsoft.Storage.ConnectionString" value="UseDevelopmentStorage=true" />
      <Setting name="PayboardEntities" value="(standard connection string stuff)" />
      <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="true" />
      <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="ken" />
      <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="(encrypted password)" />
      <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="2015-06-19T23:59:59.0000000-07:00" />
      <Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="true" />
      <Setting name="cacheSystem" value="simple" />
      <Setting name="Microsoft.WindowsAzure.Plugins.Caching.ClientDiagnosticLevel" value="1" />
      <Setting name="redisCacheConnectionString" value="(redis connection string)" />
    </ConfigurationSettings>
    <Certificates>
      <Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="(blah)" thumbprintAlgorithm="sha1" />
    </Certificates>
  </Role>
</ServiceConfiguration>

所有这些在 2.0.3 下都可以正常工作,事实上,如果我恢复到 2.0.3,它们也可以正常工作。但在 3.0 下,任何对 CloudConfigurationManager.GetSetting() 的调用都会返回 null。

我还没有找到任何关于 3.0 下可能发生的更改的文档。有人有什么建议吗?这只是某种错误吗? (显然我现在坚持使用 2.x - 没有令人信服的理由去使用 3.0 - 但我喜欢坚持使用最新版本的东西作为一般规则。)

最佳答案

这个问题已在新发布的 3.1.0 版本中修复。

干杯, 奥盖尔

关于c# - CloudConfigurationManager.GetSetting() 使用 Azure Configuration Manager 3.0 返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29152382/

相关文章:

c# - 生成每周日期

c# - 通过 PHP 启动服务器端打印作业

azure - 如何在Azure API管理上分离开发和生产环境?

visual-studio-2012 - 未针对 Azure 辅助角色打包程序集

azure - 可以以不同的工作角色访问单个输入端点

c# - SelectSingleNode 使用 XPath 为已知良好的 xml 节点路径返回 null

c# - 使用 chrome 驱动程序查找元素

azure - 通过小型企业订阅进行 Office365 Azure Active Directory Graph 客户端访问

javascript - 更新 Azure 文档 DB 存储过程中的另一个集合

azure - 与 Windows Azure 中的 Web/辅助角色和实例混淆。