docs/.github/iac/swa
Marc Duiker b26fdaf67f
Update SWA deployment instructions (#4859)
Signed-off-by: Marc Duiker <marcduiker@users.noreply.github.com>
2025-09-05 14:32:45 -07:00
..
infra IaC for Static Web App for Docs site 2024-05-29 18:40:25 -07:00
scripts IaC for Static Web App for Docs site 2024-05-29 18:40:25 -07:00
azure.yaml IaC for Static Web App for Docs site 2024-05-29 18:40:25 -07:00
readme.md Update SWA deployment instructions (#4859) 2025-09-05 14:32:45 -07:00

readme.md

Dapr Static Web Apps

dapr.docs.io

Summary

This folder contains a template and infrastructure as code to recreate and reconfigure the static web app used to host docs.dapr.io.

Prerequisites

  1. Active Azure Subscription with Contributor or Owner access to create resources
  2. Azure Developer CLI

Deploy Static Web App

  1. Export any environment variables you want to override with your values using ./infra/main.parameters.json as a reference for the variable names. e.g.

Bash/sh/zsh:

export AZURE_RESOURCE_GROUP=docs-website
export IDENTITY_RESOURCE_GROUP=dapr-identities
export AZURE_STATICWEBSITE_NAME=daprdocs-v1-1

Where daprdocs-v1-1 should be updated with the new preview version.

PowerShell

setx AZURE_RESOURCE_GROUP "docs-website"
setx IDENTITY_RESOURCE_GROUP "dapr-identities"
setx AZURE_STATICWEBSITE_NAME "daprdocs-v1-1"

Where daprdocs-v1-1 should be updated with the new preview version.

This assumes you have an existing user-assigned managed identity (see L39 in ./infra/main.bicep to use or modify name) in a resource group that you can reference as the runtime identity of this static web app. We recommend storing this in a different resource group from your application, to keep the permissions and lifecycles separate of your identity and your web app. We also recommend narrowly limiting who has access to view, contribute or own this identity, and also only apply it to single resource scopes, not to entire resource groups or subscriptions, to avoid elevation of priviledges.

  1. Deploy using the Azure Dev CLI

Start by creating a create a side-by-side azd environment:

azd env new

For example, you can name the new environment something like: dapr-docs-v1-1.

Now, deploy the Dapr docs SWA in the new azd environment using the following command:

azd up

You will be prompted for the subscription and location (region) to use. The Resource Group and Static Web App will now be created and usable. Typical deployment times are only 20-60 seconds.

Configure the Static Web App in portal.azure.com

  1. (Optional) Grant correct minimal permissions for inbound publishing and outbound access to dependencies using the Static Web App -> Access control (IAM) blade of the portal

  2. (Optional) Map your DNS CNAME using the Static Web App -> Custom Domain blade of the portal

Configure your CI/CD pipeline

You will need a rotatable token or ideally a managed identity (coming soon) for your pipeline to have Web publishing access grants to the Static Web App. Get the token from the Overview blade -> Manage Access Token command of the SWA, and store it in the vault/secret for the repo matching your Github Action (or other CI/CD pipeline)'s workflow file. One example for the current/main release of Dapr docs is here. This is an elevated operation that likely needs an admin or maintainer to perform.