Azure / Azure/static-web-apps

How to add and automatically validate a custom apex domain which is hosted on Azure DNS to an Azure Static Web App using Bicep?

Open
#1,652 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

I currently have this on my Bicep template:

// Static Web App
resource staticWebApp 'Microsoft.Web/staticSites@2024-04-01' = {
name: resourceName
location: location
tags: tags
sku: {
name: staticWebAppConfigs.home.skuName
tier: staticWebAppConfigs.home.skuTier
}
properties: {
stagingEnvironmentPolicy: staticWebAppConfigs.home.stagingEnvironmentPolicy
allowConfigFileUpdates: staticWebAppConfigs.home.allowConfigFileUpdates
enterpriseGradeCdnStatus: staticWebAppConfigs.home.enterpriseGradeCdnStatus
}
}

// Create A record as an alias to the static web app resource
module aRecord './dns-record.bicep' = {
name: 'deploy-a-record-${resourceName}'
scope: resourceGroup(sharedResourceGroupName)
params: {
dnsZoneName: staticWebAppConfigs.home.dnsZone.zoneName
recordName: '@'
recordType: 'A'
recordValue: ''
isAlias: true
targetResourceId: staticWebApp.id
}
}

// Custom Domain resource - single domain
resource customDomain 'Microsoft.Web/staticSites/customDomains@2022-09-01' = {
name: staticWebAppConfigs.home.customDomain
parent: staticWebApp
properties: {
validationMethod: 'dns-txt-token'
}
dependsOn: [
aRecord
]
}

But this causes my Bicep deployment stack to get stuck deploying the customDomain.

It's now been stuck on deploying that resource for 40 minutes.

If I access the static web app resource and visit the custom domains tab, I can see that the custom domain status is "Validating" and I can see the TXT record that needs to be added to the DNS zone.

I'm confused though because if I do this manually via the Azure Portal I can go to `Custom domains > Add > Custom domain on Azure DNS` then I select my DNS zone and leave the subdomain field blank and click add then it'll say "Validating" for a bit but it will ultimately add the TXT record to the DNS Zone automatically, without me doing anything else.

How do I specify that my custom domain is on Azure DNS when deploying the `Microsoft.Web/staticSites/customDomains` resource? It seems to think im using an external DNS and waiting for me to add the TXT record manually.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.