Azure Artifacts is the new name for VSTS Package Management. It’s a “one stop shop” for storing NuGet, npm, Maven, Gradle and “Universal” packages.

I’d previously been using another private npm registry server and wanted to shift over to using the Azure Artifacts npm registry instead. As part of this move, I needed to somehow grab the packages that were currently stored in the old registry and then re-publish them to the Artifacts one. Here’s how I did it. Artifacts do support configuring ‘upstream’ sources, but that’s not really a long term solution for migration.

Downloading packages

npm pack “@myscope/mypackage@^1.2.3456” –registry http://my.oldnpmserver

You’ll now have a file with a name similar to myscope-mypackage-1.2.3456.tgz

Repeat this for all the packages you need.

Re-publishing packages

First off, create a new file named .npmrc and enter in the details for your Artifacts registry url. If you have packages with scopes (like I did above), then add in those as well.

@myscope:registry=https://myorg.pkgs.visualstudio.com/_packaging/MyArtifacts/npm/registry/ registry=https://myorg.pkgs.visualstudio.com/_packaging/MyArtifacts/npm/registry/

always-auth=true

Azure Artifacts are password-protected, so you’ll need to authenticate. Your options here are to either make use of the vsts-npm-auth tool or generate credentials that can be pasted into the .npmrc file. Click on the Connect to Feed button from the Azure Artifacts page in the DevOps portal to find out the details.

Now use npm publish to push all the .tgz files up to the Artifacts repository (with a bit of help from PowerShell)

Get-ChildItem *.tgz | ForEach-Object { npm publish $_ }