Migration of Maven and NPM packages in Artifactory to Azure Artifacts

Copper Contributor

We currently have an onsite GitLab server and JFrog Artifactory server and we're in the process of moving everything to Azure DevOps.  We are trying to figure out how to move all the existing Maven and NPM packages to azure Artifacts.  I've seen the "how to migrate nuget packages", but that won't work for us.  Does anyone have any suggestions that would work?





1 Reply

It's been a while since you asked this question. I wonder if you worked around this problem?
This had me stumped for a long time. I even gave up and concluded MS does not support migration from another product!


But it seems this a case of the wrong question to the right problem.
The right question is “how do I publish external libraries to Azure Artifacts” - if you can do that, you can upload any artifact.


I found a solution to the Artifactory part of your problem.

The steps below transfer artifacts via your local .m2 repository, so you’ll need a working development environment (Maven installed, project checked out, etc).


1. Get your pom connected to both your existing repository manager and Azure Artifacts.

Your pom should already have your existing repository manager in the repositories section.
If you don't have a connection to Azure Artifacts ....

  1. Add a connection to Azure Artifacts in the distribution management.

    1. Go to your DevOps project

    2. Open Artifacts and select the feed

    3. Click the button “Connect to Feed”

    4. Select “Maven”

    5. Follow the instructions:

  2. The instructions in DevOps miss out a key step.
    Maven needs Azure’s SSL certificate to make the https connection.
    Follow these instructions to download the .crt file from Azure and import into Java’s keystore so that Maven can use it.


The repositories and distributionManagement sections of your pom should look something like this:


If you have an entry for Azure Artifacts in the repositories section, there's no need to remove it. I've not shown it here because it's not necessary for migration.



2. Download artifacts from your existing repository manager to your local .m2/repository folder.

Run the following command in your project’s root folder, changing the group id and artifact id to match your project:


mvn dependency:get -DgroupId='com.my_company' -DartifactId='my_project' -Dversion='0.1'


You’ll need to cycle through all the version numbers.
I used a macro in a text editor to generate a list of commands, or you could use a sh/bat script.


3. Upload these artifacts to Azure Artifacts.

Run the following command in your project’s root folder, setting your own repository id, url, group id, artifact id and the path to your local .m2 folder:


mvn org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file -Dpackaging=jar -DrepositoryId='my_project' -Durl=https://pkgs.dev.azure.com/my_company/my_project/_packaging/my_project/maven/v1 -DgroupId='com.pd4ml.utilities' -DartifactId='pd4ml' -Dversion='1.0' -Dfile=C:\Users\StephenBattey\.m2\repository\com\pd4ml\utilities\pd4ml\1.0\pd4ml-1.0.jar -DpomFile=C:\Users\StephenBattey\.m2\repository\com\pd4ml\utilities\pd4ml\1.0\pd4ml-1.0.pom


Again, you’ll need to cycle through all the version numbers.



When this is done you’ll see just one(!) artifact in your feed in Azure. Don’t panic, Azure shows only the latest version for each package.
If you click the name of the package and then navigate to “Versions” you’ll see all the versions of this artifact.



I hope this helps others who are looking to migrate artifacts.

I didn't have any npm packages to migrate, but maybe this answer gives an idea of how that can be done.