Bird
Raised Fist0
Azurecloud~5 mins

Azure Artifacts for packages - Commands & Configuration

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Azure Artifacts helps you store and share code packages like libraries or tools in one place. It solves the problem of managing and distributing these packages safely across your team or projects.
When you want to share reusable code libraries between different projects in your team.
When you need a private place to store packages that only your organization can access.
When you want to control which versions of packages your projects use to avoid errors.
When you want to automate package publishing and consumption in your build pipelines.
When you want to use popular public packages but cache them privately for faster builds.
Config File - nuget.config
nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="AzureArtifacts" value="https://pkgs.dev.azure.com/example-org/_packaging/example-feed/nuget/v3/index.json" />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

This nuget.config file tells your project where to find packages. The AzureArtifacts source points to your private feed in Azure Artifacts, and nuget.org is the public package source. This setup lets you use both private and public packages seamlessly.

Commands
This command creates a new package feed named 'example-feed' in your Azure DevOps project. A feed is where your packages will be stored and shared.
Terminal
az artifacts feed create --name example-feed --project example-project --organization https://dev.azure.com/example-org
Expected OutputExpected
{ "name": "example-feed", "project": { "id": "12345678-1234-1234-1234-123456789abc", "name": "example-project" }, "url": "https://pkgs.dev.azure.com/example-org/_packaging/example-feed/nuget/v3/index.json" }
→
--name - Sets the name of the new feed
→
--project - Specifies the Azure DevOps project
→
--organization - Specifies the Azure DevOps organization URL
This command uploads your package files from the local folder './package-folder' to the 'example-feed' in Azure Artifacts with the name 'my-package' and version '1.0.0'.
Terminal
az artifacts universal publish --organization https://dev.azure.com/example-org --feed example-feed --name my-package --version 1.0.0 --path ./package-folder
Expected OutputExpected
Uploading package 'my-package' version '1.0.0' to feed 'example-feed'... Upload completed successfully.
→
--feed - Specifies the target feed for the package
→
--name - Sets the package name
→
--version - Sets the package version
This command restores all packages for your project using the sources defined in 'nuget.config', including your Azure Artifacts feed.
Terminal
nuget restore -ConfigFile nuget.config
Expected OutputExpected
Restoring packages for project... All packages restored successfully.
→
-ConfigFile - Specifies the NuGet configuration file to use
This command downloads the package 'my-package' version '1.0.0' from the 'example-feed' into the local folder './downloaded-package'.
Terminal
az artifacts universal download --organization https://dev.azure.com/example-org --feed example-feed --name my-package --version 1.0.0 --path ./downloaded-package
Expected OutputExpected
Downloading package 'my-package' version '1.0.0' from feed 'example-feed'... Download completed successfully.
→
--feed - Specifies the feed to download from
→
--name - Specifies the package name
→
--version - Specifies the package version
Key Concept

If you remember nothing else from this pattern, remember: Azure Artifacts lets you safely store and share code packages in private feeds that your projects can easily access.

Common Mistakes
Not configuring the package source URL correctly in nuget.config
Your project won't find the private packages and will fail to restore them.
Add the exact Azure Artifacts feed URL to nuget.config under <packageSources>.
Trying to publish packages without proper permissions or authentication
The upload will fail because Azure DevOps requires you to be signed in and authorized.
Sign in with 'az login' and ensure you have permissions to publish to the feed.
Using inconsistent package versions between publish and restore commands
Your project may try to restore a version that does not exist, causing errors.
Keep package version numbers consistent and update them properly in all commands.
Summary
Create a private feed in Azure Artifacts to store your packages.
Configure your project to use the feed by updating nuget.config with the feed URL.
Publish packages to the feed using Azure CLI commands.
Restore and download packages from the feed to use them in your projects.

Practice

(1/5)
1. What is the primary purpose of Azure Artifacts in a development project?
easy
A. To monitor application performance
B. To deploy virtual machines automatically
C. To manage user identities and access
D. To store and share code packages securely

Solution

  1. Step 1: Understand Azure Artifacts role

    Azure Artifacts is designed to store and share packages like libraries or tools used in development.
  2. Step 2: Compare with other Azure services

    Other options relate to different Azure services: virtual machines, monitoring, and identity management.
  3. Final Answer:

    To store and share code packages securely -> Option D
  4. Quick Check:

    Azure Artifacts = package storage [OK]
Hint: Remember: Artifacts = packages storage and sharing [OK]
Common Mistakes:
  • Confusing Azure Artifacts with Azure Monitor
  • Thinking it manages virtual machines
  • Mixing it up with Azure Active Directory
2. Which of the following is the correct way to configure a package manager to use an Azure Artifacts feed?
easy
A. Create a virtual machine in Azure
B. Add the feed URL to the package manager's configuration file
C. Enable Azure Monitor alerts
D. Set up Azure Active Directory users

Solution

  1. Step 1: Identify configuration for package managers

    Package managers like npm or NuGet require the feed URL in their config to publish or consume packages.
  2. Step 2: Eliminate unrelated options

    Creating VMs, enabling alerts, or setting up users are unrelated to package manager configuration.
  3. Final Answer:

    Add the feed URL to the package manager's configuration file -> Option B
  4. Quick Check:

    Feed URL in config = correct setup [OK]
Hint: Configure package manager with feed URL in config file [OK]
Common Mistakes:
  • Trying to configure unrelated Azure services
  • Forgetting to add the feed URL
  • Confusing user setup with package feed setup
3. Given this snippet configuring npm to use Azure Artifacts feed:
npm set registry https://pkgs.dev.azure.com/contoso/_packaging/feed/npm/registry/

What will happen when you run npm install after this?
medium
A. npm will fetch packages from the Azure Artifacts feed
B. npm will fail because the URL is invalid
C. npm will install packages only from the public npm registry
D. npm will delete local packages

Solution

  1. Step 1: Understand npm registry setting

    Setting the registry URL tells npm to fetch packages from that feed instead of the default public registry.
  2. Step 2: Predict npm install behavior

    After setting, npm install will pull packages from the Azure Artifacts feed URL provided.
  3. Final Answer:

    npm will fetch packages from the Azure Artifacts feed -> Option A
  4. Quick Check:

    npm registry set = fetch from feed [OK]
Hint: npm registry URL points to Azure feed for installs [OK]
Common Mistakes:
  • Assuming npm uses default registry ignoring config
  • Thinking URL is invalid without checking format
  • Confusing install with delete commands
4. You configured your NuGet client to use an Azure Artifacts feed but get authentication errors when restoring packages. What is the most likely cause?
medium
A. You have no internet connection
B. The feed URL is missing from NuGet.config
C. You did not authenticate with Azure DevOps before restoring
D. Your local packages folder is full

Solution

  1. Step 1: Understand authentication requirement

    Azure Artifacts feeds require authentication to access private packages.
  2. Step 2: Identify cause of authentication errors

    If you get authentication errors, it means you likely did not sign in or provide credentials to Azure DevOps.
  3. Final Answer:

    You did not authenticate with Azure DevOps before restoring -> Option C
  4. Quick Check:

    Authentication missing = errors [OK]
Hint: Always authenticate to Azure DevOps before package restore [OK]
Common Mistakes:
  • Ignoring authentication step
  • Assuming URL missing causes auth errors
  • Blaming internet or disk space without checking auth
5. You want to share a private package with your team using Azure Artifacts. Which steps should you take to ensure only your team can access it?
hard
A. Create a private feed, add team members with permissions, publish package to feed
B. Publish package to public npm registry, share URL with team
C. Upload package to a public GitHub repo
D. Email the package files to team members

Solution

  1. Step 1: Create a private feed in Azure Artifacts

    This feed restricts package access to authorized users only.
  2. Step 2: Add team members with proper permissions

    Granting permissions ensures only your team can access the feed and packages.
  3. Step 3: Publish the package to the private feed

    Publishing here keeps the package secure and accessible only to your team.
  4. Final Answer:

    Create a private feed, add team members with permissions, publish package to feed -> Option A
  5. Quick Check:

    Private feed + permissions = secure sharing [OK]
Hint: Use private feed and permissions to control package access [OK]
Common Mistakes:
  • Publishing to public registries for private packages
  • Sharing packages by email or public repos
  • Not setting permissions on the feed