Azure Messaging Consumer Group

This page shows how to write Terraform and Azure Resource Manager for Messaging Consumer Group and write them securely.

azurerm_eventhub_consumer_group (Terraform)

The Consumer Group in Messaging can be configured in Terraform with the resource name azurerm_eventhub_consumer_group. The following sections describe 9 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L51
resource "azurerm_eventhub_consumer_group" "hcaas1" {
  name                = "testConsumerGroup"
  namespace_name      = azurerm_eventhub_namespace.mqkconnector.name
  eventhub_name       = azurerm_eventhub.providertesttpk1.name
  resource_group_name = azurerm_resource_group.mqktest.name
  user_metadata       = "some-meta-data-1"
main.tf#L57
resource "azurerm_eventhub_consumer_group" "language_detector_group" {
  name                = "language-detector-consumer"
  namespace_name      = azurerm_eventhub_namespace.project_event_hub_ns.name
  eventhub_name       = azurerm_eventhub.reddit_messages_event_hub.name
  resource_group_name = azurerm_resource_group.project_group_storage.name
}
main.tf#L65
resource "azurerm_eventhub_consumer_group" "fe_consumer_group" {
  for_each            = toset(var.topics)
  name                = "frontend"
  namespace_name      = azurerm_eventhub_namespace.eventhubs.name
  eventhub_name       = each.key
  resource_group_name = var.resource_group_name
eventhub-notification.tf#L11
resource "azurerm_eventhub_consumer_group" "notifications_notifier_appinsights" {
  name                = "appinsights"
  namespace_name      = azurerm_eventhub_namespace.ehns.name
  eventhub_name       = azurerm_eventhub.notifications.name
  resource_group_name = azurerm_resource_group.rg.name
}
consumer_groups.tf#L2
resource "azurerm_eventhub_consumer_group" "evhcg" {
  name                = var.settings.name
  namespace_name      = var.namespace_name
  eventhub_name       = var.eventhub_name
  resource_group_name = var.resource_group_name
  user_metadata       = var.settings.user_metadata
r-eventhub-consumer-group.tf#L1
resource "azurerm_eventhub_consumer_group" "eventhub_consumer_group" {
  for_each            = toset(local.hubs_list)
  name                = lookup(var.eventhub_namespaces_hubs[split("|", each.key)[0]]["hubs"][split("|", each.key)[1]], "consumer_group", "default")
  namespace_name      = local.namespace_name
  eventhub_name       = split("|", each.key)[1]
  resource_group_name = var.resource_group_name
consumer_groups.tf#L14
resource "azurerm_eventhub_consumer_group" "evhcg" {
  name                = azurecaf_name.evhcg_name.result
  namespace_name      = var.namespace_name
  eventhub_name       = var.eventhub_name
  resource_group_name = var.resource_group_name
  user_metadata       = try(var.settings.user_metadata, null)
r.eventhub_consumer_groups.tf#L13
resource "azurerm_eventhub_consumer_group" "eventhub_consumer_group" {
  for_each = { for cg in local.consumer_groups : cg.eh_name => cg }

  name                = each.value.name
  namespace_name      = azurerm_eventhub_namespace.eventhub_ns.name
  eventhub_name       = azurerm_eventhub.eventhub[each.value.eh_name].name
consumer_groups.tf#L14
resource "azurerm_eventhub_consumer_group" "evhcg" {
  name                = azurecaf_name.evhcg_name.result
  namespace_name      = var.namespace_name
  eventhub_name       = var.eventhub_name
  resource_group_name = var.resource_group_name
  user_metadata       = try(var.settings.user_metadata, null)

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages a Event Hubs Consumer Group as a nested resource within an Event Hub.

Microsoft.EventHub/namespaces/eventhubs/consumerGroups (Azure Resource Manager)

The namespaces/eventhubs/consumerGroups in Microsoft.EventHub can be configured in Azure Resource Manager with the resource name Microsoft.EventHub/namespaces/eventhubs/consumerGroups. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.

Frequently asked questions

What is Azure Messaging Consumer Group?

Azure Messaging Consumer Group is a resource for Messaging of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Messaging Consumer Group?

For Terraform, the rajuraghavan69/spring-boot-petclinic, DanyloKiral/cloud-platforms-project and chesapeaketechnology/data-science source code examples are useful. See the Terraform Example section for further details.