I have an Azure function project on the .Net 7 runtime that I've configured to run in dotnet-isolated
mode. It runs successfully locally when I publish it through Visual Studio, using Azurite as the storage emulated.
The problem is that when I deploy through my Gitlab/Octopus CI/CD pipeline, the function is not displayed in the "Functions" tab of the Function App in the portal and the Azure runtime doesn't seem to be able to "see" the isolated .exe that is created by my build process and it does not run the function.
For context: I'm using Kubernetes-based runners on a self-hosted Gitlab instance. This is used for project builds. I have set the containers to pull the mcr.microsoft.com/dotnet/sdk:7.0
image, which should be the only dependencies required to build the Function App.
Ultimately, the pipeline is configured to run dotnet commands to produce a build:
- dotnet restore --force --no-cache
- dotnet build --configuration Release
And then the build is packaged and sent to Octopus deploy for deployment. I have not found dotnet publish
to ever produce a working app that Azure Function Apps can run, so I've ommitted it.
This pipeline has worked up until now with non-isolated Function apps and a windows-based runner, but something about dotnet-isolated Function apps and Linux-based runners is causing issues at runtime.
I've also noticed that without the --runtime
parameter set to win
, the runner only produces Linux-targeted apps. No .exe file is present in the build.
The hosting environment is an EP1 tier Windows Azure App Function.
Here is the project file for the Function project
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.16.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues" Version="5.1.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.11.0" />
<PackageReference Include="OpenAI" Version="1.7.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core.Jobs\Core.Jobs.csproj" />
<ProjectReference Include="..\Core\Core.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
<None Update="nrdiag.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="nrdiag_arm64.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="nrdiag_x64.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
And the FUNCTIONS_WORKER_RUNTIME setting in our config file:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
},
"ConnectionStrings": {
}
}