🔥 Checkout our new Azure Developer page at azure.com/developer.
📺 Watch the video : How to create, host, and share packages with Azure Artifacts.
💡 Learn more : Azure Artifacts Documentation
You probably use lots of packages in your applications. And you should, as there is lots of functionality available. You can use packages from a lot of sources, like NuGet, npm, Maven and more. But what if your team creates packages that you only want to use internally in your organization? Where do you host them securely and how do you share them? Azure Artifacts provides this capability. Azure Artifacts is a package feed that is part of Azure DevOps. It allows you to host packages that you create and secure them for your organization. Let's take a look at how to create a package, host that on Azure Artifacts and use it in an application.
In order to host packages, we need to create a feed to host them on. We do that in the Azure DevOps portal.
(Create a new Azure Artifacts feed)
(Select the details for the feed)
(Add the feed to the NuGet configuration)
That's it! We now have a feed that we can use to host packages on.
Now that we have the feed, we can start putting packages on it. We'll do that using Visual Studio. In Visual Studio, I've created a console application (ConsoleApp1) and a .NET Standard library (MyFirstPackage). In the library, I've added a simple class that has a method that returns a string. We'll create a NuGet package from the library and publish that to our Azure Artifacts feed.
(Create a NuGet package in Visual Studio)
nuget.exe push -Source "https://pkgs.dev.azure.com/azuretandt/_packaging/mypackages/nuget/v3/index.json" -ApiKey key "C:\Users\Michael\source\repos\ConsoleApp1\ClassLibrary1\bin\Debug\MyFirstPackage.2.3.0.nupkg"
Make sure that you replace the URL of your feed and the path to your package file. The command might ask you to log in again and it will push the package to your feed.
You can leave the ApiKey value to an arbitrary value, like "key". This parameter is needed because we're using nuget.exe. When you push a package to nuget.org, this value needs to have an actual key value in it.
(Publish the package to the Azure Artifacts feed)
We now have a private package feed with a package on it that we've created ourselves. Now, we can use the feed and the package on it.
(Use the package from our private feed)
Azure Artifacts is a great way to host and share your packages with. You can build a big library of things that you use regularly in you organization and share them amongst your teams. The first 5 users can use Azure Artifacts for free. Additional users have to purchase Azure Artifacts licenses to access the feeds and publish packages on them. Go and check it out!