diff --git a/internal/services/applications/application_resource.go b/internal/services/applications/application_resource.go index c1cc4d8ae7..da8dbfab2e 100644 --- a/internal/services/applications/application_resource.go +++ b/internal/services/applications/application_resource.go @@ -1241,6 +1241,7 @@ func applicationResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, m // Attempt to patch the newly created application and set the display name, which will tell us whether it exists yet, then set it back to the desired value. // The SDK handles retries for us here in the event of 404, 429 or 5xx, then returns after giving up. + // Due to an unusual implementation on this service, the retry function also retries on 409. See https://github.com/hashicorp/terraform-provider-azuread/issues/1764#issuecomment-3282278691 for more information. uid, err := uuid.GenerateUUID() if err != nil { return tf.ErrorDiagF(err, "Failed to generate a UUID") diff --git a/internal/services/applications/applications.go b/internal/services/applications/applications.go index 3ca1b95116..d80696199f 100644 --- a/internal/services/applications/applications.go +++ b/internal/services/applications/applications.go @@ -27,7 +27,8 @@ import ( func applicationUpdateRetryFunc() client.RequestRetryFunc { return func(resp *http.Response, o *odata.OData) (bool, error) { - if response.WasNotFound(resp) { + // inconsistent state on this resource can result in a 409 Conflict being returned, in this exception case we retry as per the service design, see https://github.com/hashicorp/terraform-provider-azuread/issues/1764#issuecomment-3282278691 for more information. + if response.WasNotFound(resp) || response.WasConflict(resp) { return true, nil } else if response.WasBadRequest(resp) && o != nil && o.Error != nil { return o.Error.Match("Permission (scope or role) cannot be deleted or updated unless disabled first"), nil