# Azure Event Hubs

Type: `pubsub.azure.eventhubs`

Status: stable

Reference: https://docs.dapr.io/reference/components-reference/supported-pubsub/setup-azure-eventhubs/

## Example

```
apiVersion: cra.diagrid.io/v1beta1
kind: Component
metadata:
  name: <name>
spec:
  type: pubsub.azure.eventhubs
  version: v1
  metadata:
    # Connection string for the Event Hub or the Event Hub namespace.
    - name: connectionString
      value: "Endpoint=sb://{EventHubNamespace}.servicebus.windows.net/;SharedAccessKeyName={PolicyName};SharedAccessKey={Key};EntityPath={EventHub}"
    # The name of the Event Hubs Consumer Group to listen on.
    - name: consumerID
      value: "group1"
    # Storage account name to use for the checkpoint store.
    - name: storageAccountName
      value: "myeventhubstorage"
    # Storage container name.
    - name: storageContainerName
      value: "myeventhubstoragecontainer"
    # When set to true, will retrieve all message properties and include them in the returned event metadata (Optional)
    #- name: getAllMessageProperties
    #  value: "false"
    # Storage account key for the checkpoint store account. When using Azure AD, it is possible to omit this if the service principal has access to the storage account too. Property "storageAccountKey" is ignored when "storageConnectionString" is present (Optional)
    #- name: storageAccountKey
    #  value: "112233445566778899"
    # Connection string for the checkpoint store, alternative to specifying storageAccountKey. Property "storageAccountKey" is ignored when "storageConnectionString" is present (Optional)
    #- name: storageConnectionString
    #  value: "BlobEndpoint=https://storagesample.blob.core.windows.net;..."

```

## Authentication profiles

Available authentication profiles:

- Connection string

- Azure AD: Client credentials

- Azure AD: Client certificate

### Connection string

Authenticate using a connection string.

#### `connectionString`

**Required** - Connection string for the Event Hub or the Event Hub namespace.

Example value: `Endpoint=sb://{EventHubNamespace}.servicebus.windows.net/;SharedAccessKeyName={PolicyName};SharedAccessKey={Key};EntityPath={EventHub}`

### Azure AD: Client credentials

Authenticate using Azure AD with client credentials, also known as "service principals".

#### `azureClientId`

**Required** - Client ID (application ID)

Example value: `c7dd251f-811f-4ba2-a905-acd4d3f8f08b`

#### `azureClientSecret`

**Required** - Client secret (application password)

Example value: `Ecy3XG7zVZK3/vl/a2NSB+a1zXLa8RnMum/IgD0E`

#### `azureTenantId`

**Required** - ID of the Azure AD tenant

Example value: `cd4b2887-304c-47e1-b4d5-65447fdd542a`

#### `eventHubNamespace` (string)

**Required** - The Event Hub Namespace name.

Example value: `namespace`

#### `azureEnvironment`

Optional name for the Azure environment if using a different Azure cloud

Default value: `AzurePublicCloud`

Example value: `AzurePublicCloud`

Allowed values:

- AzurePublicCloud

- AzureChinaCloud

- AzureUSGovernmentCloud

#### `enableEntityManagement` (bool)

Allow management of the Event Hub namespace and storage account.

Default value: `false`

Example value: `false`

#### `enableInOrderMessageDelivery` (bool)

Enable in order processing of messages within a partition.

Default value: `false`

Example value: `false`

#### `messageRetentionInDays` (number)

Number of days to retain messages for in the newly created Event Hub namespace. Used only when entity management is enabled.

Default value: `1`

Example value: `90`

#### `partitionCount` (number)

Number of partitions for the new Event Hub namespace. Used only when entity management is enabled.

Default value: `1`

Example value: `3`

#### `resourceGroupName` (string)

Name of the resource group the Event Hub namespace is part of. Required when entity management is enabled.

Example value: `test-rg`

#### `subscriptionId` (string)

Azure subscription ID value. Required when entity management is enabled

Example value: `00112233-4455-6677-8899-aabbccddeeff`

### Azure AD: Client certificate

Authenticate using Azure AD with a client certificate. "azureCertificate" is required.

#### `azureClientId`

**Required** - Client ID (application ID)

Example value: `c7dd251f-811f-4ba2-a905-acd4d3f8f08b`

#### `azureTenantId`

**Required** - ID of the Azure AD tenant

Example value: `cd4b2887-304c-47e1-b4d5-65447fdd542a`

#### `eventHubNamespace` (string)

**Required** - The Event Hub Namespace name.

Example value: `namespace`

#### `azureCertificate`

Certificate and private key (in either a PEM file containing both the certificate and key, or in PFX/PKCS#12 format)

Example value:

```
-----BEGIN PRIVATE KEY-----\n MIIEvgI... \n -----END PRIVATE KEY-----
\n -----BEGIN CERTIFICATE----- \n MIICoTC... \n -----END CERTIFICATE----- \n

```

#### `azureCertificatePassword`

Password for the certificate if encrypted.

Example value: `password`

#### `azureEnvironment`

Optional name for the Azure environment if using a different Azure cloud

Default value: `AzurePublicCloud`

Example value: `AzurePublicCloud`

Allowed values:

- AzurePublicCloud

- AzureChinaCloud

- AzureUSGovernmentCloud

#### `enableEntityManagement` (bool)

Allow management of the Event Hub namespace and storage account.

Default value: `false`

Example value: `false`

#### `enableInOrderMessageDelivery` (bool)

Enable in order processing of messages within a partition.

Default value: `false`

Example value: `false`

#### `messageRetentionInDays` (number)

Number of days to retain messages for in the newly created Event Hub namespace. Used only when entity management is enabled.

Default value: `1`

Example value: `90`

#### `partitionCount` (number)

Number of partitions for the new Event Hub namespace. Used only when entity management is enabled.

Default value: `1`

Example value: `3`

#### `resourceGroupName` (string)

Name of the resource group the Event Hub namespace is part of. Required when entity management is enabled.

Example value: `test-rg`

#### `subscriptionId` (string)

Azure subscription ID value. Required when entity management is enabled

Example value: `00112233-4455-6677-8899-aabbccddeeff`

## Metadata

### `consumerID` (string)

**Required** - The name of the Event Hubs Consumer Group to listen on.

Example value: `group1`

### `storageAccountName` (string)

**Required** - Storage account name to use for the checkpoint store.

Example value: `myeventhubstorage`

### `storageContainerName` (string)

**Required** - Storage container name.

Example value: `myeventhubstoragecontainer`

### `getAllMessageProperties`

When set to true, will retrieve all message properties and include them in the returned event metadata Used for input binding direction.

Default value: `false`

Example value: `false`

### `storageAccountKey` (string)

Storage account key for the checkpoint store account. When using Azure AD, it is possible to omit this if the service principal has access to the storage account too. Property "storageAccountKey" is ignored when "storageConnectionString" is present

Example value: `112233445566778899`

### `storageConnectionString` (string)

Connection string for the checkpoint store, alternative to specifying storageAccountKey. Property "storageAccountKey" is ignored when "storageConnectionString" is present

Example value: `BlobEndpoint=https://storagesample.blob.core.windows.net;...`
