diff --git a/azurerm/resource_arm_app_service_plan.go b/azurerm/resource_arm_app_service_plan.go index 2adafa682ca1..a6655d2eb59c 100644 --- a/azurerm/resource_arm_app_service_plan.go +++ b/azurerm/resource_arm_app_service_plan.go @@ -279,6 +279,14 @@ func resourceArmAppServicePlanRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error making Read request on App Service Plan %q (Resource Group %q): %+v", name, resourceGroup, err) } + // A 404 doesn't error from the app service plan sdk so we'll add this check here to catch resource not found responses + // TODO This block can be removed if https://github.com/Azure/azure-sdk-for-go/issues/5407 gets addressed. + if utils.ResponseWasNotFound(resp.Response) { + log.Printf("[DEBUG] App Service Plan %q was not found in Resource Group %q - removnig from state!", name, resourceGroup) + d.SetId("") + return nil + } + d.Set("name", name) d.Set("resource_group_name", resourceGroup) if location := resp.Location; location != nil {