Unable to delete custom domain from static web app

WRex 0 Reputation points
2025-02-14T19:16:59.2433333+00:00

I recently attempted to delete a custom domain from an Azure static web app. It has been stuck in the deleting status for several weeks. I've attempted to delete it from the GUI multiple times over the course of the past few weeks.

All DNS records for the custom domain (CNAME, etc) are still active.

I've also attempted to run the following PowerShell command (with the correct names for each variable):

$rg = "[resource group name]";
$name = "[static web app name]";  
$remove_me = "[custom domain name]";  
$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!";

As well as this by itself:

Remove-AzStaticWebAppCustomDomain -ResourceGroupName [resource group] -Name [static web app] -DomainName [custom domain name]

Neither has worked, with the logs showing:

User's image

As well as this in PowerShell:

Remove-AzStaticWebAppCustomDomain_Delete: The server responded with an unrecognized response, Status: OK

Any assistance would be appreciated in resolving this.

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

1 answer

Sort by: Most helpful
  1. WRex 0 Reputation points
    2025-02-27T14:33:18.32+00:00

    I've attempted to delete it from the Azure Resource Manager as well as manually, but it did not work.

    The resource group currently has no locks in place.

    When using the command you provided (with correct information):

    az staticwebapp hostname delete -n "<static-webapp-name>" -g "<resource-group>" --hostname "<custom-domain>"
    

    I get the following output and the custom domain isn't deleted:

    Are you sure you want to perform this operation? (y/n): y
    After deleting a custom domain, there can be a 15 minute delay for the change to propagate.
    (Unspecified) 
    Code: Unspecified
    Message: 
    

    The script I ran originally came from the forum post you linked.

    I am in the process of removing the DNS entries.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.