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

使用托管身份配置Azure Function App与App Configuration时遇间歇性错误

.NET 7隔离式v4 Azure Function App间歇性崩溃问题

我们运行基于.NET 7的隔离式v4 Azure Function App,通过Azure App Configuration获取配置项与功能标志,但应用会间歇性崩溃(每分钟发生2-3次),错误信息可查看Function App日志流截图。

相关配置

Host.json配置

{
  "version": "2.0",
  "extensions": {
    "queues": {
      "maxPollingInterval": "00:00:00.100",
      "batchSize": 32,
      "maxDequeueCount": 7
    }
  }
}

Program.cs中的App Configuration配置代码

var appConfigName =
   $"https://{(Environment.GetEnvironmentVariable("Environment")!.ToUpper() != "PROD" ? "shared-test" : "prod")}" +
   $"-appconfiguration.azconfig.io";

var clientId = Environment.GetEnvironmentVariable("ClientIdUserAssignedManagedIdentity");
var tokenCredential = new DefaultAzureCredential(new DefaultAzureCredentialOptions() { ManagedIdentityClientId = clientId });

config.AddAzureAppConfiguration(options =>
{
    options.Connect(new Uri(appConfigName),
            tokenCredential)
           .Select(KeyFilter.Any, LabelFilter.Null)
           .Select(KeyFilter.Any, "interservice")
           .Select(KeyFilter.Any, "intraservice-functionapp")
           .Select(KeyFilter.Any, $"{Environment.GetEnvironmentVariable("Environment")}-functionapp")
           .Select(KeyFilter.Any, $"{Environment.GetEnvironmentVariable("Environment")}-interservice")
           .ConfigureKeyVault(kv => kv.SetCredential(tokenCredential))
           .UseFeatureFlags(featureFlagOptions =>
           {
               featureFlagOptions.CacheExpirationInterval = TimeSpan.FromDays(1);
           })
           .Select(KeyFilter.Any, Environment.GetEnvironmentVariable("Environment"));
});

已尝试的方案

  • 尝试用连接字符串连接App Configuration,但因需关联Key Vault仍需使用tokenCredential,未能解决间歇性崩溃问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 12:53:33