Azure Timer trigger function Error after deployed in Azure Portal

Reddy 25 Reputation points
2024-10-15T17:00:48.57+00:00

Hello,
I am new to this azure functions and I recently developed an azure Timer trigger function in .NET 8 Isolated and it is running successfully in local and deployed it in the Azure portal through CI/CD pipeline. It never ran successfully because of some missing assemblies. I have tried updating all my nuget packages to latest but still no luck. Please find the below error. In my function I haven't used this assembly. I have got this error from the azure function invocations in portal. Any help would be appreciated.

Result: Failure Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Memory.Data, Version=1.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. File name: 'System.Memory.Data, Version=1.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' at Microsoft.Azure.Functions.Worker.Grpc.Features.GrpcFunctionBindingsFeature.ConvertTypedData(TypedData typedData, FunctionContext context) at System.Linq.Enumerable.ToDictionaryTSource,TKey,TElement at Microsoft.Azure.Functions.Worker.Grpc.Features.GrpcFunctionBindingsFeature.get_InputData() in D:\a_work\1\s\src\DotNetWorker.Grpc\Features\GrpcFunctionBindingsFeature.cs:line 52

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Vinodh247 34,661 Reputation points MVP Volunteer Moderator
    2024-10-16T06:06:46.99+00:00

    Hi Reddy,

    Thanks for reaching out to Microsoft Q&A.

    The error is related to a missing assembly (System.Memory.Data) that is required by the Azure Functions runtime when running in the cloud, but not necessarily when running locally. This kind of issue typically arises when there are discrepancies between the environment where the function is running locally and the one on Azure.

    Here are a few steps you can take to resolve the issue:

    1. Check Azure Functions Dependencies: Ensure that all required NuGet packages are properly restored and included in the published output. Sometimes, missing or outdated package versions cause issues in cloud environments but not locally. In your csproj file, make sure that the dependencies include the correct version of the required packages. You can also add the package System.Memory.Data explicitly if it isn't already there:

      <PackageReference Include="System.Memory.Data" Version="1.0.2" />

    2. Self-contained Deployment: .NET isolated functions can sometimes miss assemblies if they rely on certain dependencies being present in the runtime. You can try deploying the function as a self-contained deployment, which bundles all necessary dependencies, including any third-party packages, in the function app package. In your .csproj file, include:

      <PropertyGroup> <PublishSingleFile>true</PublishSingleFile> <RuntimeIdentifier>win-x64</RuntimeIdentifier> <!-- or linux-x64, based on your environment --> </PropertyGroup>

    3. Functions Runtime Version: Ensure that the Azure Functions runtime in your Azure environment is compatible with .NET 8 Isolated. While .NET 8 is relatively new, make sure the runtime in Azure is updated to the latest version that supports .NET 8.
    4. Check for Conflicting NuGet Packages: Sometimes, different packages may have conflicting versions of the same dependency. You can try clearing the NuGet cache (dotnet nuget locals all -clear), then updating all packages again. Use: 'dotnet restore' command & make sure to explicitly set versions of dependencies in your csproj to avoid mismatches.
    5. Assembly Binding Redirects: Though this is less common in isolated functions, check if adding an assembly binding redirect in your appsettings.json helps resolve the issue by forcing the function to use the correct version of System.Memory.Data.
    6. Logging and Diagnostic: Enable more detailed logging for your function app in the Azure portal. You can do this by increasing the log level in host.json:

      { "logging": { "logLevel": { "default": "Debug", "Host.Startup": "Information" } } }

    This should provide more context on why the assembly is missing and help narrow down the cause of the failure.

    Please 'Upvote'(Thumbs-up) and 'Accept' as an answer if the reply was helpful. This will benefit other community members who face the same issue.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.