I need to remove webapps from deleted items, which seen after Get-AzDeletedWebApp pwsh command

Aliaksandr Urbanovich1 0 Reputation points

Hi All
Ive got 2 different Azure Directories with different subscriptions: Dir1 and Dir2; Subscription1 and Subcription2.
Under Dir1 and Subscription1 was created WebApp1. Then it was deleted.
Now Im trying to create under Dir2 and Subscription2 web application with the same name WebApp1, but its not permitted. Ive found, that those deleted web apps are stored for 30 days under /providers/Microsoft.Web/deletedSites/ (Get-AzDeletedWebApp powershell command)

My question is - how can I force those deletion, as firstly created web app under Dir1 and Subscription1 was created by mistake.

Thanks for all replies.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
5,681 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
553 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Grmacjon-MSFT 11,826 Reputation points

    Hi @Aliaksandr Urbanovich1 thanks for the question.

    one way to force the deletion of the WebApp1 that was created under Dir1 and Subscription1, is to use the Remove-AzResource PowerShell command. before using this command ensure that you have the necessary permissions to delete the web app.

    Here are the steps you can follow:

    1. Connect to the Azure portal using PowerShell and switch to the subscription where the WebApp1 was created:
        powershellCopy code
    Set-AzContext -SubscriptionId <SubscriptionId>
    1. Retrieve the deleted WebApp1 using the Get-AzDeletedWebApp command:
    powershellCopy code
    $deletedWebApp = Get-AzDeletedWebApp -ResourceGroupName <ResourceGroupName> -Name WebApp1
    Replace <ResourceGroupName> with the name of the resource group where the WebApp1 was created.
    1. Remove the deleted WebApp1 using the Remove-AzResource command:
        powershellCopy code
        Remove-AzResource -ResourceId $deletedWebApp.ResourceId -Force
        This will permanently delete the WebApp1 and free up the name for you to use again under Dir2 and Subscription2.
    A few important things to note:
    -the Remove-AzResource command is a powerful command that can delete any Azure resource, so ***make sure*** you have the correct resource ID before running this command. 
    -it may take a few minutes for the resource to be fully deleted.
    -once a web app is deleted, it **cannot** be recovered. Therefore, ensure that you have backed up any important data before deleting the web app. [Deleted apps are purged from the system 30 days](https://learn.microsoft.com/en-us/troubleshoot/azure/app-service/create-delete-resources-faq) after initial deletion. 
    Hope that helps

  2. Bart Huls 0 Reputation points

    Wow i'm totally shocked that you can't delete the AppService
    How about migrating WebServices from a tentant to an other tentant...

    0 comments No comments