Microsoft developers just added a new resource type called Static Web App, something I was looking for since the day I started using Azure.
It makes a simple way to deploy a web page and a set of APIs based on Azure Functions. By the time of writing, the service is still in beta, and have some caveats.
Let's deploy a really simple project, meaning:
- No lambdas.
- No build task.
- Lives on GitHub.
First we create a resource on Azure. The master is super-simple, just don't pick GitHub under Deployment details and leave the Source to Other. This way, you won't have to let Azure DevOps app to access your repository.
Wait for resource to be created, then go to the resource page and click on Manage deployment token tab. Copy the token and create a variable in your repository named AWESOME_PAGE_DEPLOYMENT_TOKEN or alike.
Second step is to create deployment workflow using GitHub Actions. Create file .github/workflows/deploy.yml in your repository, with following contents:
Fix branch name and the path to static files. And basically, that's it. From here you can expand by adding lambda functions, actual build steps etc.
The root domain problem
One really major issue with the service is limited support of custom domains. It is not possible to use root domain at this point, you're forced to implement something like www or blog or whatever. Which could be quite a drawback for some people, especially those who wants to migrate to this service from less sophisticated solutions like using Azure Storage to host static files, and don't want to set up redirection and mess up with their SEO.
An example on how to set up such redirection is explained in details here:
How to configure a root domain in an Azure Static Web App
UPD 2021-05-14 Custom root domains are working!