Delete default project Wiki in Azure DevOps
Background
Azure DevOps supports 2 types of project Wikis:
- project wiki: users are able to add / edit pages directly within the specified Wiki
- code wiki: markdown files are defined in a Git repo and published to the Wiki
Upon creating a new wiki, youโre greeted with the following screen:
Whenever someone has already created a project Wiki, there seems to be no way to delete it going through the web UI ๐ . This can get very annoying, especially when your team project contains a code wiki which lives next to the (default) project wiki. Clicking the Overview > Wiki menu will have users ending up in the default project wiki (which will be selected by default) instead of your code wiki, which can get confusing.
Even though it seems like only the code wikis (obviously) have a git repo backing it, all content of provisioned wikis is stored in a dedicated repo as well. Deleting this repo will delete the project wiki in question.
Solution
We can do this by making use of the Azure DevOps REST API. Call the REST API using PowerShell or specialized tools like for example Postman. Have a look at one of my earlier posts which explains how to do so: Call Azure DevOps REST API with Postman
1) Letโs first get a list of all Wikis in our team project:
GET https://dev.azure.com/{organization}/{project}/_apis/wiki/wikis?api-version=6.0
Response:
{
"value": [
{
"id": "1318cf4b-2653-4567-af6b-f8028d7d9e33",
"versions": [
{
"version": "wikiMaster"
}
],
"url": "https://dev.azure.com/fabrikamfiber/7c964ac3-ee1f-1234-9bfb-3bb5c5aff2d4/_apis/wiki/wikis/1318cf4b-2653-4567-af6b-f8028d7d9e33",
"remoteUrl": "https://dev.azure.com/fabrikamfiber/7c964ac3-ee1f-1234-9bfb-3bb5c5aff2d4/_wiki/wikis/1318cf4b-2653-4567-af6b-f8028d7d9e33",
"type": "projectWiki",
"name": "first-wiki.wiki",
"projectId": "7c964ac3-ee1f-1234-9bfb-3bb5c5aff2d4",
"repositoryId": "1318cf4b-2653-4567-af6b-f8028d7d9e33",
"mappedPath": "/"
},
{
"id": "5cfeda59-ec80-4e85-8600-9d99cbf54ebb",
"versions": [
{
"version": "master"
}
],
"url": "https://dev.azure.com/fabrikamfiber/7c964ac3-ee1f-1234-9bfb-3bb5c5aff2d4/_apis/wiki/wikis/5cfeda59-ec80-4e85-8600-9d99cbf54ebb",
"remoteUrl": "https://dev.azure.com/fabrikamfiber/7c964ac3-ee1f-1234-9bfb-3bb5c5aff2d4/_wiki/wikis/5cfeda59-ec80-4e85-8600-9d99cbf54ebb",
"type": "codeWiki",
"name": "second-wiki",
"projectId": "7c964ac3-ee1f-1234-9bfb-3bb5c5aff2d4",
"repositoryId": "6bb93d89-e257-4385-8aa0-675fb4830d9c",
"mappedPath": "/"
}
],
"count": 2
}
You can see both of our wikis are listed, each having a different type
property. The first one being the project wiki ("type": "projectWiki"
), and the second one being or code wiki ("type": "codeWiki"
). Note the repositoryId
of the project wiki (1318cf4b-2653-4567-af6b-f8028d7d9e33
in this example), which weโll be using in the next step.
2) Delete the project wiki in question by specifying the repositoryId
(1318cf4b-2653-4567-af6b-f8028d7d9e33
in this example). This will delete the underlying repository and get rid of the wiki:
DELETE https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}?api-version=6.0
Response:
Status code: 204
3) Double check by re-running our first REST call:
GET https://dev.azure.com/{organization}/{project}/_apis/wiki/wikis?api-version=5.1
Response:
{
"value": [
{
"id": "5cfeda59-ec80-4e85-8600-9d99cbf54ebb",
"versions": [
{
"version": "master"
}
],
"url": "https://dev.azure.com/fabrikamfiber/7c964ac3-ee1f-1234-9bfb-3bb5c5aff2d4/_apis/wiki/wikis/5cfeda59-ec80-4e85-8600-9d99cbf54ebb",
"remoteUrl": "https://dev.azure.com/fabrikamfiber/7c964ac3-ee1f-1234-9bfb-3bb5c5aff2d4/_wiki/wikis/5cfeda59-ec80-4e85-8600-9d99cbf54ebb",
"type": "codeWiki",
"name": "second-wiki",
"projectId": "7c964ac3-ee1f-1234-9bfb-3bb5c5aff2d4",
"repositoryId": "6bb93d89-e257-4385-8aa0-675fb4830d9c",
"mappedPath": "/"
}
],
"count": 1
}
The above steps should have deleted your project wiki, leaving you with just the code wiki intact ๐
Comments