1
votes

I am currently working with a Azure Function created in visual studio. It is a timer function that calls some common code to write to a queue.

Running the code locally does not cause any issues. Runs just fine but when publish it I get the following error:

Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=9.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.||System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=9.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.WindowsAzure.Storage, Version=9.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at Esperanto.Core.Function.JobGetterLogic.SendJobsToQue() at JobGetter.TimedJob.Run(TimerInfo myTimer, TraceWriter log)

Here is my webjob code:

public static class TimedJob
{
    [FunctionName("TimedJob")]
    public static void Run([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, TraceWriter log)
    {
        log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
        try
        {
            var brain = new CoreLogic.Function.JobGetterLogic();
            var result = brain.SendJobsToQue();
        }
        catch (Exception e)
        {
            log.Info(e.Message + "||" + e.ToString());
        }

    }
}
2
The system cannot find the file specified , check for the dll and see if it exists in correct/desired directoryChristopher H.
@zackraiyan I have tried to add the nuget package for Azure Storage to the Function but it wont add it. I also read that azure storage is just part of the azure functions system.Dan

2 Answers

2
votes

Assuming you are on v1 of Azure Functions runtime (current production version), it uses WindowsAzure.Storage assembly of version 7.2.1. Since it's the runtime which controls which versions are loaded, your implementation has to comply and use the same version.

To fix the problem, change all your references to WindowsAzure.Storage (including transitive ones) to 7.2.1.

There's currently nothing like binding redirect supported by Azure Functions.

2
votes

Mine was because of the Newtonsoft.Json version, but I got that even before publishing while installing the WindowsAzure.Storage package.

It gave me this in the output:

NU1107: Version conflict detected for Newtonsoft.Json. Reference the package directly from the project to resolve this issue.
PMTool.AzureFunctions -> WindowsAzure.Storage 9.1.0 -> Newtonsoft.Json (>= 10.0.2) PMTool.AzureFunctions -> Microsoft.NET.Sdk.Functions 1.0.6 -> Newtonsoft.Json (= 9.0.1).

And then rolled back.

So the Newtonsoft.Json in the Functions SDK is version 9.0.1 but on azure storage it is 10.0.2.

And for sure if published like this it gives this error:

"Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=9.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."

Because the didn't get referenced at all.

This might not be your exact issue but it might give you a clue.