Reputation: 191
I deleted Azure Repo by mistake, now I want to restore that repo is there any way we can restore it?
If possible, please advise.
Upvotes: 10
Views: 12392
Reputation: 33437
If you have deleted your repository, it will stay in Azure DevOps recycle bin for 30 days; so restoration is possible but you need to follow some manual steps as shown below.
Within 30 days, you can follow the steps below to recover your repository:
Create a PAT (Personal Access Token) in Azure DevOps.
You will need to use a tool such as a Postman software to make some API requests; using that, create a get request using this URL: https://dev.azure.com/{ORGANIZATION_NAME}/{PROJECT_NAME}/_apis/git/deletedrepositories?api-version=5.1-preview.1
Make Basic Auth, put the Token as a password, and leave the username empty.
The response contains the id of your deleted repo (a GUID id).
So making the request step 2, you get a JSON payload containing the REPO GUID as highlighted in yellow. That you need to copy for step 5.
With the following JSON payload body:
{
"deleted":false
}
When you make this request, it will recover the deleted repository from recycle bin.
Note: Replace {ORGANIZATION_NAME}, {PROJECT_NAME} and {REPO_GUID} with the right values.
I have tested this way and it works.
Disclaimer: This answer knowledge is based on an article I wrote in my personal blog. It is also possible to use this tool (AzdoTools) to recover the repositories. more info about it is in the given article link.
Upvotes: 23