An Azure service that provides an event-driven serverless compute platform.
Remove any comments from host.json
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
For detailed output, run func with --verbose flag.
[2024-03-06T13:54:39.549Z] Host lock lease acquired by instance ID '0000000000000000000000006F297016'.
[2024-03-06T13:55:16.662Z] Function 'HealthCheck', Invocation id 'a6026686-5dd8-4fbe-8049-c15d6f4f201f': An exception was thrown by the invocation.
[2024-03-06T13:55:16.663Z] Result: Function 'HealthCheck', Invocation id 'a6026686-5dd8-4fbe-8049-c15d6f4f201f': An exception was thrown by the invocation.
Exception: System.Threading.Tasks.TaskCanceledException: A task was canceled.
[2024-03-06T13:55:16.664Z] at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\Coordinator\DefaultHttpCoordinator.cs:line 35
[2024-03-06T13:55:16.664Z] at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 41
[2024-03-06T13:55:16.665Z] at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 77
Stack: at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\Coordinator\DefaultHttpCoordinator.cs:line 35
[2024-03-06T13:55:16.666Z] at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 41
[2024-03-06T13:55:16.667Z] at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 77.
[2024-03-06T13:55:16.694Z] Executed 'Functions.HealthCheck' (Failed, Id=a6026686-5dd8-4fbe-8049-c15d6f4f201f, Duration=38392ms)
[2024-03-06T13:55:16.696Z] System.Private.CoreLib: Exception while executing function: Functions.HealthCheck. System.Private.CoreLib: Result: Failure
Exception: System.Threading.Tasks.TaskCanceledException: A task was canceled.
[2024-03-06T13:55:16.697Z] at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\Coordinator\DefaultHttpCoordinator.cs:line 35
[2024-03-06T13:55:16.698Z] at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 41
[2024-03-06T13:55:16.699Z] at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 77
[2024-03-06T13:55:16.700Z] at Microsoft.Azure.Functions.Worker.Handlers.InvocationHandler.InvokeAsync(InvocationRequest request) in D:\a_work\1\s\src\DotNetWorker.Grpc\Handlers\InvocationHandler.cs:line 88
Stack: at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.DefaultHttpCoordinator.SetFunctionContextAsync(String invocationId, FunctionContext context) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\Coordinator\DefaultHttpCoordinator.cs:line 35
[2024-03-06T13:55:16.701Z] at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 41
[2024-03-06T13:55:16.702Z] at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 77
[2024-03-06T13:55:16.704Z] at Microsoft.Azure.Functions.Worker.Handlers.InvocationHandler.InvokeAsync(InvocationRequest request) in D:\a_work\1\s\src\DotNetWorker.Grpc\Handlers\InvocationHandler.cs:line 88.
[2024-03-06T13:55:54.878Z] Function 'ReadCache', Invocation id 'fa6afe3a-b39d-440e-a81a-fa2ac5ed13f8': An exception was thrown by the invocation.
An Azure service that provides an event-driven serverless compute platform.
Remove any comments from host.json
Hi @Mark Urman
We are also receiving the same issue after upgrading Azure Function to .NET 8 .
Additionally, after there is a timeout and the caller retries the request then the function sometimes respond with 503 response code.
Additionally, it looks like this issue was also mentioned in this and following comment: https://github.com/Azure/azure-functions-dotnet-worker/issues/1588#issuecomment-2009587420
Here is the content of our .csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.35.0" />
<!-- Internal packages references -->
</ItemGroup>
<ItemGroup>
<!-- Internal project reference -->
</ItemGroup>
<ItemGroup>
<None Include="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
and Program.cs content:
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Polly.Caching;
using Polly.Caching.Memory;
// internal using statements omitted
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices((context, services) =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
services.AddSingleton<ITelemetryInitializer, ApplicationInsightsTelemetryInitializer>();
services.AddConfiguration<Config>(context.Configuration);
services.AddHealthChecks()
.AddCheck<StorageAccountHealthCheck>("StorageAccount");
// additional code for registering internal services
})
.ConfigureLogging((context, builder) =>
{
builder.Services.Configure<LoggerFilterOptions>(options =>
{
var defaultRule = options.Rules.FirstOrDefault(rule => rule.ProviderName
== "Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider");
if (defaultRule is not null)
{
options.Rules.Remove(defaultRule);
}
});
})
.Build();
host.Run();
also you can find failing function below:
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using System.Net;
using Microsoft.Azure.Functions.Worker;
// internal namespace for ICustomHealthCheckService omitted
namespace Xxx;
public sealed class HealthCheck
{
private readonly ICustomHealthCheckService healthCheckService;
public HealthCheck(ICustomHealthCheckService healthCheckService)
{
this.healthCheckService = healthCheckService;
}
[Function("HealthCheck")]
public async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req)
{
var healthReport = await healthCheckService.GetHealthCheckResult();
var statusCode = healthReport.Status == HealthStatus.Healthy.ToString()
? (int)HttpStatusCode.OK
: (int)HttpStatusCode.ServiceUnavailable;
return new OkObjectResult(healthReport)
{
StatusCode = statusCode
};
}
}
Hi All,
any solution or suggestion for this issue, I'm getting same error after upgrading to .net 8.0.
Hi Folks,
Any news about this issue ?
I'm having the same problem.
Best Regards,
Bernard
Hi @Balasubrahmanyam Tekimudi Thanks for reaching out.
Could you share the contents of your .csproj as well as the Program.cs files? Be sure to omit any private details. If you'd like to troubleshoot yourself, please refer to the following guide and review thoroughly what the configs of your .Net 8 Function App should be: Migrate .NET apps from the in-process model to the isolated worker model