You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Function App v1集成Key Vault出现Azure.Core程序集加载失败问题咨询

解决方案说明

首先明确:Azure Function App v1 支持集成 Azure Key Vault,你遇到的错误是 .NET Framework 环境下典型的程序集绑定冲突问题,和功能兼容性无关。

问题根因

Azure Functions v1 运行时会预加载部分 Azure 基础 SDK 程序集,你项目中引用的 Azure.Core 1.20.0 版本与运行时默认加载的低版本 Azure.Core 产生冲突,程序集解析逻辑无法找到符合版本要求的 Azure.Core 库,因此抛出加载失败错误。

修复步骤

  • 第一步:修正项目文件语法错误
    你贴出的 .csproj 配置中存在语法错误,有一处ItemGroup标签漏写了左尖括号,修正为:
<ItemGroup>
  <Reference Include="Microsoft.CSharp" />
</ItemGroup>
  • 第二步:添加程序集绑定重定向
    在项目根目录新增 app.config 文件,添加以下配置,将所有 Azure.Core 版本请求统一重定向到你实际引用的 1.20.0 版本:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Azure.Core" publicKeyToken="92742159e12e44c8" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.20.0.0" newVersion="1.20.0.0" />
      </dependentAssembly>
      <!-- 后续如果遇到其他Azure相关库的加载错误,可按照同样格式添加对应库的绑定重定向 -->
    </assemblyBinding>
  </runtime>
</configuration>
  • 第三步:显式引用对应版本的 Azure.Core
    在 .csproj 的 PackageReference 节点中显式添加 Azure.Core 1.20.0 的引用,强制复制到输出目录:
<PackageReference Include="Azure.Core" Version="1.20.0">
  <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PackageReference>
  • 第四步:清理重建项目
    删除本地的 bin、obj 目录后重新生成项目,运行即可正常初始化 SecretClient。

额外注意事项

部署到 Azure 后,需为 Function App 开启系统分配托管身份,并为该身份分配 Key Vault 的「机密读取」权限,即可在云端正常访问 Key Vault 资源。

内容的提问来源于stack exchange,提问作者Colin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.27 13:06:08