<a id="cc-clickhouse-sink-eap-azure"></a>

# Egress Private Link Endpoint Setup: ClickHouse on Azure for Confluent Cloud

The ClickHouse Sink connector for Confluent Cloud supports Azure Private Link
connectivity through Egress Private Link Endpoints. Use this guide to
configure the connector and set up the required endpoints.

## Prerequisites

The following is a list of prerequisites for configuring the ClickHouse Sink connector with an Egress Private Link Endpoint:

* In Confluent Cloud, one of the following cluster types is set up with the specified
  network resource:
  * A Dedicated cluster with a Confluent Cloud network.

    For the steps to create a Confluent Cloud network, see [Create a Confluent Cloud network](../../networking/ccloud-network/azure.md#ccn-config-azure). The Connection
    type of the network needs to be “Private Link Access”.
  * A Enterprise cluster with a network gateway

    For the steps to create a gateway, see
    [Create a gateway for outbound connectivity in Confluent Cloud](../../networking/azure-egress-privatelink-esku.md#azure-privatelink-egress-create-gateway-esku).
* A source topic is created to sink data into the ClickHouse database.
* A ClickHouse instance is created to sink data into and is running within the
  same region and cloud as the Confluent Cloud cluster.
* A database and a schema are created in ClickHouse to sink data into.

<a id="cc-clickhouse-sink-eap-azure-service-dns-name"></a>

## Step 1. Obtain Endpoint Service name and DNS Name from ClickHouse

1. In the ClickHouse Cloud console, open the service you want to connect via Private Link, then navigate to the **Settings** menu.
2. Click **Setup Private Link Endpoint** in Private Endpoint section, and make note of ClickHouse Service Name and DNS Name.
   ![image](connectors/cc-clickhouse-sink-connector/images-clickhouse-eap/clickhouse-dns-service-name.png)

<a id="cc-clickhouse-sink-eap-azure-create-egress-endpoint"></a>

## Step 2. Create an Egress Private Link Endpoint

### Dedicated cluster

1. In the **Network management** page or tab of the desired Confluent Cloud environment,
   click the Confluent Cloud network you want to add the Private Link Endpoint to.
   The **Connection Type** of the network should be “Private Link
   Access”.
2. Click **Create endpoint** in the **Egress connections**
   tab.
3. Click the service you want to connect to, specifically, **ClickHouse**. Select **Other** if you do not see the specific service.
4. Follow the steps below to specify the following field values:
   * **SERVICE**: Name of service connecting to - ClickHouse.
   * **Endpoint Name**: Name of the Private Link Endpoint.
   * **Private Link service name**: The name of the Private Link service you
     retrieved in [Step 1. Obtain Endpoint Service name and DNS Name from ClickHouse](#cc-clickhouse-sink-eap-azure-service-dns-name).
   * **Create an endpoint with high availability**: Check the box if
     you wish to deploy an endpoint with High Availability.

     Endpoints deployed with high availability have network interfaces
     deployed in multiple availability zones.
5. Click **Create** to create the Private Link Endpoint.
6. If there are additional steps for the specific target service, follow
   the prompt to complete the tasks, and then click **Finish**.

### Enterprise cluster

1. In the **Network management** page or tab of the desired Confluent Cloud environment,
   click the **For serverless products** tab.
2. Click the gateway to which you want to add the PrivateLink Endpoint.
3. In the **Access points** tab, click **Add access point**.
4. Click the service you want to connect to, specifically, **ClickHouse**. Select **Other** if you do not see the specific service.

   Specific services are listed based on the cloud provider for the
   gateway.
5. Follow the steps below to specify the following field values:
   * **Access point name**: Name of the PrivateLink Endpoint.
   * **Create an endpoint with high availability**: Check the box if
     you wish to deploy an endpoint with High Availability.

     Endpoints deployed with high availability have network interfaces
     deployed in multiple availability zones.
   * **Private Link service name**: The name of the Private Link service you
     retrieved in [Step 1. Obtain Endpoint Service name and DNS Name from ClickHouse](#cc-clickhouse-sink-eap-azure-service-dns-name).
6. Click **Create access point** to create the PrivateLink Endpoint.
7. If there are additional steps for the specific target service, follow
   the prompt to complete the tasks, and click **Finish**.

## Step 3. Add Endpoint ID to ClickHouse Cloud organization

1. Open the ClickHouse Cloud Console, and Copy the Resource ID from the **Egress connection** tab.
   ![image](connectors/cc-clickhouse-sink-connector/images-clickhouse-eap/clickhouse-resource-id.png)
2. Go to the **ClickHouse Console → Settings → Set up private endpoint**. Add the Resource ID retrieved in the previous step to the **Endpoint ID** field. This will allow requests from the Confluent cluster endpoint to access the ClickHouse service.
   ![image](connectors/cc-clickhouse-sink-connector/images-clickhouse-eap/clickhouse-add-endpoint.png)

## Step 4. Create a DNS record

### Dedicated Cluster

1. When the Private Link Endpoint status transitions to “Ready”, in the **DNS** tab,
   click **Create record** on the associated Private Link Endpoint.
   ![image](connectors/cc-clickhouse-sink-connector/images-clickhouse-eap/clickhouse-create-dns-record.png)
2. Specify the following, and click **Save**.
   * **Access point**: Select the Private Link Endpoint you created above in
     [Step 2. Create an Egress Private Link Endpoint](#cc-clickhouse-sink-eap-azure-create-egress-endpoint).
   * **Domain**: Enter the domain name as DNS name you got from ClickHouse in [Step 1. Obtain Endpoint Service name and DNS Name from ClickHouse](#cc-clickhouse-sink-eap-azure-service-dns-name).

   ![image](connectors/cc-clickhouse-sink-connector/images-clickhouse-eap/clickhouse-dns-record.png)

### Enterprise cluster

1. In the **Network Management** tab of your environment, click the
   **For serverless products** tab, and click the Confluent Cloud gateway you
   want to add the DNS record to.
2. In the **DNS** tab, click **Create DNS record**.
3. Specify the following field values:
   * **Access point**: Select the Private Link Endpoint you created above in
     [Step 2. Create an Egress Private Link Endpoint](#cc-clickhouse-sink-eap-azure-create-egress-endpoint).
   * **Domain**: Enter the domain name as DNS name we got from ClickHouse in [Step 1. Obtain Endpoint Service name and DNS Name from ClickHouse](#cc-clickhouse-sink-eap-azure-service-dns-name).
4. Click **Save**.

## Step 5. Create the ClickHouse Sink connector

1. Specify the ClickHouse hostname as the DNS name fetched from ClickHouse in [Step 1. Obtain Endpoint Service name and DNS Name from ClickHouse](#cc-clickhouse-sink-eap-azure-service-dns-name).
   ![image](connectors/cc-clickhouse-sink-connector/images-clickhouse-eap/clickhouse-create-connector.png)
2. See the [ClickHouse Sink connector](cc-clickhouse-sink.md#cc-clickhouse-sink) documentation for the steps to create the sink connector Confluent Cloud.
