如何在Azure App Service Web应用程序上查看最终的appSettings值?(How can I view the final appSettings values on an Azure App Service web app?)

我有一个ASP.NET MVC应用程序部署到Microsoft Azure应用程序服务,并与appSettings和connectionStrings值有一些麻烦。

我在web.config中设置了一些值,并在App Service的“应用程序设置”选项卡中覆盖了一些值。 我想快速轻松地查看最终值,以检查设置是否正确选取。

我怎样才能做到这一点?

注意:我已经尝试过使用az webapp config appsettings list但是这似乎只能恢复在App Service的应用程序设置中配置的内容,而不是与web.config结合的合并结果。

I have an ASP.NET MVC app deployed to Microsoft Azure App Service and am having some trouble with the appSettings and connectionStrings values.

I have some values set in the web.config and some values overriding them in the Application Settings tab of the App Service. I want to quickly and easily view the final values to check that the settings are being picked up correctly.

How can I do this?

Note: I've tried using az webapp config appsettings list but this only seems to bring back what is configured in the Application Settings of the App Service and not the merged results of combining with web.config.

最满意答案

Azure API不会返回包含来自web.config文件的设置的值。

获得这个的唯一方法是在你自己的运行时间里询问配置系统。 例如沿这些代码使用代码:

foreach (string name in ConfigurationManager.AppSettings) { string val = ConfigurationManager.AppSettings[name]; ... } foreach (ConnectionStringSettings settings in ConfigurationManager.ConnectionStrings) { string connStr = settings.ConnectionString; string provider = settings.ProviderName; ... }

这将为您提供应用于您的应用的有效值。

No Azure API will return values that include settings that come from your web.config file.

The only way to get this is to ask the config system within your own runtime. e.g. Use code along these lines:

foreach (string name in ConfigurationManager.AppSettings) { string val = ConfigurationManager.AppSettings[name]; ... } foreach (ConnectionStringSettings settings in ConfigurationManager.ConnectionStrings) { string connStr = settings.ConnectionString; string provider = settings.ProviderName; ... }

This will give you the effective values that are applied to your app.

更多推荐