Edit

Share via


Tutorial: How to restore packages from upstream sources

Azure DevOps Services | Azure DevOps Server 2022 | Azure DevOps Server 2020

Using upstream sources in Azure Artifacts enables you to manage all your application dependencies from a single feed. It simplifies consuming packages from public registries like NuGet.org or npmjs.com, while also providing protection against outages or compromised packages. You can also publish your own packages to the same feed and manage all your dependencies in one location.

This tutorial walks you through enabling upstream sources in your feed and consuming packages from public registries such as NuGet.org or npmjs.com.

Prerequisites

Product Requirements
Azure DevOps - An Azure DevOps organization.
- An Azure DevOps project.
- Allow Azure Artifacts Domain URLs and IP addresses if your organization is using a firewall or a proxy server.

Create a feed and enable upstream sources

  1. Sign in to your Azure DevOps organization, and then navigate to your project.

  2. Select Artifacts, and then select Create Feed to create a new feed.

  3. Provide a Name for your feed, choose its Visibility and Scope, and make sure you check the Include packages from common public sources checkbox to enable upstream sources.

  4. Select Create when you're done.

    a Screenshot displaying how to create a new feed and enable upstream sources in Azure Artifacts.

Important

To add a feed from a different organization as an upstream source, the target feed owner must share the target view with All feeds and people in organizations associated with my Microsoft Entra tenant by navigating to Feed Settings > Views > Select the ellipsis button on the right for the specified view > Edit .

Authenticate with the feed

Now that you've created your feed, select the appropriate tab based on the technology you're using and follow the instructions to set up your configuration file and connect to your feed:

  1. Sign in to your Azure DevOps organization, and then navigate to your project.

  2. Select Artifacts, select your feed from the dropdown menu, and then select Connect to feed.

  3. Select npm from the left navigation pane, and follow the provided instructions in the Project setup section to set up your config file. If you don’t already have a .npmrc file, create a new one in the root of your project (the same folder as your package.json). Open your new .npmrc file and paste in the provided snippet.

    A screenshot displaying how to set up your npm project in Azure Artifacts.

Restore packages

Now that you've enabled upstream sources and authenticated with your feed, select the appropriate tab based on your package type, and follow the instructions to restore packages from public registries into your Azure Artifacts feed.

  1. Remove the node_modules folder from your project.

  2. Open a command prompt window and run the following command to restore your packages. Once completed, your feed should have a saved copy of any packages installed from upstream.

    npm install --force
    

Note

The --force flag ensures that packages are pulled from the remote source even if a local copy exists.

  1. Remove the node_modules folder from your project.

  2. Open a command prompt window and run the following command to restore your packages. Once completed, your feed should have a saved copy of any packages installed from upstream.

    npm install --force
    

Note

The --force flag ensures that packages are pulled from the remote source even if a local copy exists.