The function app runs locally but is deployed as a Linux container. The deployed function isn't reporting any issues in the portal and I can see the three functions listed in the Functions blade. However, none are working (one is a simple HTTP ping which is returning a 502 Bad Gateway response).
So no obvious issues in the portal, but inspection of logs reveals this recurring exception:
System.Threading.Tasks.TaskCanceledException at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess
The formatted message is:
Failed to start a new language worker for runtime: dotnet-isolated
My suspicion is that this is something to do with the value of the site setting linuxFxVersion
. Mind you, I've tried using DOTNET|6.0
and DOTNET-ISOLATED|6.0
. In both cases it doesn't seem to make a difference and anyway when I export the function app's ARM template it has linuxFxVersion
set to the URI of the container image prefixed with DOCKER|
.
That seems to relate to this specific advice from Microsoft about pinning the host version on Linux. But it still isn't clear to me which value I should us, and anyway, in another place the advice from another Microsoft document states:
To support zip deployment and running from the deployment package on Linux, you also need to update the linuxFxVersion site config setting to DOTNET-ISOLATED|6.0.
Anyway, Here are the details of my config. I've followed every bit of guidance from Microsoft so I hope someone can spot what I've missed...
First two parts of project file:
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>V4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>true</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.CosmosDB" Version="3.0.9" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.5.2" />
</ItemGroup>
host.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}
Main
method in Program.cs:
public static async Task Main()
{
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureAppConfiguration((context, configurationBuilder) =>
{
configurationBuilder.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
if (context.HostingEnvironment.IsDevelopment())
{
configurationBuilder.AddJsonFile("local.settings.json", optional: true, reloadOnChange: true);
}
else
{
configurationBuilder.AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true);
}
configurationBuilder.AddEnvironmentVariables();
})
.ConfigureServices((context, collection) => ConfigureServices(collection, context.Configuration, context.HostingEnvironment))
.Build()
.RunAsync();
}
The function provisioning pipeline sets the following app settings:
FUNCTIONS_EXTENSION_VERSION: '~4'
FUNCTIONS_WORKER_RUNTIME: 'dotnet-isolated'
As stated above, the latest version of my site config defined during provisioning includes this:
linuxFxVersion: 'DOTNET-ISOLATED|6.0'
The Docker image uses mcr.microsoft.com/azure-functions/dotnet-isolated:4
as a base image for the published app, and mcr.microsoft.com/dotnet/sdk:6.0
to build it.
Please tell me there's something obvious I'm missing. We currently have two function apps, and neither can be deployed as dotnet-isolated. It's driving me mad!