Delete and recover packages
Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019
Azure Artifacts securely stores various package types in a feed, whether published directly or saved from upstream sources. As older package versions become less relevant, you can remove them manually or by using retention policies to free up space and reduce costs.
Prerequisites
Product | Requirements |
---|---|
Azure DevOps | - An Azure DevOps organization. - An Azure DevOps project. - An Azure Artifacts feed. - Permissions: - You must be a Feed Owner to set up retention policies, delete packages and feeds, or restore packages from the recycle bin. - You must be a Feed Publisher (Contributor) or higher to unlist, deprecate, or yank packages. |
Delete packages
In Azure Artifacts, packages are immutable, meaning their version numbers cannot be reused or modified after publishing. Once you publish a package to a feed, its version number is permanently reserved. Even if you delete the package, its version remains recorded in the feed’s history, and you cannot publish a new package with the same version number.
There are two ways to remove a NuGet package from a feed: Unlist and Delete. Unlisting a package version hides it from search results in Azure Artifacts feeds and on NuGet.org. Deleting a package version moves it to the recycle bin and makes it unavailable for installation.
Sign in to your Azure DevOps organization, and then navigate to your project.
Select Artifacts, and then select your feed from the dropdown menu.
Select the package you want to delete, then select Unlist to hide it from search results in Azure Artifacts feeds and on NuGet.org, or Delete to move it to the recycle bin.
Unlist packages (CLI)
Sign in to your Azure DevOps organization, then navigate to your project.
Select Artifacts, then select your feed from the dropdown menu.
Select Connect to feed > NuGet.exe, then find and copy your Package Source URL. It should follow this format:
https://pkgs.dev.azure.com/OrganizationName/ProjectName/_packaging/FeedName/nuget/v3/index.json
.Run the following command to unlist your package. The ApiKey argument is required but is treated as a placeholder when publishing to an Azure Artifacts feed, so you can use any string value:
nuget.exe delete <PACKAGE_NAME> <PACKAGE_VERSION> -Source <PACKAGE_SOURCE_URL> -ApiKey <ANY_STRING>
Important
Azure DevOps interprets the nuget.exe delete
command as an unlisting operation. This means that running the command does not delete the package, but instead hides it from search results in Azure Artifacts feeds and on NuGet.org. To delete a package from your feed, you must use the REST API or delete it manually from the web interface.
Delete packages permanently
Packages in the recycle bin are automatically deleted after 30 days, but they still count toward your storage usage during this period. To remove them sooner, you can manually delete them from the Recycle Bin by following these steps:
Sign in to your Azure DevOps organization, and then navigate to your project.
Select Artifacts, then select your feed from the dropdown menu.
In the upper-right corner, select Recycle Bin.
Select the package you want to delete permanently, then select Permanently Delete.
Select Permanently Delete again to confirm your decision. Your package will be deleted permanently.
Delete packages automatically with retention policies
As the number of package versions in your feed grows, storage usage can increase rapidly. You can set up retention policies to automatically delete old package versions and free up space.
If you need to keep a package indefinitely, promote it to a view. Packages in a view are exempt from retention policies and will not be subject to deletion. To configure retention policies for your feed, follow the steps below:
Note
Azure Artifacts does not support package demotion. Once a package is promoted to a view, it cannot be reverted back to @local.
Sign in to your Azure DevOps organization, and then navigate to your project.
Select Artifacts, then select the gear icon
in the upper-right corner to access your feed's settings.
Select Feed details, check the Enable package retention checkbox, and configure the following settings:
Maximum number of versions per package: The number of versions for each package you wish to retain.
Days to keep recently downloaded packages: Packages will only be deleted if they haven't been downloaded for the specified number of days specified here.
Select Save when you're done.
Note
When retention policies are enabled, a package version will be deleted only when both of the following conditions are met:
- The total number of published versions reaches the Maximum number of versions per package limit.
- A version of that package has not been downloaded within the timeframe specified in Days to keep recently downloaded packages.
Restore deleted packages
Deleted packages remain in the recycle bin for 30 days. After this period, they are permanently deleted. To restore a package from the recycle bin, follow these steps:
Sign in to your Azure DevOps organization, and then navigate to your project.
Select Artifacts, then select Recycle Bin.
Select your package, and then select Restore.
Select Restore once more to confirm your decision.
Q&A
Q: What is the difference between Deprecate, Unlist, Yank, and Delete a package version?
A: Deprecate applies to npm packages, Yank applies to Cargo packages while Unlist applies to NuGet packages. You can Delete any of the package types (npm, Maven, Python, Cargo, and Universal Packages) from your Azure Artifacts feed.
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 this warning message whenever the package is viewed or installed.
Unlist (NuGet): Unlisting a package version hides it from search results in Azure Artifacts feeds and on NuGet.org.
Yank (Cargo): Yanking a package version marks it as obsolete or deprecated, discouraging its use, but it doesn't delete the package.
Delete: Deleting a package version moves it to the recycle bin, making it unavailable for installation. Deleted packages can be restored from the recycle bin within 30 days. After this period, they will be permanently deleted.
Q: How do I delete all package versions?
A: To delete all versions of a package, select the package from your feed, select Versions, and then select the checkbox next to version. This will select all versions of that package in your feed. Select Delete, then select delete once more to confirm.
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 due to 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 manually delete them using the web UI or the REST API before the 30-day period ends.
Q: What if I don't want to enable retention policies?
A: Azure Artifacts retention policies are designed to help manage your dependencies and streamline storage cost management. If you choose not to enable retention policies, you'll need to manage your storage manually, monitoring consumption and deleting packages as necessary. Azure Artifacts offers 2 GiB of free storage per organization, which allows you to evaluate whether the service fits your workflow. Once you exceed the storage limit, you won't be able to publish new artifacts unless you set up billing and increase your storage limit.
Q: How long does it take for the billed storage amount to update after deleting Artifacts?
A: Typically, storage consumption should update within 24 hours. However, in some cases, it might take up to 48 hours for the changes to be reflected. The Artifacts usage on your organization's billing page updates once a day, while the Artifact Storage page is updated more frequently, which could lead to a slight discrepancy between the two.