azure-devopsazure-pipelineswikiwiki-markup

Automatically update content of Azure DevOps Wikis


I want to include an image_file in a Azure DevOps Wiki.

The image_file in question is automatically updated everytime I make a commit to the main branch in a personal_repo.

Hence, I want to include a link pointing to that image_file in that personal_repo.

![Context Diagram](https://dev.azure.com/{org}/{prj}/_apis/sourceProviders/TfsGit/fileContents?repository=personal_repo&path=/image_file.png&commitOrBranch=main&api-version=7.1-preview)

The url is based on the Azure-DevOps-Docu and correct. I tested it for multiple files. It provides their content. However, the picture is not rendered as, assumably, the file type cannot be dertermined because the url has no ending like *.png, which its type is in my case.

I searched extensively for other API calls. The only other alternative I see now is to also push the image_file, in the pipeline that updates it, to the wiki's attachement dir and then include it from there. Isn't there an easier way?


Solution

  • I couldn't find a way to do it only using the Azure DevOps API, because Wiki attachments can be created but not deleted, as no respective call exists. Also, using Attachments - Create files can not be overwritten, whereby unique naming and wiki page upates would have to be implemented.

    The solution I implemented now is based on Wikis in Azure being repositories as well. In the runner, after I updated images, I clone the wiki repo using git, replace files in the .attachements folder, create a commit and push it.