0

是否可以像在常规 ASP.NET 网站中一样在 Azure 云服务配置中创建自定义配置部分?

即在常规 ASP.NET 站点中,您的 Web.Config 将具有以下内容:

<configuration>
  <configSections>
     <section name="myCustomConfig" type="MyNamespace.MyType" />
  </configSections>
  <myCustomConfig someProperty="someValue" />
</configuration>

这如何在云服务中完成并在多个不同角色之间共享?

4

1 回答 1

3

At this time I do not believe this is possible. There is a post for it on user voice you can vote up: http://www.mygreatwindowsazureidea.com/forums/169386-cloud-services-web-and-worker-role-/suggestions/459944-enable-custom-configuration-sections-in-csdef-cscf.

As a way around this you could put configuration into a file that is stored in BLOB storage. On start up, or when it is needed, all instances could then go pull the file to get the configuration. To deal with changes to the configuration you could either have the instances pulling the configuration from time to time as a refresher, or you could tap into the environment changed event in RoleEntryPoint that is used to detect changes to the Service Configuration. Add a setting to the service configuration that is a version number of your shared config file or something, just anything that could be modified to trigger the RoleEnvironment.Changing event.

于 2013-08-18T16:12:28.007 回答