c# - 30 分钟后 Azure 函数超时

标签 c# .net asp.net-core azure-functions azure-functions-runtime

我已经设置了一个 Azure Functions v3。根据本文档配置标准计划:https://learn.microsoft.com/en-us/azure/azure-functions/functions-host-json#functiontimeout .另外,将 functionTimeout 设置为 Unlimited

标准(S1:1) 计划是否正确?我是否需要将其更改为 P1V12 才能将其设置为“无限”超时?

enter image description here enter image description here host.json:

enter image description here

30 分钟后继续崩溃: enter image description here

好像没有考虑host.json?还是计划不正确?请帮忙。

最佳答案

我能够让它工作是添加一个属性:

[Timeout("05:00:00")]
[FunctionName("MyFunction")] 

似乎 host.json 文件被忽略了

编辑 - 修复 HOST.JSON 文件

找到这个线程:https://github.com/Azure/azure-functions-servicebus-extension/issues/81

解决方法: https://github.com/Azure/azure-functions-servicebus-extension/issues/34#issuecomment-596781972

public override void Configure(IFunctionsHostBuilder builder)
        {
            var tempServices = builder.Services.BuildServiceProvider();
            var azureFuncConfig = tempServices.GetService<IConfiguration>();
            var configBuilder = new ConfigurationBuilder()
                .AddConfiguration(azureFuncConfig)
                .SetBasePath(Environment.CurrentDirectory)
                .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                .AddEnvironmentVariables();

            var configReader = configBuilder.Build();
            var config = configBuilder.AddAzureKeyVault(new AzureKeyVaultConfigurationOptions()
            {
                Client = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(new AzureServiceTokenProvider().KeyVaultTokenCallback)),
                Vault = configReader["keyvaulturl"],
                Manager = new DefaultKeyVaultSecretManager()),
            }).Build();

            builder.Services.AddSingleton<IConfiguration>(config);
        }

关于c# - 30 分钟后 Azure 函数超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68869429/

相关文章:

.net - 尝试将 AutoMapper 添加到 .NetCore1.1 - 无法识别 services.AddAutoMapper()

c# - 在 x86 上处理非常大的列表

c# - 将字符串 [] 转换为整数 []

c# - 如何查看国家简称

c# - 我如何重写此代码以避免 "Linq to entities Does not recognize method"错误

c# - 重新格式化默认的 asp.net core 错误请求错误消息

c# - Windows 应用商店和 Windows Phone 应用程序上的 Geopoint、Geocoordinate、Geoposition 或 GeoCoordinate?

c# - 我如何计算准确的耗时

c# - 如何防止颜色混合?

asp.net-core - Serilog - 如何停止请求生命周期日志并仅启用自定义信息日志