From 40834d55eecdf2f6632c0860cb0dbbaa00742f21 Mon Sep 17 00:00:00 2001 From: Chang Li Date: Thu, 14 Jun 2018 08:21:39 +0800 Subject: [PATCH 1/3] enable_partitioning not supported servicebus Premium Sku. --- azurerm/resource_arm_servicebus_queue.go | 7 +++---- azurerm/resource_arm_servicebus_queue_test.go | 4 ++-- azurerm/resource_arm_servicebus_topic.go | 13 +++++++++++++ azurerm/resource_arm_servicebus_topic_test.go | 6 +++--- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/azurerm/resource_arm_servicebus_queue.go b/azurerm/resource_arm_servicebus_queue.go index a4986c980771..95c8a5052346 100644 --- a/azurerm/resource_arm_servicebus_queue.go +++ b/azurerm/resource_arm_servicebus_queue.go @@ -166,10 +166,9 @@ func resourceArmServiceBusQueueCreateUpdate(d *schema.ResourceData, meta interfa return nsErr } - // Enforce Premium namespace to have partitioning enabled in Terraform. It is always enabled in Azure for - // Premium SKU. - if namespace.Sku.Name == servicebus.Premium && !d.Get("enable_partitioning").(bool) { - return fmt.Errorf("ServiceBus Queue (%s) must have Partitioning enabled for Premium SKU", name) + // In a Premium tier namespace, partitioning entities is not supported. + if namespace.Sku.Name == servicebus.Premium && d.Get("enable_partitioning").(bool) { + return fmt.Errorf("ServiceBus Queue (%s) does not support Partitioning enabled for Premium SKU", name) } // Enforce Premium namespace to have Express Entities disabled in Terraform since they are not supported for diff --git a/azurerm/resource_arm_servicebus_queue_test.go b/azurerm/resource_arm_servicebus_queue_test.go index 5e92900127e4..11e5c2a53b0c 100644 --- a/azurerm/resource_arm_servicebus_queue_test.go +++ b/azurerm/resource_arm_servicebus_queue_test.go @@ -108,7 +108,7 @@ func TestAccAzureRMServiceBusQueue_defaultEnablePartitioningPremium(t *testing.T Config: config, Check: resource.ComposeTestCheckFunc( testCheckAzureRMServiceBusQueueExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "enable_partitioning", "true"), + resource.TestCheckResourceAttr(resourceName, "enable_partitioning", "false"), resource.TestCheckResourceAttr(resourceName, "enable_express", "false"), ), }, @@ -331,7 +331,7 @@ resource "azurerm_servicebus_queue" "test" { name = "acctestservicebusqueue-%d" resource_group_name = "${azurerm_resource_group.test.name}" namespace_name = "${azurerm_servicebus_namespace.test.name}" - enable_partitioning = true + enable_partitioning = false enable_express = false } `, rInt, location, rInt, rInt) diff --git a/azurerm/resource_arm_servicebus_topic.go b/azurerm/resource_arm_servicebus_topic.go index 4121bda84f5d..afc205f4daf1 100644 --- a/azurerm/resource_arm_servicebus_topic.go +++ b/azurerm/resource_arm_servicebus_topic.go @@ -151,6 +151,19 @@ func resourceArmServiceBusTopicCreate(d *schema.ResourceData, meta interface{}) parameters.SBTopicProperties.DuplicateDetectionHistoryTimeWindow = utils.String(duplicateWindow) } + // We need to retrieve the namespace because Premium namespace works differently from Basic and Standard, + // so it needs different rules applied to it. + namespacesClient := meta.(*ArmClient).serviceBusNamespacesClient + namespace, nsErr := namespacesClient.Get(ctx, resourceGroup, namespaceName) + if nsErr != nil { + return nsErr + } + + // In a Premium tier namespace, partitioning entities is not supported. + if namespace.Sku.Name == servicebus.Premium && d.Get("enable_partitioning").(bool) { + return fmt.Errorf("ServiceBus Queue (%s) does not support Partitioning enabled for Premium SKU", name) + } + _, err := client.CreateOrUpdate(ctx, resourceGroup, namespaceName, name, parameters) if err != nil { return err diff --git a/azurerm/resource_arm_servicebus_topic_test.go b/azurerm/resource_arm_servicebus_topic_test.go index a1930296d46f..33146c282ccf 100644 --- a/azurerm/resource_arm_servicebus_topic_test.go +++ b/azurerm/resource_arm_servicebus_topic_test.go @@ -165,7 +165,7 @@ func TestAccAzureRMServiceBusTopic_enablePartitioningPremium(t *testing.T) { { Config: postConfig, Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, "enable_partitioning", "true"), + resource.TestCheckResourceAttr(resourceName, "enable_partitioning", "false"), resource.TestCheckResourceAttr(resourceName, "max_size_in_megabytes", "81920"), ), }, @@ -349,7 +349,7 @@ resource "azurerm_servicebus_topic" "test" { name = "acctestservicebustopic-%d" namespace_name = "${azurerm_servicebus_namespace.test.name}" resource_group_name = "${azurerm_resource_group.test.name}" - enable_partitioning = true + enable_partitioning = false } `, rInt, location, rInt, rInt) } @@ -397,7 +397,7 @@ resource "azurerm_servicebus_topic" "test" { name = "acctestservicebustopic-%d" namespace_name = "${azurerm_servicebus_namespace.test.name}" resource_group_name = "${azurerm_resource_group.test.name}" - enable_partitioning = true + enable_partitioning = false max_size_in_megabytes = 81920 } `, rInt, location, rInt, rInt) From f01e55538164b7a6bd528afef105ab0d273cf775 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Mon, 2 Jul 2018 16:00:36 +0200 Subject: [PATCH 2/3] Updating the docs to mention the change at Azure's end No longer failing if the sku is premium to allow for existing resources --- azurerm/resource_arm_servicebus_queue.go | 11 +++-------- azurerm/resource_arm_servicebus_topic.go | 15 +-------------- website/docs/r/servicebus_queue.html.markdown | 2 +- website/docs/r/servicebus_topic.html.markdown | 2 ++ 4 files changed, 7 insertions(+), 23 deletions(-) diff --git a/azurerm/resource_arm_servicebus_queue.go b/azurerm/resource_arm_servicebus_queue.go index 95c8a5052346..8c94833e09d9 100644 --- a/azurerm/resource_arm_servicebus_queue.go +++ b/azurerm/resource_arm_servicebus_queue.go @@ -161,14 +161,9 @@ func resourceArmServiceBusQueueCreateUpdate(d *schema.ResourceData, meta interfa // We need to retrieve the namespace because Premium namespace works differently from Basic and Standard, // so it needs different rules applied to it. namespacesClient := meta.(*ArmClient).serviceBusNamespacesClient - namespace, nsErr := namespacesClient.Get(ctx, resourceGroup, namespaceName) - if nsErr != nil { - return nsErr - } - - // In a Premium tier namespace, partitioning entities is not supported. - if namespace.Sku.Name == servicebus.Premium && d.Get("enable_partitioning").(bool) { - return fmt.Errorf("ServiceBus Queue (%s) does not support Partitioning enabled for Premium SKU", name) + namespace, err := namespacesClient.Get(ctx, resourceGroup, namespaceName) + if err != nil { + return fmt.Errorf("Error retrieving ServiceBus Namespace %q (Resource Group %q): %+v", resourceGroup, namespaceName, err) } // Enforce Premium namespace to have Express Entities disabled in Terraform since they are not supported for diff --git a/azurerm/resource_arm_servicebus_topic.go b/azurerm/resource_arm_servicebus_topic.go index afc205f4daf1..45ab5ba836c9 100644 --- a/azurerm/resource_arm_servicebus_topic.go +++ b/azurerm/resource_arm_servicebus_topic.go @@ -151,19 +151,6 @@ func resourceArmServiceBusTopicCreate(d *schema.ResourceData, meta interface{}) parameters.SBTopicProperties.DuplicateDetectionHistoryTimeWindow = utils.String(duplicateWindow) } - // We need to retrieve the namespace because Premium namespace works differently from Basic and Standard, - // so it needs different rules applied to it. - namespacesClient := meta.(*ArmClient).serviceBusNamespacesClient - namespace, nsErr := namespacesClient.Get(ctx, resourceGroup, namespaceName) - if nsErr != nil { - return nsErr - } - - // In a Premium tier namespace, partitioning entities is not supported. - if namespace.Sku.Name == servicebus.Premium && d.Get("enable_partitioning").(bool) { - return fmt.Errorf("ServiceBus Queue (%s) does not support Partitioning enabled for Premium SKU", name) - } - _, err := client.CreateOrUpdate(ctx, resourceGroup, namespaceName, name, parameters) if err != nil { return err @@ -227,7 +214,7 @@ func resourceArmServiceBusTopicRead(d *schema.ResourceData, meta interface{}) er // if the topic is in a premium namespace and partitioning is enabled then the // max size returned by the API will be 16 times greater than the value set - if *props.EnablePartitioning { + if partitioning := props.EnablePartitioning; partitioning != nil && *partitioning { namespacesClient := meta.(*ArmClient).serviceBusNamespacesClient namespace, err := namespacesClient.Get(ctx, resourceGroup, namespaceName) if err != nil { diff --git a/website/docs/r/servicebus_queue.html.markdown b/website/docs/r/servicebus_queue.html.markdown index 7e2cfae876e2..691dfadc33a5 100644 --- a/website/docs/r/servicebus_queue.html.markdown +++ b/website/docs/r/servicebus_queue.html.markdown @@ -86,7 +86,7 @@ The following arguments are supported: a new resource to be created. Defaults to `false` for Basic and Standard. For Premium, it MUST be set to `true`. -~> **NOTE:** Service Bus Premium namespaces are always partitioned, so `enable_partitioning` MUST be set to `true`. +-> **NOTE:** Partitioning is available at entity creation for all queues and topics in Basic or Standard SKUs. It is not available for the Premium messaging SKU, but any previously existing partitioned entities in Premium namespaces continue to work as expected. Please [see the documentation](https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-partitioning) for more information. * `lock_duration` - (Optional) The ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. Maximum value is 5 minutes. Defaults to 1 minute. (`PT1M`) diff --git a/website/docs/r/servicebus_topic.html.markdown b/website/docs/r/servicebus_topic.html.markdown index 22fea453c3da..dc85d52b9991 100644 --- a/website/docs/r/servicebus_topic.html.markdown +++ b/website/docs/r/servicebus_topic.html.markdown @@ -85,6 +85,8 @@ The following arguments are supported: the topic to be partitioned across multiple message brokers. Defaults to false. Changing this forces a new resource to be created. +-> **NOTE:** Partitioning is available at entity creation for all queues and topics in Basic or Standard SKUs. It is not available for the Premium messaging SKU, but any previously existing partitioned entities in Premium namespaces continue to work as expected. Please [see the documentation](https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-partitioning) for more information. + * `max_size_in_megabytes` - (Optional) Integer value which controls the size of memory allocated for the topic. For supported values see the "Queue/topic size" section of [this document](https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-quotas). From eef8517913c1b24d94ded949b1e391a320adc626 Mon Sep 17 00:00:00 2001 From: kt Date: Mon, 2 Jul 2018 09:45:11 -0700 Subject: [PATCH 3/3] Fix minor assingment error --- azurerm/resource_arm_servicebus_queue.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_servicebus_queue.go b/azurerm/resource_arm_servicebus_queue.go index 8c94833e09d9..7676c0b65ddc 100644 --- a/azurerm/resource_arm_servicebus_queue.go +++ b/azurerm/resource_arm_servicebus_queue.go @@ -172,7 +172,7 @@ func resourceArmServiceBusQueueCreateUpdate(d *schema.ResourceData, meta interfa return fmt.Errorf("ServiceBus Queue (%s) does not support Express Entities in Premium SKU and must be disabled", name) } - _, err := client.CreateOrUpdate(ctx, resourceGroup, namespaceName, name, parameters) + _, err = client.CreateOrUpdate(ctx, resourceGroup, namespaceName, name, parameters) if err != nil { return err }