How to refer nuget package in Azure Function v1.x

Ahamed Fazil Buhari
 
Senior Developer
November 13, 2018
 
Rate this article
[Total: 0    Average: 0/5]
 
Views
1542

Hello everyone,

In this article we will see how to refer nuget package in Azure Function version 1.x. Please make sure that your Azure function is version 1, because nuget package is referenced in different way in version 2. 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 Under Runtime version

clip_image002

clip_image004

Adding NuGet package from Azure Portal:

Here we’re adding nuget package to azure function from azure portal. To achieve this, create a file called project.json in your azure function and paste the following json value, inside dependencies, specify the nuget package name and its version

{

“frameworks”: {

“net46”:{

“dependencies”: {

“SharePointPnPCoreOnline”: “2.24.1803”

}

}

}

}

For example, I’ve added SharePointPnPCoreOnline nuget package with the version 2.24.1803 and save the project.json file

clip_image006

After click on save, we can see from the logs that it will start installing all dependencies,

clip_image007

It will take few seconds based on the size of the nuget package,

clip_image008

And to utilize nuget package no need to use #r in the code, we can directly start using. Well in this example, I am not doing anything further other than referring nuget package, so I just utilized ClientContext class from Microsoft.SharePoint.Client dll to show it got referred without issue. Thank you for reading

clip_image010

Adding Nuget package from Visual Studio

If an azure function is created from Visual Studio (Create And Debug Azure Function Using Visual Studio 2017 – Part 1) then it’s very easy to add Nuget package, just like how we add reference in other project in VS

clip_image011

Once the project is published, all the dependencies will be added to bin folder.

clip_image013

 

Happy Coding

Ahamed

Category : ADFS, Function APP

Author Info

Ahamed Fazil Buhari
 
Senior Developer
 
Rate this article
[Total: 0    Average: 0/5]
 
Ahamed is a Senior Developer and he has very good experience in the field of Microsoft Technologies, especially SharePoint 2013, 2016 and O365, Azure, ASP.NET, SQL Server, IIS and client ...read more
 

Leave a comment