|
| 1 | +--- |
| 2 | +title: Configure properties for an Azure event hub |
| 3 | +description: Learn how to configure status, partition count, cleanup policy, and retention time for an event hub |
| 4 | +ms.topic: how-to |
| 5 | +ms.custom: log-compaction |
| 6 | +ms.date: 06/19/2023 |
| 7 | +--- |
| 8 | + |
| 9 | +# Configure properties for an event hub |
| 10 | +This article shows you how to configure properties such as status, partition count, retention time, etc. for an event hub. |
| 11 | + |
| 12 | +## Configure status |
| 13 | +You can update the status of an event hub to one of these values on the **Properties** page after the event hub is created. |
| 14 | + |
| 15 | +- Select **Active** (default) if you want to send events to and receive events from an event hub. |
| 16 | +- Select **Disabled** if you want to disable both sending and receiving events from an event hub. |
| 17 | +- Select **SendDisabled** if you want to disable sending events to an event hub. |
| 18 | + |
| 19 | + :::image type="content" source="./media/configure-event-hub-properties/properties-page.png" alt-text="Screenshot showing the Properties page for an event hub."::: |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +## Configure partition count |
| 24 | +The **Properties** page allows you to see the number of partitions in an event hub for event hubs in all tiers. It allows you to update the partition count for event hubs in a premium or dedicated tier. For other tiers, you can only specify the partition count at the time of creating an event hub. To learn about partitions in Event Hubs, see [Scalability](event-hubs-scalability.md#partitions) |
| 25 | + |
| 26 | +### Configure cleanup policy |
| 27 | +You see the cleanup policy for an event hub on the **Properties** page. You can't update it. By default, an event hub is created with the **delete** cleanup policy, where events are purged upon the expiration of the retention time. While creating an event hub, you can set the cleanup policy to **Compact**. For more information, see [Log compaction](log-compaction.md) and [Configure log compaction](use-log-compaction.md). |
| 28 | + |
| 29 | + |
| 30 | +## Configure retention time |
| 31 | + |
| 32 | +If the cleanup policy is set to **Delete**, the **retention time** is the maximum time that Event Hubs retains an event before discarding the event. The **Properties** page allows you to specify retention time in hours. |
| 33 | + |
| 34 | +If the cleanup policy is set to **Compact** at the time of creating an event hub, the **infinite retention time** is automatically enabled. You can set the **Tombstone retention time in hours** though. Client applications can mark existing events of an event hub to be deleted during a compaction job by sending a new event with an existing key and a `null` event payload. These markers are known as **Tombstones**. The **Tombstone retention time in hours** is the time to retain tombstone markers in a compacted event hub. |
| 35 | + |
| 36 | +## Azure CLI |
| 37 | +Use the [`az eventhubs eventhub update`](/cli/azure/eventhubs/eventhub#az-eventhubs-eventhub-update) command to configure partition count and retention settings for an event hub. |
| 38 | + |
| 39 | +- Use the `--status` parameter to set the status of an existing event hub to `Active`, `Disabled`, or `SendDisabled` or `ReceiveDisabled`. |
| 40 | +- Use `--partition-count` parameter to specify the number of partitions. You can specify the partition count for an existing event hub only if it's in the premium or dedicated tier namespace. |
| 41 | +- Use the `--retention-time` to specify the number of hours to retain events for an event hub, if the `cleanupPolicy` is `Delete`. |
| 42 | +- Use the `--tombstone-retention-time-in-hours` to specify the number of hours to retain the tombstone markers, if the `cleanupPolicy` is `Compact`. |
| 43 | + |
| 44 | + |
| 45 | +## Azure PowerShell |
| 46 | +Use the [`Set-AzEventHub`](/powershell/module/az.eventhub/set-azeventhub) by using the `-Status`, `-RetentionTimeInHour` or `TomstoneRetentionTimeInHour` parameters. Currently, the PowerShell command doesn't support updating the partition count for an event hub. |
| 47 | + |
| 48 | +## Azure Resource Manager template |
| 49 | + |
| 50 | +If you're using an Azure Resource Manager template, use the `partitionCount` and `retentionTimeinHours` as shown in the following example. `MYNAMESPACE` is the name of the Event Hubs namespace and `MYEVENTHUB` is the name of the event hub in this example. |
| 51 | + |
| 52 | +```json |
| 53 | +{ |
| 54 | + "type": "Microsoft.EventHub/namespaces/eventhubs", |
| 55 | + "apiVersion": "2022-10-01-preview", |
| 56 | + "name": "MYNAMESPACE/MYEVENTHUB ", |
| 57 | + "properties": { |
| 58 | + "partitionIds": [], |
| 59 | + "partitionCount": 1, |
| 60 | + "captureDescription": null, |
| 61 | + "retentionDescription": { |
| 62 | + "cleanupPolicy": "Delete", |
| 63 | + "retentionTimeInHours": 1 |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +## Next steps |
| 70 | +See the following articles: |
| 71 | + |
| 72 | +- [Scalability](event-hubs-scalability.md#partitions) |
| 73 | +- [Log compaction](log-compaction.md) and [Configure log compaction](use-log-compaction.md)- |
0 commit comments