Signed-off-by: Marc Duiker <marcduiker@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| infra | ||
| scripts | ||
| azure.yaml | ||
| readme.md | ||
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
- Active Azure Subscription with
ContributororOwneraccess to create resources - Azure Developer CLI
Deploy Static Web App
- Export any environment variables you want to override with your values using
./infra/main.parameters.jsonas 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.
- 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
-
(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
-
(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.