unable to delete custom domain for azure static web app

Chai Seng Loi 1 Reputation point
2022-09-20T05:50:51.773+00:00

I tried to delete the custom domain for my static web app, the progress is still "deleting":
242696-snipaste-2022-09-20-13-46-54.png

The activity log showed that delete failed with no reason:
242706-snipaste-2022-09-20-13-48-05.png

I tried doing it from cli, and it showed some errors:
242729-snipaste-2022-09-20-13-49-40.png

Is there anyway to delete custom domain?

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
803 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VenkateshDodda-MSFT 19,616 Reputation points Microsoft Employee
    2022-09-20T10:01:43.717+00:00

    @Chai Seng Loi Thanks for your swift response you can use the below PowerShell script to delete custom domain of static web app this script will retry the delete operation until it gets succeeded. You can run this script from cloud shell in the portal if you don't have PowerShell locally installed.

    $name = "<static-webapp>";  
    $remove_me = "sub.domain.com";  
    $domains = Get-AzStaticWebAppCustomDomain -ResourceGroupName $rg -Name $name;  
    $len = $domains.Length;  
    while($len -eq $domains.Length){  
            foreach($item in $domains){  
                if($item.name -eq $remove_me){  
                    $err = Remove-AzStaticWebAppCustomDomain -DomainName $remove_me -Name $name -ResourceGroupName $rg -NoWait;  
                    $domains = Get-AzStaticWebAppCustomDomain -ResourceGroupName $rg -Name $name;   
                    if($domains.Length -gt 0){  
                        Write-Host "$remove_me still exists. Retrying...";  
                        Start-Sleep -s 10;  
                    }  
                }  
            }   
        }  
    Write-Host "Success!";  
    

    Feel free to reach back to me if you have any further queries on this.

    1 person found this answer helpful.