{"id":62906,"date":"2021-12-02T08:56:59","date_gmt":"2021-12-02T16:56:59","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/devops\/?p=62906"},"modified":"2021-12-02T08:54:46","modified_gmt":"2021-12-02T16:54:46","slug":"automating-azure-static-web-apps-in-azure-pipelines","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/automating-azure-static-web-apps-in-azure-pipelines\/","title":{"rendered":"Automating Azure Static Web Apps in Azure Pipelines"},"content":{"rendered":"<p><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/static-web-apps\/\">Azure Static Web Apps<\/a> 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 <a href=\"https:\/\/aka.ms\/ADOAzureSWA\">getting started guide<\/a> 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 <em>Deployment Token<\/em> from the Azure portal into your variables in Azure DevOps.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/Untitled-scaled.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/Untitled-1024x344.jpg\" alt=\"Deployment Token\" width=\"640\" height=\"215\" class=\"aligncenter size-large wp-image-62923\" srcset=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/Untitled-1024x344.jpg 1024w, https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/Untitled-300x101.jpg 300w, https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/Untitled-768x258.jpg 768w, https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/Untitled-1536x516.jpg 1536w, https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/Untitled-2048x687.jpg 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>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.<\/p>\n<p>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!<\/p>\n<p>Here is a sample pipeline that includes this automation task:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/swayaml-scaled.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/swayaml-1024x703.jpg\" alt=\"PowerShell Script in Azure Pipelines\" width=\"640\" height=\"439\" class=\"aligncenter size-large wp-image-62909\" srcset=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/swayaml-1024x703.jpg 1024w, https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/swayaml-300x206.jpg 300w, https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/swayaml-768x527.jpg 768w, https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/swayaml-1536x1054.jpg 1536w, https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2021\/12\/swayaml-2048x1405.jpg 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>If you would like to reuse this task (please send a very warm thank you to <a href=\"https:\/\/twitter.com\/StevenMurawski\">Steven Murawski<\/a>) and you can reference the PowerShell script <a href=\"https:\/\/github.com\/scubaninja\/AzStaticWebApps-Demo\/tree\/main\/infrastructure\">here<\/a>.<\/p>\n<p>Good luck and happy automating!<\/p>\n<p>For more DevOps goodness have a look at the links below:<\/p>\n<p><a href=\"https:\/\/aka.ms\/AzDevOpsYouTube\">The DevOps Lab on YouTube<\/a><br \/>\n<a href=\"https:\/\/twitter.com\/TheDevOpsLab\">The DevOps Lab on Twitter<\/a><br \/>\n<a href=\"https:\/\/aka.ms\/DevOpsLab\">The DevOps Lab on Microsoft Docs<\/a><\/p>\n<p>Useful Docs:<\/p>\n<p><a href=\"https:\/\/azure.microsoft.com\/free\/?WT.mc_id=devops-15965-jagord\">Microsoft Azure: $200 Free Credit<\/a><br \/>\n<a href=\"https:\/\/www.azuredevopslabs.com\/\">Azure DevOps Hands on Labs<\/a><br \/>\n<a href=\"https:\/\/aka.ms\/AzureDevOps\/Learning\">Get started with the Azure DevOps learning path<\/a><br \/>\n<a href=\"https:\/\/aka.ms\/AzureDevOpsDocumentation\">Azure DevOps Documentation<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":11848,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[224,226,1],"tags":[],"class_list":["post-62906","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-ci","category-devops"],"acf":[],"blog_post_summary":"<p>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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/62906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/11848"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=62906"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/62906\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=62906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=62906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=62906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}