AZ-400: Designing and Implementing Microsoft DevOps Solutions
Design and Implement a Package Management Strategy
Implementing package feeds
In this guide, you’ll learn how to set up, configure, and manage package feeds in Azure DevOps. By following these steps, you'll gain the knowledge required to efficiently integrate package feeds into your development projects.
Creating a Package Feed in Azure DevOps
To create a new package feed, follow these steps:
- Open your Azure DevOps project—in this example, we’re using a project called "Simple Converter."
- On the left-hand side, click on Artifacts.
- Although there is an option to connect to an existing feed, click Create a Feed at the top to establish a new feed.
When prompted, provide a name for your feed. For this example, we use My Project Feed. You can configure the feed’s visibility, choosing to share it with all members of your Azure DevOps organization (KodeKloud Demo) or with specific users only. You may also set upstream sources to include packages from repositories such as NuGet, npmjs.com, etc., and determine the scope (project or entire organization). Once you have configured these settings, click Create.
Exploring Feed Settings
After creating your feed, select My Project Feed from the dropdown and click the gear icon to access the feed settings. One useful feature is the option to hide deleted package versions. If a previous version is deleted, it is hidden from view, yet the version number remains reserved to prevent breaking changes in dependent projects.
Additional settings allow you to expose the latest package version on your wiki or project homepage and to set up retention policies to automatically delete old or infrequently downloaded packages.
Configuring Permissions
Managing access to your package feed is straightforward. To configure permissions:
- Navigate to the Permissions tab.
- Click Add Users and Groups to add a contributor.
- For example, add a user named Lloyd Christmas. Assign the appropriate role—such as contributor, which allows publishing and consuming packages, feed owner, or publisher—based on the level of access required.
Note
Ensure that you only grant the minimum required permissions to maintain security and control over your feeds.
Configuring Upstream Sources
Upstream sources help optimize build performance by managing external dependencies. To configure these:
- Visit the Upstream Sources tab to view a list of public package repositories, such as NuGet Gallery, crates.io, and Maven Central.
- You can also add your own upstream sources from either public sources or another Azure Artifacts feed.
- To add an upstream source, click the designated option and choose from the dialog box that appears, which offers the choice between a public source and an Azure Artifacts feed.
Publishing a NuGet Package to the Feed
After setting up your feed, you can publish a NuGet package. This section demonstrates how to create and publish a simple NuGet package from a basic C# class library that is intended to be reused across multiple projects.
- Save your project and right-click on the package to select Pack.
- Ensure the build is successful. You will see your NuGet package is created with a version number, such as 1.0.0.
Below is the sample code for a simple C# class library:
using System;
namespace Kalculator
{
public class AddKalculator
{
public int Add(int x, int y)
{
return x + y;
}
}
}
Once the package is built, open Visual Studio and click Connect to Feed. Follow the instructions to configure the package source by navigating to Tools > Options > NuGet Package Manager > Package Sources. You might already see NuGet.org and GitHub listed. Click the green plus icon, name the new package source My Project Feed, paste the URL provided by Azure DevOps, and click Update.
Next, push your NuGet package to your Azure DevOps project. One efficient method is to use the Azure CLI. First, log in to Azure DevOps using the CLI and provide your personal access token when prompted. Then, execute the following commands:
az devops login --organization https://dev.azure.com/KodeKloudDemo/
az artifacts universal download \
--organization https://dev.azure.com/KodeKloudDemo/ \
--project "SimpleConverter" \
--scope project \
--name my-first-package \
--version 0.1 \
--path .
az artifacts universal publish \
--organization https://dev.azure.com/KodeKloudDemo/ \
--project "SimpleConverter" \
--scope project \
--name my-first-package \
--version 0.1 \
--description "Welcome to Universal Packages"
The CLI tool will download any required tooling if not already installed and then confirm that your package has been published successfully.
Verifying the Published Package
To verify the successful publication of your package:
- Return to the Artifacts section in Azure DevOps.
- Confirm that your universal package, my-first-package with version 0.0.1, appears on the feed.
This interface also provides detailed instructions for connecting to the feed using .NET, NuGet, Visual Studio, and other tools.
Conclusion
In this article, we covered how to:
- Set up package feeds in Azure DevOps.
- Configure feed settings and manage permissions.
- Establish upstream sources.
- Publish a simple NuGet package using the Azure CLI.
Final Thoughts
Package feeds in Azure DevOps are an excellent solution for managing custom software components across multiple projects while ensuring they remain secure and private within your organization.
Happy packaging!
Watch Video
Watch video content