skip to Main Content

Updated – see notes below


I have a .NET 8 Azure Function (Windows, not Linux) that is triggered by a CRON timer.

I published it to a Local Folder:

  • Configuration : Release
  • Target Framework : net8.0
  • Target Runtime : win-x64
  • Deployment mode : Self-contained

And then deployed it to the wwwroot folder and it’s working fine.

From the "Diagnose and solve problems" pane of the App Service, it gave me a warning that I should deploy this using the "Run Frm Package approach".

I added the configuration value WEBSITE_RUN_FROM_PACKAGE with a value of "1" and that made the wwwroot folder read-only, so that seemed to have been set correctly.

I then deployed the exact same set of files to the "SitePackages" folder and restarted the App Service. It reported that it has restarted successfully.

The only problem is that my functions no longer fires.

I didn’t set the URL because it’s not Linux and is in the default SitePackages folder. The zip is well under the 1GB limit.


Update 18-Dec-2023

Based on the comment by @PravallikaKV, I have some more information.

Isolated rather than In process

.NET 8 wasn’t fully released when this project started, so I went with the isolated model. This is a copy of the 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>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
        <TreatWarningsAsErrors>True</TreatWarningsAsErrors>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
        <TreatWarningsAsErrors>True</TreatWarningsAsErrors>
    </PropertyGroup>
    <ItemGroup>
        <FrameworkReference Include="Microsoft.AspNetCore.App" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.3" OutputItemType="Analyzer" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.0" />
        <PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.0" />
    </ItemGroup>
    <ItemGroup>
        <None Update="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>

Publish profile

enter image description here

Configuration

Application Settings

enter image description here

Function runtime settings

enter image description here

General Settings

enter image description here

Exception

When I run this as a package, I now see the following error message:

Full Exception :
System.NullReferenceException : Object reference not set to an instance of an object.
at Microsoft.Azure.WebJobs.Script.FunctionMetadataManager.GetFallbackWorkerConfig() at //src/WebJobs.Script/Host/FunctionMetadataManager.cs : 129
at Microsoft.Azure.WebJobs.Script.FunctionMetadataManager.LoadFunctionMetadata(Boolean forceRefresh,Boolean includeCustomProviders,IFunctionInvocationDispatcher dispatcher,IList1 workerConfigs) at /_/src/WebJobs.Script/Host/FunctionMetadataManager.cs : 137 at Microsoft.Azure.WebJobs.Script.FunctionMetadataManager.GetFunctionMetadata(Boolean forceRefresh,Boolean applyAllowList,Boolean includeCustomProviders,IList1 workerConfigs) at /
/src/WebJobs.Script/Host/FunctionMetadataManager.cs : 90
at async Microsoft.Azure.WebJobs.Script.WebHost.Management.FunctionsSyncManager.GetSyncTriggersPayload() at //src/WebJobs.Script.WebHost/Management/FunctionsSyncManager.cs : 312
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.Management.FunctionsSyncManager.TrySyncTriggersAsync(Boolean isBackgroundSync) at /
/src/WebJobs.Script.WebHost/Management/FunctionsSyncManager.cs : 125

2

Answers


    • Check the logs if there are any error messages which might be causing the function to fail.

    • Check if your function code is compatible with the .NET 8 runtime.

    I have replicated the same in my environment with the below steps:

    • Created a .NET 8 Isolated Azure function with Timer Trigger.
    • Deployed the function to the newly created Azure function app with the below options:
      – OS: Windows
      – Runtime Stack: .NET 8 Isolated Process (Early Access)
      – Deployment-Mode: Self-Contained

    enter image description here

    Portal:

    enter image description here

    Application Settings of my Function App:

    enter image description here
    enter image description here

    • Navigate to the deployed function=>Code+Test, click on Test/Run.

    enter image description here

    Connected! You are now viewing logs of Function runs in the current Code + Test panel. To see all the logs for this Function, please go to 'Monitor' from the Function menu.
    2023-12-13T09:40:02Z [Information] Executing 'Functions.Function1' (Reason='This function was programmatically called via the host APIs.', Id=f83e5e82-e8b4-45f7-b582-d305c2d83f96)
    2023-12-13T09:40:02Z [Information] C# Timer trigger function executed at: 12/13/2023 9:40:02 AM
    2023-12-13T09:40:02Z [Information] Next timer schedule at: 12/13/2023 9:45:00 AM
    2023-12-13T09:40:02Z [Information] Executed 'Functions.Function1' (Succeeded, Id=f83e5e82-e8b4-45f7-b582-d305c2d83f96, Duration=10ms)
    
    • Check if the function is running without any issues.

    • Navigate to the Monitor in left pane, Check the Invocation Traces:

    • I could see my deployed Timer Trigger function getting fired for every 5 minutes.

    enter image description here

    Login or Signup to reply.
  1. I worked with the poster and resolved this offline.

    The drag and drop functionality in Kudu doesn’t actually use ZipDeploy.
    You would need to invoke Zip Deploy either via Visual Studio and Publish or VS Code and Deploy Function App or CLI or the Rest API’s.

    Zip push deployment for Azure Functions | Microsoft Learn has more on this.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search