We have a Functionapp project (class library) with 7 functions (6 timetriggers and 1 servicebustrigger) running on the ,Net Framework 4.8. I tried to migrate the project to V4 using the learn.microsoft.com migration guide.
The diagram in the documentation shows support for the net48 functions running in V4 under the dotnet-isolated run-environment.
My proj file has been altered according the documentation:|
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<RootNamespace>My.Namespace</RootNamespace>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.19.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.0.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.0.0" />
<!-- Other packages may also be in this list -->
</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>
The output type clearly shows that the host will be looking for the function.exe.
The template has been set to Console application, making sense with an output type of .exe, and the functions.exe is present!
Problem (one of many) which I can not figure out is that it is looking for a functions.dll:
Here is the stacktrace:
[2023-12-06T19:36:38.225Z] Worker process started and initialized. [2023-12-06T19:36:38.252Z] Worker failed to load function: 'DbCleanFunction' with functionId: '3350649044'. [2023-12-06T19:36:38.253Z] Result: Failure Exception: System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Users\fkr22238\source\repos\PAS\Source\NL.NS.NSRA\NL.NS.NSRA.FunctionsIsolated\bin\output\NL.NS.NSRA.Fuctions.Isolated.dll' or one of its dependencies. The system cannot find the file specified. [2023-12-06T19:36:38.254Z] File name: 'file:///C:\Users\fkr22238\source\repos\PAS\Source\NL.NS.NSRA\NL.NS.NSRA.FunctionsIsolated\bin\output\NL.NS.NSRA.Fuctions.Isolated.dll' [2023-12-06T19:36:38.254Z] at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) [2023-12-06T19:36:38.256Z] at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) [2023-12-06T19:36:38.256Z] at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) [2023-12-06T19:36:38.257Z] at System.Reflection.Assembly.LoadFrom(String assemblyFile) [2023-12-06T19:36:38.257Z] at Microsoft.Azure.Functions.Worker.Invocation.DefaultMethodInfoLocator.GetMethod(String pathToAssembly, String entryPoint) in D:\a\_work\1\s\src\DotNetWorker.Core\Invocation\DefaultMethodInfoLocator.cs:line 27 [2023-12-06T19:36:38.258Z] at Microsoft.Azure.Functions.Worker.Definition.GrpcFunctionDefinition..ctor(FunctionLoadRequest loadRequest, IMethodInfoLocator methodInfoLocator) in D:\a\_work\1\s\src\DotNetWorker.Grpc\Definition\GrpcFunctionDefinition.cs:line 56 [2023-12-06T19:36:38.258Z] at Microsoft.Azure.Functions.Worker.GrpcWorker.FunctionLoadRequestHandler(FunctionLoadRequest request, IFunctionsApplication application, IMethodInfoLocator methodInfoLocator) in D:\a\_work\1\s\src\DotNetWorker.Grpc\GrpcWorker.cs:line 269
Due to all these little failures, with this one being the major failure, I tried to setup a new Function App and just copied one of the functions in it (DBClean) to see if the error would go away. It didn't work.
Anyone having the same problem or having a solution to this problem? Any help is highly appreciated!
.csproj
as shown below:.csproj:
local.settings.json:
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
in yourlocal.settings.json
.Also check if your function code is valid and compatible with the Version V4.
I have created a .NET 4.8 Framework Http Triggered Azure Function code with version V4.
Function.cs:
Program.cs: