December 2nd, 2021

Automating Azure Static Web Apps in Azure Pipelines

April Yoho
Senior Developer Advocate

Azure Static Web Apps were launched earlier in 2021 and out of the box they had the capability to integrate your existing repository and deploy your Static Web App from Azure DevOps. You can reference the full getting started guide for the end-to-end deployment setup. Although, there is a caveat, the whole process is not entirely automated. When you create an Azure Static Web App you are required to copy the Deployment Token from the Azure portal into your variables in Azure DevOps.

Deployment Token

While deployment using Azure DevOps is supported, we really want to be better automate our pipeline and take out the manual intervention of having to copy and paste our Deployment Token into our pipelines. The reality is, we are going to need to rotate our deployment token to maintain a highly secure application. Imagine if we were taking part in good security practices and rotated our tokens, but forgot that we had a manual step to update our pipeline variables? This would undoubtedly cause downtime in our Azure Static Web App.

In our pipeline we can create a task that runs a PowerShell script that pulls the latest Deployment token from the Azure portal, then updating our pipeline deployment token with the new token value. This automates what would have been a very manual process!

Here is a sample pipeline that includes this automation task:

PowerShell Script in Azure Pipelines

If you would like to reuse this task (please send a very warm thank you to Steven Murawski) and you can reference the PowerShell script here.

Good luck and happy automating!

For more DevOps goodness have a look at the links below:

The DevOps Lab on YouTube
The DevOps Lab on Twitter
The DevOps Lab on Microsoft Docs

Useful Docs:

Microsoft Azure: $200 Free Credit
Azure DevOps Hands on Labs
Get started with the Azure DevOps learning path
Azure DevOps Documentation

Author

April Yoho
Senior Developer Advocate

April is a senior developer advocate and DevOps practice lead for GitHub specializing in application transformation and DevOps ways of working. Her focus is working on Microsoft Azure to take customers of a journey from legacy technology, to serverless and containers, where code comes first, while enabling them to take full advantage of DevOps. April was previously a cloud consultant and solution architect for various partners in the UK and brings her years of experience in helping customers ...

More about author

3 comments

Discussion is closed. Login to edit/delete existing comments.

  • mo. ashfak

    I am seeing many Developers article of Microsoft DevOPS And Web Apps but your writing skills just amazing April.
    1Fid

  • Sasan Barkhordari · Edited

    thank you about this great content , waiting for next release
    Tehranborj

  • Altaf Hussain

    This is what I exactly need appreciating for sharing.
    imgsin