Skip to content

Commit

Permalink
Merge pull request #3198 from IanMoroney/patch-1
Browse files Browse the repository at this point in the history
Error handling for 404 responses from Azure on App Services
  • Loading branch information
tombuildsstuff authored Apr 6, 2019
2 parents eefa81a + e203268 commit e3c9929
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions azurerm/resource_arm_app_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,21 @@ func resourceArmAppServiceRead(d *schema.ResourceData, meta interface{}) error {

configResp, err := client.GetConfiguration(ctx, resGroup, name)
if err != nil {
if utils.ResponseWasNotFound(configResp.Response) {
log.Printf("[DEBUG] Configuration of App Service %q (resource group %q) was not found", name, resGroup)
d.SetId("")
return nil
}
return fmt.Errorf("Error making Read request on AzureRM App Service Configuration %q: %+v", name, err)
}

appSettingsResp, err := client.ListApplicationSettings(ctx, resGroup, name)
if err != nil {
if utils.ResponseWasNotFound(appSettingsResp.Response) {
log.Printf("[DEBUG] Application Settings of App Service %q (resource group %q) were not found", name, resGroup)
d.SetId("")
return nil
}
return fmt.Errorf("Error making Read request on AzureRM App Service AppSettings %q: %+v", name, err)
}

Expand Down
10 changes: 10 additions & 0 deletions azurerm/resource_arm_app_service_slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,21 @@ func resourceArmAppServiceSlotRead(d *schema.ResourceData, meta interface{}) err

configResp, err := client.GetConfigurationSlot(ctx, resGroup, appServiceName, slot)
if err != nil {
if utils.ResponseWasNotFound(configResp.Response) {
log.Printf("[DEBUG] Configuration of App Service Slot %q/%q (resource group %q) was not found", appServiceName, slot, resGroup)
d.SetId("")
return nil
}
return fmt.Errorf("Error making Read request on AzureRM App Service Slot Configuration %q/%q: %+v", appServiceName, slot, err)
}

appSettingsResp, err := client.ListApplicationSettingsSlot(ctx, resGroup, appServiceName, slot)
if err != nil {
if utils.ResponseWasNotFound(appSettingsResp.Response) {
log.Printf("[DEBUG] Application Settings of App Service Slot %q/%q (resource group %q) were not found", appServiceName, slot, resGroup)
d.SetId("")
return nil
}
return fmt.Errorf("Error making Read request on AzureRM App Service Slot AppSettings %q/%q: %+v", appServiceName, slot, err)
}

Expand Down

0 comments on commit e3c9929

Please sign in to comment.