Skip to content

Commit

Permalink
AppInsights: working around a breaking API change. (#1769)
Browse files Browse the repository at this point in the history
Fixes #1762
  • Loading branch information
tombuildsstuff authored Aug 15, 2018
1 parent 8e02944 commit 611746e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions azurerm/resource_arm_application_insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,19 @@ func resourceArmApplicationInsightsCreateOrUpdate(d *schema.ResourceData, meta i
Tags: expandTags(tags),
}

_, err := client.CreateOrUpdate(ctx, resGroup, name, insightProperties)
resp, err := client.CreateOrUpdate(ctx, resGroup, name, insightProperties)
if err != nil {
return err
// @tombuildsstuff - from 2018-08-14 the Create call started returning a 201 instead of 200
// which doesn't match the Swagger - this works around it until that's fixed
// BUG: https://github.com/Azure/azure-sdk-for-go/issues/2465
if resp.StatusCode != http.StatusCreated {
return fmt.Errorf("Error creating Application Insights %q (Resource Group %q): %+v", name, resGroup, err)
}
}

read, err := client.Get(ctx, resGroup, name)
if err != nil {
return err
return fmt.Errorf("Error retrieving Application Insights %q (Resource Group %q): %+v", name, resGroup, err)
}
if read.ID == nil {
return fmt.Errorf("Cannot read AzureRM Application Insights '%s' (Resource Group %s) ID", name, resGroup)
Expand Down

0 comments on commit 611746e

Please sign in to comment.