How to refer nuget package in Azure Function v2.x


Ahamed Fazil Buhari
Senior Developer
Published On :   15 Dec 2018
Visit Count
Today :  2    Total :   174


Hello everyone,

In this article we will see how to refer nuget package in your azure function v2.x. Please make sure that your Azure function is version 2, because nuget package is referred differently in version 1 please refer my other article for v1.x - How to refer nuget package in Azure Function v1.x. To check your current azure function version, please follow the below step.

Go to Azure Portal (https://portal.azure.com/ ) -> open Function App, under Overview or Platform features tab there will be link Function app settings

clip_image002

clip_image004

In my function app, I’ve already created a simple HttpTrigger function as you can see from below screenshot

clip_image006

Now, I want to add the following nuget package - https://www.nuget.org/packages/SharePointPnPCoreOnline/ to my azure function, to do that we need to create a File called function.proj (but in v1.x this file name should be project.json) clip_image008

paste the below XML in newly created function.proj file

 <Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
   </PropertyGroup> 
   <ItemGroup>
     <PackageReference Include="SharePointPnPCoreOnline" Version="3.2.1810"/>
   </ItemGroup> 
 </Project>
 


And click on Save, if you need more than one nuget package to be installed, then please add another <PackageReference Include="package-name " Version="version-num"/>

inside <ItemGroup> tag.

clip_image010

Once it’s saved, you can see from the log that the package is getting installed

clip_image012

After installation is over (it takes few seconds based on size of the package), I just referred Microsoft.SharePoint.Client dll to check and it worked.

clip_image014

Happy Coding

Ahamed

Categories