Connect to Azure Artifacts feeds (NuGet.exe)
Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019
Azure Artifacts enables developers to publish and download NuGet packages from various sources, including feeds and public registries. You can use private Azure Artifacts feeds to share packages privately with your team or specific users. Additionally, you can create public feeds to make packages publicly accessible, allowing you to share them openly with anyone on the internet. This article will guide you through connecting to your Azure Artifacts feed.
Prerequisites
An Azure DevOps organization and a project. Create an organization or a project if you haven't already.
An Azure Artifacts feed. Create a new feed if you don't have one already.
Install the latest NuGet version.
Install the Azure Artifacts Credential Provider.
Project setup
Sign in to your Azure DevOps organization, and then navigate to your project.
Select Artifacts, and then select your feed from the dropdown menu.
Select Connect to feed, and then select NuGet.exe from the left panel.
If this is your first time using Azure Artifacts with NuGet.exe, make sure you've installed the prerequisites, otherwise select Get the tools in the top-right corner to install them.
Add a nuget.config file to your project, place it in the same folder as your csproj or sln file, and then paste the provided snippet into it. The snippet should be structured like this:
Project-scoped feed:
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <clear /> <add key="<SOURCE_NAME>" value="https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json" /> </packageSources> </configuration>
Organization-scoped feed:
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <clear /> <add key="<SOURCE_NAME>" value="https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json" /> </packageSources> </configuration>
Sign in to your Azure DevOps server, and then navigate to your project.
Select Artifacts, and then select your feed from the dropdown menu.
Select Connect to Feed, and then select NuGet.exe from the left navigation pane.
Follow the instructions in the Project setup section to connect to your feed.
Sign in to your Azure DevOps server, and then navigate to your project.
Select Artifacts, and then select your feed.
Select Connect to Feed, and then select NuGet from the left navigation pane.
Follow the provided instructions to add your package source URL to your nuget.config file.
Important
The Azure Artifacts Credential Provider requires NuGet 4.8.0.5385
or higher.
For optimal performance, Azure Artifacts recommends using NuGet version 5.5.x
or later as it includes crucial bug fixes related to cancellations and timeouts.
Legacy project setup
If you're using an older version of NuGet, follow the instructions below to connect to your feed:
Sign in to your Azure DevOps organization, and then navigate to your project.
Select Artifacts and then select your feed from the dropdown menu.
Select Connect to feed, and then select NuGet.exe from the left panel.
Copy your source URL, and then replace
/v3/index.json
with/v2
. Your updated source URL should resemble the following:Project-scoped feed:
https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/nuget/v2
Organization-scoped feed:
https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/_packaging/<FEED_NAME>/nuget/v2
Create a Personal Access Token, and make sure you scope it to the right organization you want to access and select one of the following scopes: Packaging (read), Packaging (read and write), or Packaging (read, write, and manage).
Run the following command in a command prompt window to add your feed source to your nuget.config file:
nuget sources add -name <FEED_NAME> -source <SOURCE_URL> -username <ANY_STRING_BUT_NOT_NULL> -password <YOUR_PERSONAL_ACCESS_TOKEN>
If your organization is connected to Microsoft Entra ID, you must first authenticate with your AD credentials and then add your personal access token using the setapikey command:
nuget sources add -name <FEED_NAME> -source <SOURCE_URL> -username <AZURE_ACTIVE_DIRECTORY_USERNAME> -password <AZURE_ACTIVE_DIRECTORY_PASSWORD> nuget setapikey <YOUR_PERSONAL_ACCESS_TOKEN> -source <SOURCE_URL>
Authenticate NuGet Feed with Service Principal
To authenticate with a service principal, you must first install the Artifacts Credential Provider.
Set the ARTIFACTS_CREDENTIALPROVIDER_FEED_ENDPOINTS environment variable as shown below, specifying your feed URL, the service principal's application (client) ID, and the subject name or the file path of your service principal certificate. (Only one is needed between the certificate subject name or file path.)
In PowerShell, enter the following code.
$env:ARTIFACTS_CREDENTIALPROVIDER_FEED_ENDPOINTS = @'{
"endpointCredentials": [
{
"endpoint": "<FEED_URL>",
"clientId": "<SERVICE_PRINCIPAL_APPLICATION_(CLIENT)_ID>",
"clientCertificateSubjectName": "<SERVICE_PRINCIPAL_CERTIFICATE_NAME>",
"clientCertificateFilePath": "<SERVICE_PRINCIPAL_CERTIFICATE_PATH>"
}
]
}
'@