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
Configuration
Application Settings
Function runtime settings
General Settings
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,IList
1 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:
– OS: Windows
– Runtime Stack: .NET 8 Isolated Process (Early Access)
– Deployment-Mode: Self-Contained
Portal:
Application Settings of my Function App:
deployed function=>Code+Test
, click onTest/Run
.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.
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.