Delete and recover packages

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019 | TFS 2018

Azure Artifacts safely stores different types of packages in your feed, whether you published them directly or saved them from upstream sources. As older package versions fall out of use, you might want to clean them up either manually or automatically by using retention policies.

In this article, you'll learn how to:

  • Delete packages from feeds.
  • Set up retention policies to automatically delete older packages.
  • Recover recently deleted packages from the Recycle Bin.

Note

To delete/recover packages or set up retention policies, you must be a feed Owner.

Delete packages

In Azure Artifacts, packages are immutable. When you publish a package to your feed, its version number will be reserved permanently. You can't upload a new package with that same version number, even if you delete it from your feed.

Two options are available to delete a NuGet package from your feed, Unlist and Delete.

Note

You must be a Contributor to unlist a package and an Owner to delete it.

  1. Select Artifacts, and then select your feed.

  2. Select the package that you want to delete or deprecate, and then select Unlist or Delete latest.

    Screenshot that shows buttons for unlisting and deleting NuGet packages.

  1. Select Build and Release.

  2. Select Packages, and then select the package that you want to delete.

  3. Select Unlist or Delete latest.

    Screenshot that shows the buttons for unlisting and deleting NuGet packages in Team Foundation Server.

Unlist a NuGet package by using NuGet.exe

  1. Select Artifacts, and then go to your feed. Select Connect to feed.

    Screenshot that shows the button for connecting to a feed.

    Screenshot that shows the button for connecting to a feed in Team Foundation Server.

  2. Select NuGet.exe, and then find and copy your Package Source URL.

  3. Run the following command:

    nuget.exe delete <PACKAGE_NAME> <PACKAGE_VERSION> -Source <PACKAGE_SOURCE_URL> -ApiKey <KEY>
    

Note

Azure DevOps and Visual Studio Team Foundation Server interpret the nuget.exe delete command as an unlist operation. To delete a package, you must use the REST API or the web interface.

Note

Packages sent to the Recycle Bin will be deleted permanently after 30 days. However, these packages still count as part of your storage bill. If you want to delete them sooner, go to the Recycle Bin and delete them manually.

Delete packages automatically with retention policies

The number of versions for each package hosted in your feed can grow quickly. To free up storage space, you can set up retention policies to automatically delete old packages.

If you want to retain a package indefinitely, you can promote it to a view. Packages promoted to a view are exempt from retention policies and won't be deleted.

Note

Package demotion is not supported. If you want this feature to be added to future releases, feel free to use Suggest a feature on our Azure DevOps Developer Community page.

To configure retention policies:

  1. Select Artifacts.

    Screenshot that shows the Artifacts button.

  2. Select the gear icon to navigate to your feed's settings.

    A screenshot showing how to navigate to feed settings.

  3. Select Feed details, and then select the Enable package retention checkbox. Then enter values for:

    • Maximum number of versions per package: How many versions of a package you want to keep.
    • Days to keep recently downloaded packages: Packages will be deleted only if they haven't been downloaded for the number of days set in here.

    Screenshot that shows how to enable retention policies for your feed.

  4. Select Save when you're done.

  1. Select Build and Release.

  2. Select Packages, and then select the gear icon to access your feed's settings.

    Screenshot that shows how access the feed's settings in Team Foundation Server.

  3. From the Retention tab, enter values for:

    • Maximum number of versions per package: How many versions of a package you want to keep.
    • Days to keep recently downloaded packages: Packages will be deleted only if they haven't been downloaded for the number of days set in here.

    Screenshot that shows retention policies in Team Foundation Server.

  4. Select Save when you're done.

Note

When you enable package retention, a version of a package will be deleted when both of the following criteria are met:

  • The number of published versions reaches the Maximum number of versions per package limit.
  • A version of that package has not been downloaded for the period defined in Days to keep recently downloaded packages.

Recover deleted packages

Deleted packages will remain in the Recycle Bin for 30 days. After that, they'll be permanently deleted. You must be a feed Owner to recover deleted packages.

  1. Select Artifacts.

    Screenshot of how to access Azure Artifacts.

  2. Select Recycle Bin.

    A screenshot showing how to access the recycle bin.

  3. Select your package, and then select Restore.

    A screenshot showing how to restore deleted packages.

  1. Select Build and Release, and then select Packages.

  2. Select Recycle Bin.

    Screenshot of how to access the Recycle Bin in Team Foundation Server.

  3. Select the appropriate package, and then select the package version that you want to delete.

    Screenshot that shows the package in the Recycle Bin in Team Foundation Server.

  4. Select Restore to feed.

    Screenshot that shows the button for restoring to feed in Team Foundation Server.

Q&A

Q: What is the difference between Deprecate, Unpublish, Unlist, and Delete a package version?

A: Unpublish and Deprecate applies to npm packages, while Unlist and Delete applies to NuGet packages. You can also Delete package versions for the rest of the package types (Maven, Python, and Universal Packages):

  • Deprecate (npm): When you deprecate a package version, a warning message is added to the package's metadata. Azure Artifacts and most npm clients will display the warning message whenever the package is viewed or installed.

  • Unpublish (npm): Unpublishing a package version makes it unavailable to install. Unpublished packages can be restored from the Recycle Bin within 30 days of deletion. After that, the packages will be permanently deleted.

  • Unlist (NuGet): Unlisting a package version hides it from the search results in Azure Artifacts feeds and on NuGet.org.

  • Delete: Deleting a package version makes it unavailable to install. Deleted packages can be restored from the Recycle Bin within 30 days of deletion. After that, the packages will be permanently deleted.

Q: What happens with old or existing packages when we enable retention policies?

A: Old or existing packages will be soft-deleted and moved to the Recycle Bin. The deletion job runs once a day, but there might be an initial delay after the policy is turned on for the first time because of an influx of packages.

Packages remain in the Recycle Bin for 30 days before they're permanently deleted. To remove the packages from your billable storage, you can choose to delete them manually by using the UI or the REST API before the 30 days are up.