How to Set up a Private Nuget Feed With Azure or Any Service Provider

A new way to set up a NuGet feed with Azure, Docker or any service provider.

If you read our previous post, How to Setup a Private NuGet Feed in Azure DevOps Pipelines, you’re probably wondering why we’d release more info on this topic.

After all, “if it aint broke, don’t fix it”, right? 

How to Setup a Private NuGet Feed in Azure DevOps Pipelines process is still a great way to set up a NuGet feed; the slight difference with this method is that it’ll help you authenticate to an external or internal Azure DevOps NuGet feed using a script.

Using a script, you can save it to your repository, enabling you to authenticate the DevOps feed in a standardised way.

Plus, this post will guide you through the latest setup recommendations for Docker and other service providers. 


How to setup a private NuGet feed with Azure DevOps

Step 1 - Before you start, generate a PAT (personal access token)  token; find out how to generate a PAT with Azure here. 

Step 2 -  Install Credentials Provider

You need to install your relevant Azure DevOps credit providers:
For PowerShell users 
For Bash users 

Step 3 - Add your private NuGet feed to the NuGet.config file like this:
 - Azure DevOps:

<?xml version="1.0" encoding="utf-8"?>
        <add key="" value="" protocolVersion="3" />
        <add key="private_feed" value="your_private_nuget_feed_url" />

Step 4 -
Export to the environment variable
Use your private NuGet feed URL as shown below:

VSS_NUGET_EXTERNAL_FEED_ENDPOINTS={"endpointCredentials": [{"endpoint":"[your_private_nuget_feed_url]", "username":"[user]", "password":"[PAT]"}]}

And that’s it! You can now work in the external feed based on the PAT (Personal Access Token) you’ve already generated. 

How to Setup A Private NuGet feed using Docker 

Step 1 - Here's how to set up a Dockerfile (docker build process) access to an external feed on Azure DevOps.

FROM AS build-env
WORKDIR /source
# Private NuGet Artefact steps
# Install NuGet Credentials manager
RUN wget \
    && chmod +x \
    && ./

ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS "{\"endpointCredentials\": [{\"endpoint\": \"[your_private_nuget_feed_url]\",\"username\": \"CI Build\",\"password\": \"${NUGET_PAT}\"}]}"

# Copy all files
COPY . .
# Restore NuGet dependencies
RUN dotnet restore

And that’s all you need to do. You should now be able to authorise the external NuGet feed using Docker!


How to Setup a Private NuGet feed with any service provider. 

This method uses dotnet nuget CLI to create a source with your chosen PAT token.

Step 1-  Generate your PAT (Personal Access Token) using your chosen service provider.

For both automatic and manual, you’ll need first to create PAT.

We’ve included PAT generation instructions for the leading providers below, GitHub and MyGet, but you can use anything you like.

GitHub PAT instructions
MyGet PAT instructions 
Azure DevOps PAT instructions 

The automatic (CLI) way:

Using this method, you can add your provider, GitHub or MyGet.
dotnet nuget add source [your_private_nuget_feed_url] --name PRIVATE_SOURCE_NAME --username BUILD_CI --password BASE64_PAT --store-password-in-clear-text --configfile NuGet.config


The manual way (NuGet.config):

For manually adding new source with PAT token. 

<?xml version="1.0" encoding="utf-8"?>
    <clear />
    <add key="private_feed" value="[your_private_nuget_feed_url]" />
      <add key="Username" value="BUILD CI" />
      <add key="Password" value="[BASE64_PAT]" />
      <add key="ValidAuthenticationTypes" value="basic" />


That's it!

We’re always keen to know if there are any developer tutorials you’d like to read. Let us know in the comments below or on social media.

Interesting NuGet-related resources:

-Visual Studio Team Services Integration (MyGet)
-Use personal access token (PAT) as an alternate password to authenticate into Azure DevOps (Microsoft)

  • Image for Why you should use Modular Monoliths with Umbraco Build

    Why you should use Modular Monoliths with Umbraco

  • Image for 5 Tips to Keep Your Zoom Call Secure Strategy

    5 Tips to Keep Your Zoom Call Secure

  • Image for Keeping Up With Digital Transformation Build

    Keeping Up With Digital Transformation

  • Image for Website Security Checklist: The 4 Basics Build

    Website Security Checklist: The 4 Basics

Ready to collaborate ?

Get in touch to see how we can transform your digital presence.

Send us a message