Partager via


Delete a project

Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022 | Azure DevOps Server 2020

If a project becomes obsolete, you can delete it from your organization or collection in Azure DevOps. If you're migrating from an on-premises Azure DevOps Server to Azure DevOps Services, you might also need to delete the project. Removing unused projects can enhance navigation by limiting it to only those projects that are currently in use.

Caution

  • Soft-deleted projects from the web portal are permanently removed if not restored within 28 days.
  • In rare cases, our deletion process might take up to 70 days due to backend retries and the need to delete data from multiple sources.
  • Hard-deleted projects from the on-premises Azure DevOps Administration Console can't be restored. For more information, see Restore a project and Save project data.

Prerequisites

Save project data

Use the following procedures to save data that users most care about, such as source code, build data, and work items. This procedure is optional and something you might consider before you delete a project.

  • Source code and custom build templates: Download your files as a zip file. Select Repository actions for the repository, file, or folder and select Download as Zip. Or, select Download to download either all of the files in the currently selected folder, or the currently selected file.

    Screenshot of Downloading code.

    This process doesn't save any change history or links to other artifacts. If you use Git, clone your repositories to retain the full project history and all the branches.

  • Build data: To save logs and data in your drop build folders, see View build results.

  • Work item tracking data: Create a work item query and open it using Excel. Save the Excel spreadsheet.

    This process doesn't save any attachments, change history, or links to other artifacts.

For more information, see our Data Protection Overview.

Delete project

Use your web browser to perform a soft-delete. After 28 days, projects are permanently deleted if not restored within that time.

Your project is deleted and can be restored up to 28 days afterward. Your deleted project is removed from your projects list.

Restore a deleted project

If you inadvertently delete a project in Azure DevOps, you can restore it within 28 days of its deletion.

Restore project with REST API

Warning

To restore a project with an existing name, rename the project first. To rename the project, enter the following text in the request body: "name":"new name".

  1. Open a browser window and enter a URL that uses the following form:

    'http://ServerName:8080/tfs/DefaultCollection/ProjectName'

    For example, to connect to the server named FabrikamPrime, enter: 'http://FabrikamPrime:8080/tfs/'.

    The default Port is 8080. Specify the port number and directory for your server if defaults aren't used.

  2. Get a list of deleted projects using the following request:

    GET http://ServerName:8080/tfs/DefaultCollection/_apis/projects?stateFilter=
    deleted&api-version=5.0-preview.3
    
  3. Restore a deleted project using the following request:

    PATCH http://ServerName:8080/tfs/DefaultCollection/_apis/projects/{projectId}?
    api-version=5.0-preview.3
    

    Request body

    {
     "state" : "wellFormed"
    }
    

Restore project with PowerShell

  1. Execute the following PowerShell script to get a list of deleted projects and make sure to update $collectionUrl.

    $collectionUrl = "https://localhost/defaultcollection"
    (irm -Uri "$collectionUrl/_apis/projects?stateFilter=
    deleted&api-version=5.0-preview.3" -UseDefaultCredentials).value
    
  2. Use the following script to restore a project. Be sure to update $collectionUrl and $projectName.

    $collectionUrl = "https://localhost/defaultcollection"
    $projectName = 'Project1'
    $project = (irm -Uri "$collectionUrl/_apis/projects?stateFilter=
    deleted&api-version=5.0-preview.3" -UseDefaultCredentials).value
     | where {$_.name -eq $projectName}
    irm -Uri ($project.url + "?api-version=5.0-preview.3") 
    -UseDefaultCredentials -Method PATCH -Body '{"state":"wellFormed"}'
     -ContentType 'application/json'
    

Your project and associated data are restored.

FAQs

See the following frequently asked questions about deleting projects in Azure DevOps.

A: Work item links pointing to deleted project work items will remain until the project is permanently deleted. Once the project is permanently deleted, the work item links are automatically cleaned up within 24 hours. If you need the work item links cleaned up quicker than that, you can manually remove them from the work item form directly.

Q: I deleted a project in Azure DevOps, but in Visual Studio Team Explorer it's still there, what do I do?

A: Wait 28 days before the project is permanently deleted.