# Azure EventHubs

{% hint style="danger" %}
Azure EventHubs only support delete or compact as a topic cleanup policy.
{% endhint %}

{% hint style="success" %}
Only one Kafka connection is allowed.

The name must be kafka.

See [JSON schema](https://docs.lenses.io/latest/deployment/configuration/overview#json-schema-support) for support.

Environment variables are supported; escape the dollar sign

```yaml
sslKeystorePassword:
  # In case environment variable has single or double quotes escape it with 
  ## "\${ENV_VAR_NAME}
  value: "${ENV_VAR_NAME}"
```

{% endhint %}

{% stepper %}
{% step %}
**Create a Data Integration API key**

* **Add a shared access policy**
  * Navigate to your Event Hub resource and select *Shared access policies* in the *Settings* section.
  * Select *+* **Add shared access policy,** give a name, and check *all boxes* for the permissions (Manage, Send, Listen)
* Once the policy is created, obtain the *Primary Connection String*, by clicking the policy and copying the connection string. The connection string will be used as a JAAS password to connect to Kafka.
* The bootstrap broker **\[YOUR\_EVENT\_HUBS\_NAMESPACE]**.servicebus.windows.net:9093

**Configure Provisioning**
{% endstep %}

{% step %}
Set the following in the **provisioning.yaml**

{% hint style="warning" %}
Due to Azure EventHubs limitation, Pricing tier for EventHub has to be at least **Standard.**
{% endhint %}

{% tabs %}
{% tab title="With environment variable" %}
First, set the environment variable

{% hint style="info" %}
Note that "\\" at "*$ConnectionString"* is set additionally to escape the $ sign.
{% endhint %}

{% code title="terminal" fullWidth="true" %}

```bash
export SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule required username="\$ConnectionString" password="Endpoint=sb://[SB_URL]/;SharedAccessKeyName=[KEY_NAME];SharedAccessKey=[ACCESS_KEY]";
```

{% endcode %}

{% code title="provision.yaml" %}

```yaml
kafka:
- name: kafka
  version: 1
  tags: [my-tag]
  configuration:
    kafkaBootstrapServers:
      value:
        - SASL_SSL://[YOUR_BOOTSTRAP_SERVER]
        - SASL_SSL://[YOUR_BOOTSTRAP_SERVER]
    saslJaasConfig:
      value: '${SASL_JAAS_CONFIG}'
    saslMechanism:
      value: PLAIN
    protocol:
      value: SASL_SSL
```

{% endcode %}
{% endtab %}

{% tab title="Without environment variable" %}
{% code title="provision.yaml" %}

```yaml
connections:
  kafka:
  - name: Kafka
    version: 1
    tags: [my-tag]
    configuration:
      kafkaBootstrapServers:
        value:
          - SASL_SSL://[YOUR_BOOTSTRAP_SERVER]
          - SASL_SSL://[YOUR_BOOTSTRAP_SERVER]
      saslJaasConfig:
        value: org.apache.kafka.common.security.plain.PlainLoginModule required username="\$ConnectionString" password="Endpoint=sb://[SB_URL]/;SharedAccessKeyName=[KEY_NAME];SharedAccessKey=[ACCESS_KEY]";
      saslMechanism:
        value: PLAIN
      protocol:
        value: SASL_SSL
```

{% endcode %}
{% endtab %}
{% endtabs %}
{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lenses.io/latest/deployment/configuration/agent/automation/kafka/azure-eventhub.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
