【问题标题】:Not able to read values from Azure KeyVault. The specified user does not have a valid profile无法从 Azure KeyVault 读取值。指定的用户没有有效的个人资料
【发布时间】:2021-04-29 21:19:38
【问题描述】:

我们有多个服务器,我们在 IIS 上托管 ASP.NET 网站。在网站中,我们尝试从 Azure KeyVault 获取值。

在一台服务器中,由于某种原因,它无法从 Azure KeyVault 读取值,并出现错误“指定的用户没有有效的配置文件”。我们已经完成了调查,仔细检查了配置,文件的权限 - 一切看起来都很好。还尝试在 IIS 中调整配置文件,但没有任何帮助。

这是堆栈跟踪:

Exception information: 
    Exception type: ConfigurationErrorsException 
    Exception message: An error occurred loading a configuration file: The specified user does not have a valid profile.  Unable to load 'Microsoft.Configuration.ConfigurationBuilders.Azure, Version=2.0.0.0, Culture=neutral'. (D:\<website_path> line 77)
   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, Boolean getLkg, Boolean checkPermission)
   at System.Web.Util.AppSettings.GetAppSettingsSection()
   at System.Web.Util.AppSettings.EnsureSettingsLoaded()
   at System.Web.Util.AppSettings.get_PortableCompilationOutput()
   at System.Web.Compilation.BuildManager.RestorePortableCompilationOutputSnapshot()
   at System.Web.Compilation.BuildManager.ExecutePreAppStart()
   at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException)
The specified user does not have a valid profile.  Unable to load 'Microsoft.Configuration.ConfigurationBuilders.Azure, Version=2.0.0.0, Culture=neutral'.
   at System.Configuration.TypeUtil.GetTypeImpl(String typeString, Boolean throwOnError)
   at System.Configuration.ConfigurationBuildersSection.InstantiateBuilder(ProviderSettings ps)
   at System.Configuration.ConfigurationBuildersSection.GetBuilderFromName(String builderName)
   at System.Configuration.BaseConfigurationRecord.GetSectionXmlReader(String[] keys, SectionInput input)

有没有人遇到过类似的问题?

任何帮助将不胜感激。

【问题讨论】:

  • 在其他服务器上能成功获取值还是只有一台服务器?
  • @TheobaldDu 是的,我们有多个服务器,一切都在其他服务器上运行。
  • 你能找到被推荐的用户没有有效的个人资料吗?此用户是否有权访问密钥保管库实例?错误发生在什么时候?无法访问密钥保管库或使用 null 或错误机密加载“Microsoft.Configuration.ConfigurationBuilders.Azure”的时间?
  • 我的意思是你可以检查是否有一些错误导致用户的身份错误。请参阅this,如果您使用默认凭据可能会有所帮助。

标签: c# asp.net azure iis


【解决方案1】:

我在这里回答了类似的问题:Function app in Azure could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions'

请检查 - 可能是因为相同的原因。可能有一个 nuget 包需要不同版本的Microsoft.Configuration.ConfigurationBuilders.Azure: 2.0.0。但是,您安装的版本不兼容。

【讨论】:

  • 感谢您的想法。我们检查了我们的依赖关系图,一切似乎都是兼容的,不幸的是这看起来不像这里的问题。
【解决方案2】:

在做了一些调试后,我们发现了问题。事实证明,在用户的环境变量下,我们一切都正确,但在系统的环境变量下,我们输入了错误的 AZURE_TENTANT_ID。解释为什么它作为控制台应用程序(作为当前用户运行)而不是作为 Windows 服务(作为系统运行)工作

【讨论】:

    猜你喜欢
    • 2020-05-20
    • 1970-01-01
    • 2017-12-20
    • 2010-09-09
    • 2013-07-08
    • 1970-01-01
    • 2021-01-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多