I have created a new Azure function in the portal, and wanted to use the WindowsAzure.Storage
NuGet package. Given that the default template is created with:
#r "Newtonsoft.Json"
I thought I could do this:
#r "WindowsAzure.Storage"
However, when I do, I get the error:
[Error] run.csx(2,1): error CS0006: Metadata file 'WindowsAzure.Storage' could not be found
I can't see anywhere else that Newtonsoft.Json
is being referenced.
How can I include this NuGet package in my function (without building this is VS or VS Code and deploying it). Also, what, exactly does the #r
directive do, if not bring in external libraries and packages?
Ok so everytime i create a Function app i mostly use VS Code or Visual Studio just for the intellisense and easiness of work. To add a nuget from the Azure portal
View Files
and add a function.proj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3"/>
</ItemGroup>
</Project>
upon saving this you should see the console update stating that the packages are getting installed. This really isn't well documented in the microsoft docs
There is correction in namespace
#r "Microsoft.WindowsAzure.Storage"
and not #r "WindowsAzure.Storage"
You can refer - https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp#binding-to-arguments
Try with #r "Microsoft.WindowsAzure.Storage"
You can also upload a custom dll into the function app by Kudu tools. And then you can refer the dll by #r "path to dll"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.