Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling for 404 responses from Azure on App Services #3198

Merged
merged 4 commits into from
Apr 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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