如何在Azure Web App的自定义部分中覆盖web.config值? [英] How to override web.config values in custom section in Azure Web App?

查看:128
本文介绍了如何在Azure Web App的自定义部分中覆盖web.config值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Azure Web App中可以轻松覆盖web.config AppSettings部分.例如.如果我有以下web.config:

It is possible in Azure Web App to override web.config AppSettings section easily. E.g. if I have the following web.config:

<appSettings>   
    <add key="AllowedCORSOrigin" value="http://localhost:26674"/>
</appSettings>

我可以在门户网站的应用程序设置UI中覆盖它,

I can override it in the app settings UI in the portal like that:

我在web.config中也有一个自定义部分:

I have also a custom section in the web.config:

<AdWordsApi>
    <add key="OAuth2RefreshToken" value="TOKEN" />
</AdWordsApi>

是否有可能以某种方式覆盖它?我已经尝试过AdWordsApi.OAuth2RefreshTokenAdWordsApi:OAuth2RefreshToken,但这并不容易.

Is it possible to override it somehow as well? I have tried AdWordsApi.OAuth2RefreshToken and AdWordsApi:OAuth2RefreshToken, but that does not work that easily.

P.S.知道其他自定义部分是否可行,例如是否要在服务器上使用其他身份验证模式,这很有趣.

P.S. It's interesting to know if it's possible with other custom sections like e.g if I want another authentication mode on the server.

<system.web>
    <authentication mode="None" />
</system.web>

推荐答案

简短的回答是这是不可能的.

Short answer is that it is not possible.

您描述的机制仅适用于应用程序设置"和连接字符串".高层次,它的工作方式是:

The mechanism you describes only works with App Settings and Connection Strings. High level, the way it works is:

  • 您的Azure应用设置成为环境变量
  • 在运行时,一个特殊的模块在.NET config系统中动态设置这些参数.请注意,物理web.config从未修改.

但是要使这种机制适用于任意配置节将很困难,因为如果不修改物理文件就无法动态影响这些配置节.

But it would be hard to make such mechanism work on arbitrary config sections, as those could not be dynamically affected without modifying the physical file.

这篇关于如何在Azure Web App的自定义部分中覆盖web.config值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆