Deploying DocFX on Azure static web app
Introduction
Azure Static Web App
The Azure static web app is a modern web app service that helps with streamlined full-stack development. The feature I like most about it is the ease of CI-CD managed straight from the resource deployment. Refer documentation, Building your first static site in the Azure portal for how to.
DocFx
DocFX is a nice open-source tool to produce documentation from source code (including C#, F#, Visual Basic, REST, JavaScript, Java, Python and TypeScript) as well as raw Markdown files. It generates a static website from doc comments.
The deployment
First of all, we need a DocFx ready repo, ideally on GitHub. The simplest thing to do is to fork the DocFx seed project.
Once the repo is ready, follow the Microsoft documentation link above to create a new Azure static web app and select this repo from GitHub for Source in Deployment details.
This will create a workflow in the repo. This is super useful as it automatically handles the triggers and required steps. The only step missing will be the building of the DocFx site. This has to be added just before the autogenerated Build And Deploy
step.
- name: Build Documentation
uses: nikeee/docfx-action@v1.0.0
with:
args: docs/docfx.json
And that’s it.
Conclusion
This makes it very easy to have a website where you can share your API docs for other teams to refer to. And I remain very impressed with this static web app offering from Azure. You may want to refer the fork I created to test this on github.