1

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": {
}

}

Agreene
  • 508
  • 7
  • 16

1 Answers1

0

I tried deploying the Function with an alternative method by using the zip command in my Gitlab pipeline like below:-

My repository with Function trigger zip:-

enter image description here

variables:
  AZURE_CLIENT_ID: xxxxx838-xxx1435cb
  AZURE_CLIENT_SECRET: xxxxxxx8313-xxxifbLE
  AZURE_TENANT_ID: xxxxx-xxx-xx038592395
  AZURE_WEBAPP_NAME: siliconfunc653

stages:
  - deploy

deploy:
  stage: deploy
  image: mcr.microsoft.com/dotnet/sdk:7.0
  script:
    - curl -sL https://aka.ms/InstallAzureCLIDeb | bash
    - apt-get install curl && curl -sL https://deb.nodesource.com/setup_12.x | bash -
    - apt-get install nodejs
    - npm install -g azure-functions-core-tools@3 --unsafe-perm true
    - az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET --tenant $AZURE_TENANT_ID
    - func azure functionapp publish $AZURE_WEBAPP_NAME --csharp
  only:
    - main

Instead of using func azure function-app-name publish command you can directly use the command below in the yml script above:-

 az functionapp deployment source config-zip --name $AZURE_WEBAPP_NAME --resource-group Insights_Test --src function.zip

Also, Make sure you have the following settings added in the Function Configuration:-

enter image description here

enter image description here

Reference:-

.gitlab-ci.yml · main · Wai Lin / gitlab-ci-Azure-Function · GitLab

Gitlab CI script to deploy a Azure Function - DEV Community

SiddheshDesai
  • 3,668
  • 1
  • 2
  • 11