1
votes

Getting the below error while running the Azure Function:

Could not load file or assembly 'Microsoft.Azure.KeyVault, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Thanks, Shrikant

1
Which version of Azure-Function are you using?Kzrystof

1 Answers

0
votes

The error you gave can happen for multiple reason, but without more information, the most likely case is that the code you wrote for your Azure Function depends on Microsoft.Azure.KeyVault. This is not one of our included default dependencies, so you need to explicitly include this assembly as a dependency. How to do this depends whether you are using pre-compiled C#, or a C# script (.csx).

Pre-compiled

In the pre-compiled case with Visual Studio, just including the reference as part of the .csproj file for your library should be sufficient to get rid of this error.

C# script (.csx)

In .csx files, you need to load in external .dll files using the #r notation. You can read more about what assemblies are included by default here. For assemblies not included by default, you would need to do the following:

  1. Include a project.json file in your function's folder in the application's file system that looks like:

{ "frameworks": { "net46":{ "dependencies": { "Microsoft.Azure.KeyVault": "1.1.0" } } } }

  1. Include #r "Microsoft.Azure.KeyVault" at the top of your .csx file.