diff --git a/azurerm/resource_arm_servicebus_namespace.go b/azurerm/resource_arm_servicebus_namespace.go index 2decd619aab3..f53f4001c92f 100644 --- a/azurerm/resource_arm_servicebus_namespace.go +++ b/azurerm/resource_arm_servicebus_namespace.go @@ -3,13 +3,14 @@ package azurerm import ( "fmt" "log" + "regexp" "strings" "github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" - "regexp" ) // Default Authorization Rule/Policy created by Azure, used to populate the @@ -212,10 +213,18 @@ func resourceArmServiceBusNamespaceDelete(d *schema.ResourceData, meta interface resourceGroup := id.ResourceGroup name := id.Path["namespaces"] - _, err = client.Delete(ctx, resourceGroup, name) + future, err := client.Delete(ctx, resourceGroup, name) if err != nil { return err } + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + if response.WasNotFound(future.Response()) { + return nil + } + + return fmt.Errorf("Error deleting Service Bus %q: %+v", name, err) + } + return nil } diff --git a/azurerm/resource_arm_servicebus_namespace_test.go b/azurerm/resource_arm_servicebus_namespace_test.go index 3d681c79d96c..03fc38a5aa41 100644 --- a/azurerm/resource_arm_servicebus_namespace_test.go +++ b/azurerm/resource_arm_servicebus_namespace_test.go @@ -136,6 +136,26 @@ func TestAccAzureRMServiceBusNamespace_NonStandardCasing(t *testing.T) { }) } +func TestAccAzureRMServiceBusNamespace_premium(t *testing.T) { + resourceName := "azurerm_servicebus_namespace.test" + ri := acctest.RandInt() + config := testAccAzureRMServiceBusNamespace_premium(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceBusNamespaceDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceBusNamespaceExists(resourceName), + ), + }, + }, + }) +} + func testCheckAzureRMServiceBusNamespaceDestroy(s *terraform.State) error { client := testAccProvider.Meta().(*ArmClient).serviceBusNamespacesClient ctx := testAccProvider.Meta().(*ArmClient).StopContext @@ -221,3 +241,20 @@ resource "azurerm_servicebus_namespace" "test" { } `, rInt, location, rInt) } + +func testAccAzureRMServiceBusNamespace_premium(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_servicebus_namespace" "test" { + name = "acctestservicebusnamespace-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku = "Premium" + capacity = 1 +} +`, rInt, location, rInt) +}