Azure Functions (Version 2) - Personal Nuget sources

A while back I wrote an article on how to use a personal nuget feed with Azure functions.

As a side note; I was pleasantly surprised to find that it features quite highly on Google search (more luck than judgement): google

Anyway, while that is all well and good, it doesn't work with Version 2 of the Azure Functions.

The V2 way

Like my previous research, there was very little documentation on this. I'd supect that most "serious" Azure Function work is being done in C# using Visual Studio or VS Code - very little is being done in the portal and CSX.

(I generally only using the portal and CSX for quick experiments)

So after much experimentation, I believe this is the way to do it;

Add a "function.proj" file similar to the below at the same level as your run.csx:

The file explained

The file itself is in MSBuild Proj format - which is the first major change from working with Azure Functions V1.

The second major change is that the file contains the nuget package AND the source. Previously the source was configured using nuget.config.

In this example, I use the RestoreSources to define the list of sources nuget should use. This list should be semicolon delimited. Obviously replace https://www.myget.org/F/red-folder/api/v3/index.json with your own feed.

I then add the packages to be loaded as a PackageReference - you would add one for each nuget package you want to import.

Then all you need to do is add the relevant "using" to your run.csx.

Once you know how, nice and easy.

Please let me know if this does/ doesn't work for you - seem good for me - but has been arrived at via experimentation.

Credits

Blog Header image by rawpixel.com from Pexels

About the author:

Mark Taylor is an experience IT Consultant passionate about helping his clients get better ROI from their Software Development.

He has over 20 years Software Development experience - over 15 of those leading teams. He has experience in a wide variety of technologies and holds certification in Microsoft Development and Scrum.

He operates through Red Folder Consultancy Ltd.