Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
325 stars 56 forks source link

Deleting a custom domain should take minutes #915

Closed johnkors closed 1 year ago

johnkors commented 2 years ago

To Reproduce Steps to reproduce the behavior:

  1. Add a custom domain
  2. Delete a custom domain

. . . . WAIT 24 HOURS

image

[still not deleted 😴]

WAIT ..

💤

. . Go to work next day. Grab a coffee ☕️ Try to delete the domain the deleting state. image

See errors. . . . . WAIT ANOTHER COUPLE OF HOURS. . . . image

Expected behavior A custom domain should be able to be removed within minutes.

johnkors commented 2 years ago

Sorry about the snark, but why is adding/removing a custom domain such a pain in the ass. The same process take seconds in App Service (or more relevant, the competion: Vercel, Netlify). Is it because of GoDaddy or what?

Tucnak67 commented 2 years ago

I have exactly the same problem, since yesterday.

vienleidl commented 2 years ago

I have the same issue, unfortunately, it's stuck forever image

StacyCash commented 2 years ago

I came to report this as well. Mine isn't just taking minutes, it's forever. The only way I can remove a custom domain at the moment is to delete the SWA itself and recreate it. I've tried two subscriptions and both have the same issue.

johnkors commented 2 years ago

@StacyCash Deleting the SWA itself would probably delete the custom domain first, anyways? Or is that quicker in your experience?

StacyCash commented 2 years ago

For me it wasn't just quicker, it was the only way. That said deleting the SWA also took several attempts.

But I have to update my other statement: in my MVP Subscription deleting just doesn't happen, in my private subscription it simply takes 20 minutes or more to delete.

deathmarine commented 2 years ago

@johnkors Ran into the same problem with a domain taking hours to delete. and utilized a little brute force with PowerShell. Still takes a while... but the automation helps and I'm seeing ~20 mins like @StacyCash.

$rg = "<resource-group>";
$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!";
johnkors commented 2 years ago

Yeah, same — except we're using Pulumi for managing the infra on our end.

vgibilmanno commented 1 year ago

I had the same problem. The previous mentioned workarounds didn't work for me. What worked for me was to first delete the deployment and after that delete the static web app. Whenever I tried to delete the static web app first, it just reappeared after a few minutes with the status of the custom domain still as deleting.

kjkent commented 1 year ago

Also having this issue and unable to delete the SWAs involved or reclaim their domains for use in another resource.

It seems this Stack Overflow post and this Microsoft Learn post are referring to the same issue.

@vgibilmanno how did you get to delete the deployment? On the resource group level, I've deleted the deployments for the SWA, and if I go into the Environments blade within the resource, it just shows "production" as perpetually deleting.

vgibilmanno commented 1 year ago

@kjkent That's exactly how I did it. I went to the deployment option in the resource group blade, selected the SWA deployment and deleted it.

johnkors commented 1 year ago

Interesting workaround. Thanks.

kjkent commented 1 year ago

@vgibilmanno thanks for the explanation -- unfortunately I was locked out of doing that by a perpetual deleting status! All hope was not lost -- @deathmarine's script (thank you!) actually worked wonders; in ten mins, two days of trying to fix this was over!

StacyCash commented 1 year ago

I didn't get around to trying the other options, but I did just try doing it again in the portal (it was still on deleting after a month or more) and it was super quick again (<30 seconds). So I don't know if something has been fixed in the background...

vienleidl commented 1 year ago

I didn't get around to trying the other options, but I did just try doing it again in the portal (it was still on deleting after a month or more) and it was super quick again (<30 seconds). So I don't know if something has been fixed in the background...

Me, too! I've just tried again, it works, deleted in 20 seconds.

Reshmi-Sriram commented 1 year ago

This issue should now be fixed. Let us know if you still face issues. Thanks for being patient!

seidnerj commented 4 months ago

@Reshmi-Sriram Dealing with this issue as well, two years laters, even opened a support ticket. Our website is down, can't do anything... am also running the script pasted above and getting internal errors from Azure's API. Can't delete the custom domains, can't delete the Static Web App. Please help!

Screenshot 2024-05-12 at 21 01 04