# Deleted My Web App and App Service Plan, Whats Next ?

![Rock Garden,Darjeeling,India](/files/-McxgA3DtZK3yudrzfgN)

As a human being we all can do mistakes. There for we can delete production grade Azure Web App accidentally. Sometimes this scenarios can be happen when hacker penetrate the Azure subscription credentials and get control, and intentionally delete production Web App.

So whats happen now. What if we want to recover it quickly. Earlier we need to submit a support ticket to Azure to restore Azure Web App and it take hours if you don’t have premier support. But introduction of **Azure App Service Web App Undelete** we can restore the app without any support plan.

**YES** you can imagine how cool it was right. Lets see how we can do it.

Deleted Web apps are stored in Subscription base so if you have multiple subscription first we need to select right subscription for that we can use following Azure PowerShell commands

```
#Login to Azure PowerShell
Login-AzureRmAccount#Select Azure Subscription
Select-AzureRmSubscription -Subscription "<SubName>"
```

Make sure you have the latest version of Azure Powershell Module AzureRM.Websites 5.1.0

```
#Get Azure RM Powershell Module Version
Get-Module -Name AzureRM.Websites#Get Latest PowerShell Module
Install-Module -Name AzureRM.Websites -RequiredVersion 5.1.0
```

Before this demo I created a Web app and deleted from my Resource Group name DeleteWebapp. So lets see the deleted Web App (Times are in UTC)

```
#Get Deleted Web App
Get-AzureRmDeletedWebApp -ResourceGroupName DeleteWebapp
```

![](https://miro.medium.com/max/60/1*BLEtKxFtPlzluIEDJIyEOQ.png?q=20)![](https://miro.medium.com/max/554/1*BLEtKxFtPlzluIEDJIyEOQ.png)

Next I’ll create PS variable to store the deleted app details

```
#Store As a Variable
$deletedApp= Get-AzureRmDeletedWebApp -ResourceGroupName DeleteWebapp
```

![](https://miro.medium.com/max/60/1*Esf1FWOZzmU0jT4KSLkKHw.png?q=20)![](https://miro.medium.com/max/622/1*Esf1FWOZzmU0jT4KSLkKHw.png)

We will create a new Resource group to restore this app, then create an App Service Plan to restore the deleted app. **NOTE — Make Sure the App service Plan is Basic or higher tire restoring feature is not supported for free tier**

```
#Create new Resource Group for Web App restore 
New-AzureRmResourceGroup -Name WebAppRestore -Location "Central US"#Create an App Service Plan 
New-AzureRmAppServicePlan -Location "Central US" -Tier Standard -Name WebAppRestoreAppPlan -ResourceGroupName WebAppRestore
```

![](https://miro.medium.com/max/60/1*wU-FOENytXj751FyaJhfrw.png?q=20)![](https://miro.medium.com/max/1129/1*wU-FOENytXj751FyaJhfrw.png)

Lets restore deleted web app to the newly created App Service plan. For that previous step we sore the details of the deleted web app as a variable, we can use that variable to restore the web app.

```
#restore the web App
$deletedApp | Restore-AzureRmDeletedWebApp -TargetResourceGroupName WebAppRestore -TargetAppServicePlanName WebAppRestoreAppPlan
```

![](https://miro.medium.com/max/60/1*EC3N6AVdAi43FIj6vGzivg.png?q=20)![](https://miro.medium.com/max/1149/1*EC3N6AVdAi43FIj6vGzivg.png)

If you have done this correctly you can see that the web app state is running at shell and portal we can see the app running![](https://miro.medium.com/max/60/1*JX4fDatPAayyE1UwiYto9Q.png?q=20)![](https://miro.medium.com/max/1541/1*JX4fDatPAayyE1UwiYto9Q.png)

**NOTE — We can restore deleted web apps up to 30 days from deletion date, and its compliant with GDPR. As per the GDPR it can’t keep customer data more than 30 days**[<br>](https://kasunrajapakse.me/?source=post_sidebar--------------------------post_sidebar-----------)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ak2019cs.gitbook.io/aditya-kumar/deleted-my-web-app-and-app-service-plan-whats-next.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
