title: Error "Cannot modify this web hosting plan because another operation is in progress" Azure Powershell
body: <p>We are using Powershell SDK to write our infrastructure as code in Azure. For the DEV instance, we are deleting the Resource group first and then completely provision and redeploy our application.</p>
  
  <p>Doing that I get often the error message "Cannot modify this web hosting plan because another operation is in progress". A workaround is to add a Sleep after this command and then hope its done continue with the script. </p>
  
  <pre><code>Get-AzureRmResourceGroup -Name $ResourceGroupName -ErrorVariable GetResourceGroupError -ErrorAction SilentlyContinue
  if(!$GetResourceGroupError -and $PeformCleanDeployment)
  {
      Write-Output "Removing resources group..."
      Remove-AzureRmResourceGroup -Name $ResourceGroupName -Force
      do
      {
          Write-Output "Waiting until resource group is deleted..."
          Get-AzureRmResourceGroup -Name $ResourceGroupName -ErrorVariable GetResourceGroupError -ErrorAction SilentlyContinue
          Start-Sleep 30
      } while (!$GetResourceGroupError)
  }
  </code></pre>
  
  <p>But this is not working. I still get the error.</p>
  
  <p>What is the recommended way doing this? Is there an option to ensure the Resource Group is Really gone? </p>
  
  <p>My Resource Group contains a webapp, serviceplan and a postgres database.</p>
  
  <p>Error message I get</p>
  
  <pre><code>Removing resources group...
  True
  Waiting until resource group is deleted...
  Wait ----
  Creating resources...
  ResourceGroupName : ####################
  Location          : westeurope
  ProvisioningState : Succeeded
  Tags              :
  ResourceId        : ####################
  
  New-AzureRmAppServicePlan : Cannot modify this web hosting plan because another operation is in progress. Details: Id:
  ########################, OperationName: Delete, CreatedTime: 10/4/2017 8:32:32 AM, RequestId:
  </code></pre>
  
  <p>Cheers</p>