2016-10-03 12:22:18 +02:00
---
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_servicebus_subscription"
sidebar_current: "docs-azurerm-resource-servicebus-subscription"
description: |-
Create a ServiceBus Subscription.
---
# azurerm\_servicebus\_subscription
Create a ServiceBus Subscription.
## Example Usage
2017-04-17 12:17:54 +02:00
```hcl
2016-10-03 12:22:18 +02:00
resource "azurerm_resource_group" "test" {
2017-02-18 23:48:50 +01:00
name = "resourceGroup1"
location = "West US"
2016-10-03 12:22:18 +02:00
}
resource "azurerm_servicebus_namespace" "test" {
2017-02-18 23:48:50 +01:00
name = "acceptanceTestServiceBusNamespace"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "standard"
tags {
environment = "Production"
}
2016-10-03 12:22:18 +02:00
}
resource "azurerm_servicebus_topic" "test" {
2017-02-18 23:48:50 +01:00
name = "testTopic"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
2016-10-03 12:22:18 +02:00
2017-02-18 23:48:50 +01:00
enable_partitioning = true
2016-10-03 12:22:18 +02:00
}
resource "azurerm_servicebus_subscription" "test" {
2017-02-18 23:48:50 +01:00
name = "testSubscription"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
topic_name = "${azurerm_servicebus_topic.test.name}"
max_delivery_count = 1
2016-10-03 12:22:18 +02:00
}
```
## Argument Reference
The following arguments are supported:
* `name` - (Required) Specifies the name of the ServiceBus Subscription resource.
Changing this forces a new resource to be created.
* `namespace_name` - (Required) The name of the ServiceBus Namespace to create
this Subscription in. Changing this forces a new resource to be created.
* `topic_name` - (Required) The name of the ServiceBus Topic to create
this Subscription in. Changing this forces a new resource to be created.
* `location` - (Required) Specifies the supported Azure location where the resource exists.
Changing this forces a new resource to be created.
* `resource_group_name` - (Required) The name of the resource group in which to
create the namespace. Changing this forces a new resource to be created.
* `max_delivery_count` - (Required) The maximum number of deliveries.
* `auto_delete_on_idle` - (Optional) The idle interval after which the
Subscription is automatically deleted, minimum of 5 minutes. Provided in the
[TimeSpan ](#timespan-format ) format.
2017-02-18 23:48:50 +01:00
* `default_message_ttl` - (Optional) The TTL of messages sent to this Subscription
2016-10-03 12:22:18 +02:00
if no TTL value is set on the message itself. Provided in the [TimeSpan ](#timespan-format )
format.
* `lock_duration` - (Optional) The lock duration for the subscription, maximum
supported value is 5 minutes. Defaults to 1 minute.
* `dead_lettering_on_filter_evaluation_exceptions` - (Optional) Boolean flag which
controls whether the Subscription has dead letter support on Filter evaluation
exceptions. Defaults to false.
* `dead_lettering_on_message_expiration` - (Optional) Boolean flag which controls
whether the Subscription has dead letter support when a message expires. Defaults
to false.
* `enable_batched_operations` - (Optional) Boolean flag which controls whether the
Subscription supports batched operations. Defaults to false.
* `requires_session` - (Optional) Boolean flag which controls whether this Subscription
supports the concept of a session. Defaults to false. Changing this forces a
new resource to be created.
### TimeSpan Format
Some arguments for this resource are required in the TimeSpan format which is
2017-05-24 12:31:52 +02:00
used to represent a length of time. The supported format is documented [here ](https://msdn.microsoft.com/en-us/library/se73z7b9(v=vs.110 ).aspx#Anchor_2)
2016-10-03 12:22:18 +02:00
## Attributes Reference
The following attributes are exported:
* `id` - The ServiceBus Subscription ID.
2016-11-22 13:13:11 +01:00
## Import
2017-02-18 23:48:50 +01:00
Service Bus Subscriptions can be imported using the `resource id` , e.g.
2016-11-22 13:13:11 +01:00
```
terraform import azurerm_servicebus_subscription.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.servicebus/namespaces/sbns1/topics/sntopic1/subscriptions/sbsub1
2017-05-24 12:31:52 +02:00
```