ערוך

שתף באמצעות


Tutorial: How to use upstream sources

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

Using upstream sources in your feed enables you to manage your application dependencies from a single feed. Using upstream sources makes it easy to consume packages from public registries while having 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 will walk you through how to enable upstream sources on your feed and consume packages from public registries such as NuGet.org or npmjs.com.

In this tutorial, you will:

  • Create a new feed and enable upstream sources.
  • Set up your configuration file.
  • Run an initial package restore to populate your feed.
  • Check your feed to view the saved copy of the packages you consumed from the public registry.

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.

    Screenshot showing the create feed button.

  3. Provide a name for your feed, and choose its visibility. Make sure you check the Include packages from common public sources checkbox to enable upstream sources, and then select Create when you're done.

    Screenshot showing the create a new feed window.

Note

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 .

Set up the configuration file

Now that we created our feed, we need to update the config file to point to our feed. To do this we must:

  1. Get the source's URL
  2. Update the configuration file
  1. Select Artifacts, and then select Connect to feed.

    Screenshot showing how to connect to a feed.

  2. On the left side of the page, select the npm tab.

  3. Follow the instructions in the Project setup section to set up your config file.

    Screenshot showing how to set up your project.

If you don't have a .npmrc file already, create a new one in the root of your project (in the same folder as your package.json). Open your new .npmrc file and paste the snippet you just copied in the previous step.

Restore packages

Now that you enabled upstream sources and set up your configuration file, we can run the package restore command to query the upstream source and retrieve the upstream packages.

Remove the node_modules folder from your project and run the following command in an elevated command prompt window:

npm install --force

Your feed now should have a saved copy of any packages you installed from upstream.

Note

The --force argument will force pull remotes even if a local copy exists.

Remove the node_modules folder from your project and run the following command in an elevated command prompt window:

npm install --force

Your feed now should have a saved copy of any packages you installed from upstream.

Note

The --force argument will force pull remotes even if a local copy exists.

Remove the node_modules folder from your project and run the following command in an elevated command prompt window:

npm install --force

Your feed now should have a saved copy of any packages you installed from upstream.

Note

The --force argument will force pull remotes even if a local copy exists.