╷ │ Error: creating Namespace (Subscription: "7f8e5acb-a937-4163-80b1-f874c3a4d62c" │ Resource Group Name: "nimtechnology" │ Namespace Name: "elearning-eventhub"): performing CreateOrUpdate: unexpected status 409 (409 Conflict) with error: MissingSubscriptionRegistration: The subscription is not registered to use namespace 'Microsoft.EventHub'. See https://aka.ms/rps-not-found for how to register subscriptions. │ │ with module.event-hubs-kafka.azurerm_eventhub_namespace.eventhub_namespace, │ on .terraform/modules/event-hubs-kafka/c5-eventhub-module.tf line 61, in resource "azurerm_eventhub_namespace" "eventhub_namespace": │ 61: resource "azurerm_eventhub_namespace" "eventhub_namespace" { │ ╵
Đâu tiên nếu chúng ta chưa đăng ký sử dụng Event Hub sẽ bị lỗi trên.
Chúng ta sẽ thực hiện đăng ký như sau:

Bạn tìm đến eventhub click vào:



Tiếp theo thì bạn sẽ chọn Subscription và Resource group
Namespace name nó là tên của event-hub rồi chọn region
Pricing tier: chúng ta có rất nhiều option

với từng Pricing tier chúng ta có nhưng setup khác nhau:
Với Dedicated thì chúng ta setup được cluster detail:

Với Premium chúng ta chỉ có thể setup thêm Processing Units

Với Standard thì chúng ta chỉ có setup Throughput Units
Chúng ta sẽ cùng nhau tìm hiểu CU (capacity unit), PU (processing unit), and TU (throughput unit)
Summary Table
Tier | Unit | Ingress Capacity | Egress Capacity | Max Units per Namespace |
---|---|---|---|---|
Standard | TU | Up to 1 MB/sec or 1,000 events/sec | Up to 2 MB/sec or 4,096 events/sec | 40 TUs |
Premium | PU | ~5–10 MB/sec | ~10–20 MB/sec | 16 PUs |
Dedicated | CU | ~100–200 MB/sec | ~100–200 MB/sec | 20 CUs |
Key Differences:
- Throughput Units (TU): Used in the Standard tier, suitable for general event streaming with moderate throughput needs.
- Processing Units (PU): Used in the Premium tier, providing dedicated resources for high-throughput, low-latency workloads.
- Capacity Units (CU): Used in the Dedicated tier, offering single-tenant resources for mission-critical workloads requiring high throughput.Microsoft Learn
Tiếp theo là đến tab advanced:

Phân networking chúng ta sẽ chọn public access hoặc private access:

Tiếp theo là tag và review + create

Sau đó chúng ta có 1 con event hubs:

Bạn có thể connect vào event hub thông qua domain ở đây với port 9093

và lấy passwork ở đây:
và username mặc định là $$ConnectionString


Bạn có thể kiểm tra connection như sau:
version: '3.6' services: akhq: image: tchiotludo/akhq environment: AKHQ_CONFIGURATION: | akhq: connections: eventhub-terraform: properties: bootstrap.servers: "xxx-eventhub.servicebus.windows.net:9093" security.protocol: SASL_SSL sasl.mechanism: PLAIN sasl.jaas.config: org.apache.kafka.common.security.plain.PlainLoginModule required username='$$ConnectionString' password='Endpoint=sb://xxx-eventhub.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=otArEMfGxxxxxxxxxsmQF3qrsCml+AEhHuWnAg='; ports: - "8080:8080" restart: always
module "event-hubs-kafka" { source = "azure-terraform-module/event-hubs-kafka/azure" version = "0.0.2" namespace = "elearning-eventhub" # Must be unique name resource_group_name = var.resource_group_name location = var.resource_group_location network_mode = "public" tags = { environment = "dev" project = "elearning" } }
Apply service endpoint for EventHubs.
Bạn có thể tham khảo bài viết này để hiểu hơn về Service Endpoint
Và bạn có sử thể sử dụng terraform config sau để apply:
module "event-hubs-kafka" { source = "azure-terraform-module/event-hubs-kafka/azure" version = "0.0.4" namespace = "elearning-eventhub" # Must be unique name resource_group_name = var.resource_group_name location = var.resource_group_location network_mode = "service" subnet_ids = module.vnet.subnet_ids tags = { environment = "dev" project = "elearning" } }
ở đây thì bạn cần khai báo network_mode và subnet_ids

Lúc này bạn vào kiểm tra Networking thấy hiện như trên là ok.
để Endpoint status enable thì bạn sẽ cần sang thêm subnet và chỉ định EventHubs trong phần Service.

Apply Private Endpoint to Event Hubs
Để apply private endpoint cho event hubs đầu tiên bạn nên chỉnh Public access bằng disabled.

Sau đó bạn cấu hình Private DNS rồi map với private endpoint connections.

Lúc này bạn sẽ thấy nó sẽ tạo domain private cho event hubs và nó sẽ lấy 1 IP private trong subnet.


Tất cả sẽ đơn giản nếu bạn sử dụng terraform sau:
module "event-hubs-kafka" { source = "azure-terraform-module/event-hubs-kafka/azure" version = "0.0.5" namespace = "elearning-eventhub" # Must be unique name resource_group_name = var.resource_group_name location = var.resource_group_location network_mode = "private" vnet_ids = [module.vnet.vnet_id] subnet_ids = [module.vnet.subnet_ids[1]] tags = { environment = "dev" project = "elearning" } }