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

Aliaksandr Urbanovich1 20 Reputation points
2023-03-17T08:26:16.7833333+00:00

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.
6,875 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
762 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Grmacjon-MSFT 15,856 Reputation points
    2023-03-23T18:50:43.8666667+00:00

    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
        Connect-AzAccount
    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
    
    -Grace
    
    

  2. Bart Huls 0 Reputation points
    2023-09-11T19:15:12.0333333+00:00

    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