Startup after failure ends after using the configSource attribute of the connection string along with the Azure App Service application environment connection strings

I am trying to follow the Recommendations for private configuration data and connection strings in the configuration in ASP.NET and Azure and Recommendations for deploying passwords and other sensitive data in ASP.NET and Azure App Service .

The steps I took:

I have an ASP.NET 4.6 web application with a regular web.configfile. I created two files for my secrets: Web.Secrets.AppSettings.configand Web.Secrets.ConnectionString.configby putting the corresponding secrets in them according to the tutorial and changing the root web.configso that it looks like this:

<configuration>
  <appSettings file="Web.Secrets.AppSettings.config">
  </appSettings>
  <connectionStrings configSource="Web.Secrets.ConnectionStrings.config">
  </connectionStrings>
  <!--...-->
</configuration>

Azure App Service Azure Portal, ( ).

- Azure App Service, :

"/".

. , . , .

Parser. configSource. 'Web.Secrets.ConnectionStrings.config'.

:

. ( ). , , , .

: D:\home\site\wwwroot\web.config : 8

: Microsoft.NET Framework: 4.0.30319; ASP.NET: 4.6.1590.0

, Web.Secrets.ConnectionStrings.config Web.Secrets.AppSettings.config , , . .

HTML- :

[ConfigurationErrorsException]: Unable to open configSource file 'Web.Secrets.ConnectionStrings.config'. (D:\home\site\wwwroot\web.config line 8)
   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   at System.Web.Configuration.HttpConfigurationSystem.GetApplicationSection(String sectionName)
   at System.Web.Configuration.HttpConfigurationSystem.GetSection(String sectionName)
   at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.Configuration.ConfigurationManager.get_ConnectionStrings()
   at EnvSettings.SettingsProcessor.SetConnectionString(String name, String connString, String providerName)
   at EnvSettings.SettingsProcessor.Start()
[InvalidOperationException]: The pre-application start initialization method Start on type EnvSettings.SettingsProcessor threw an exception with the following error message: Unable to open configSource file 'Web.Secrets.ConnectionStrings.config'. (D:\home\site\wwwroot\web.config line 8).
   at System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures)
   at System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods)
   at System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded)
   at System.Web.Compilation.BuildManager.ExecutePreAppStart()
   at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
[HttpException]: The pre-application start initialization method Start on type EnvSettings.SettingsProc

? Azure?

  • . , .
  • Azure App Service, . , . ! ! IS - fail, - .
  • Web.Secrets.ConnectionStrings.config, . Azure App Service. , Azure App Service.
  • ASP.NET Web Application.
  • appSettings , connectionStrings .

Azure :

WEBSITE_NODE_DEFAULT_VERSION: 4.4.7

:

web.config. , Web.Release.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <connectionStrings xdt:Transform="RemoveAttributes(configSource)"/>
  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
  </system.web>
</configuration>
+4
1

, , Azure, config configSource. , , ​​, . Azure, web.config, configSource :

ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["foo"];

(Unable to open configSource file 'Web.Secrets.ConnectionStrings.config'.).

, App Settings file, .

Azure. .NET. , , : https://github.com/davidebbo-test/ConsoleAppWithMissingConfigSourceFile

( ), , .

+3

Source: https://habr.com/ru/post/1661731/


All Articles