30 分钟后 Azure 函数超时
Azure Function Timeout after 30 minutes
我已经设置了 Azure Functions v3。根据本文档配置了标准计划:https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json#functiontimeout。另外,将 functionTimeout 设置为 Unlimited
标准 (S1:1) 计划是否正确?我是否需要将其更改为 P1V12 才能将其设置为 'unlimited' 超时?
host.json:
30 分钟后继续崩溃:
好像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);
}
我已经设置了 Azure Functions v3。根据本文档配置了标准计划:https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json#functiontimeout。另外,将 functionTimeout 设置为 Unlimited
标准 (S1:1) 计划是否正确?我是否需要将其更改为 P1V12 才能将其设置为 'unlimited' 超时?
30 分钟后继续崩溃:
好像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);
}