Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

Azure Artifacts Tutorial

Introduction to Azure Artifacts

Azure Artifacts is a service within Azure DevOps that allows you to create, host, and share packages with your team. It supports multiple package types such as NuGet, npm, Maven, Python, and Universal Packages. This tutorial will guide you through the process of using Azure Artifacts from start to finish.

Prerequisites

Before you start using Azure Artifacts, ensure you have the following:

  • An Azure DevOps organization
  • Basic knowledge of package management
  • Installed Azure CLI (for some operations)

Creating a Feed

A feed is a container for your packages. Follow these steps to create a feed in Azure Artifacts:

  1. Navigate to your Azure DevOps organization.
  2. Click on "Artifacts" in the left-hand menu.
  3. Click the "+ New feed" button.
  4. Provide a name and description for your feed.
  5. Set the visibility and scope as needed.
  6. Click "Create".

Example:

az artifacts feed create --name MyFeed --project MyProject

Publishing Packages

Once you have a feed, you can publish packages to it. The process varies depending on the package type. Here, we'll go through an example of publishing a npm package:

  1. Configure npm to use your Azure Artifacts feed:
  2. npm config set registry
  3. Login to your Azure Artifacts feed:
  4. npm login --registry
  5. Publish your package:
  6. npm publish

Example:

npm config set registry https://pkgs.dev.azure.com/YourOrg/_packaging/YourFeed/npm/registry/
npm login --registry https://pkgs.dev.azure.com/YourOrg/_packaging/YourFeed/npm/registry/
npm publish

Consuming Packages

To consume packages from your Azure Artifacts feed, you'll need to configure your package manager to use the feed. Here’s an example for npm:

  1. Configure npm to use your Azure Artifacts feed:
  2. npm config set registry
  3. Install the package:
  4. npm install <package-name>

Example:

npm config set registry https://pkgs.dev.azure.com/YourOrg/_packaging/YourFeed/npm/registry/
npm install your-package

Managing Permissions

You can control who has access to your feed and what they can do. Follow these steps to manage permissions:

  1. Navigate to your feed in Azure Artifacts.
  2. Click on "Permissions".
  3. Add users or groups and set their permissions.
  4. Click "Save".

Cleaning Up

Over time, your feed may accumulate old or unused packages. Azure Artifacts offers tools to help you clean up:

  1. Navigate to your feed in Azure Artifacts.
  2. Click on "Recycle Bin".
  3. Select the packages you want to delete permanently.
  4. Click "Delete".

Conclusion

Azure Artifacts is a powerful tool for managing and sharing packages within your team. By following this tutorial, you should now be able to create feeds, publish and consume packages, manage permissions, and clean up old packages. Happy coding!