> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Azure Private Link

> How to set up Azure Private Link

export const ScalePlanFeatureBadge = ({feature = 'This feature', linking_verb_are = false}) => {
  return <div className="scalePlanFeatureContainer">
            <div className="scalePlanFeatureBadge">
                Scale plan feature
            </div>
            <div>
                <p>{feature} {linking_verb_are ? 'are' : 'is'} available in the Scale and Enterprise plans. To upgrade, visit the plans page in the cloud console.</p>
            </div>
        </div>;
};

export const Image = ({img, alt, size = "lg"}) => {
  const normalizedSize = ["sm", "md", "lg"].includes(size) ? size : "lg";
  return <div className={`ch-image-${normalizedSize}`}>
      <Frame>
        <img src={img} alt={alt} />
      </Frame>
    </div>;
};

<ScalePlanFeatureBadge feature="Azure Private Link" />

This guide shows how to use Azure Private Link to provide private connectivity via a virtual network between Azure (including customer-owned and Microsoft Partner services) and ClickHouse Cloud. Azure Private Link simplifies the network architecture and secures the connection between endpoints in Azure by eliminating data exposure to the public internet.

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pe.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=dc77d27afd6dd25a67c8a73341fe7a6c" size="lg" alt="Overview of PrivateLink" background="white" width="906" height="414" data-path="images/cloud/security/azure-pe.webp" />

<Warning>
  Azure Private Link supports only connections initiated from your Azure VNet to ClickHouse Cloud. It can't be used for connections initiated from ClickHouse Cloud to services in your VNet, such as a private database.
</Warning>

Azure supports cross-region connectivity via Private Link. This enables you to establish connections between VNets located in different regions where you have ClickHouse services deployed.

<Note>
  Additional charges may be applied to inter-region traffic. Please check the latest Azure documentation.
</Note>

**Please complete the following steps to enable Azure Private Link:**

1. Obtain Azure connection alias for Private Link
2. Create a Private Endpoint in Azure
3. Add the Private Endpoint Resource ID to your ClickHouse Cloud organization
4. Add the Private Endpoint Resource ID to your services allow list
5. Access your ClickHouse Cloud service using Private Link

<Note>
  ClickHouse Cloud Azure PrivateLink has switched from using resourceGUID to Resource ID filters. You can still use resourceGUID, as it is backward-compatible, but we recommend switching to Resource ID filters. To migrate, simply create a new endpoint using the Resource ID, attach it to the service, and remove the old resourceGUID-based one.
</Note>

<h2 id="attention">
  Attention
</h2>

ClickHouse attempts to group your services to reuse the same published [Private Link service](https://learn.microsoft.com/en-us/azure/private-link/private-link-service-overview) within the Azure region. However, this grouping isn't guaranteed, especially if you spread your services across multiple ClickHouse organizations.
If you already have Private Link configured for other services in your ClickHouse organization, you can often skip most of the steps because of that grouping and proceed directly to the final step: [Add the Private Endpoint Resource ID to your services allow list](#add-private-endpoint-id-to-services-allow-list).

Find Terraform examples at the ClickHouse [Terraform Provider repository](https://github.com/ClickHouse/terraform-provider-clickhouse/tree/main/examples/).

<h2 id="obtain-azure-connection-alias-for-private-link">
  Obtain Azure connection alias for Private Link
</h2>

<h3 id="option-1-clickhouse-cloud-console">
  Option 1: ClickHouse Cloud console
</h3>

In the ClickHouse Cloud console, open the service that you would like to connect via PrivateLink, then open the **Settings** menu. Click on the **Set up private endpoint** button. Make a note of the `Service name` and `DNS name` which will be used for setting up Private Link.

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-privatelink-pe-create.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=731b46648c85879bd271b3c9fa4a8f44" size="lg" alt="Private Endpoints" border width="1898" height="918" data-path="images/cloud/security/azure-privatelink-pe-create.webp" />

Make a note of the `Service name` and `DNS name`, they will be needed in the next steps.

<h3 id="option-2-api">
  Option 2: API
</h3>

Before you get started, you'll need a ClickHouse Cloud API key. You can [create a new key](/docs/products/cloud/features/admin-features/api/openapi) or use an existing one.

Once you have your API key, set the following environment variables before running any commands:

```bash theme={null}
REGION=<region code, use Azure format, for example: westus3>
PROVIDER=azure
KEY_ID=<Key ID>
KEY_SECRET=<Key secret>
ORG_ID=<set ClickHouse organization ID>
SERVICE_NAME=<Your ClickHouse service name>
```

Get your ClickHouse `INSTANCE_ID` by filtering by region, provider and service name:

```shell theme={null}
INSTANCE_ID=$(curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" \
"https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services" | \
jq ".result[] | select (.region==\"${REGION:?}\" and .provider==\"${PROVIDER:?}\" and .name==\"${SERVICE_NAME:?}\") | .id " -r)
```

Obtain your Azure connection alias and Private DNS hostname for Private Link:

```bash theme={null}
curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | jq  .result
{
  "endpointServiceId": "production-westus3-0-0.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.westus3.azure.privatelinkservice",
  "privateDnsHostname": "xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud"
}
```

Make a note of the `endpointServiceId`. You'll use it in the next step.

<h2 id="create-private-endpoint-in-azure">
  Create a private endpoint in Azure
</h2>

<Warning>
  This section covers ClickHouse-specific details for configuring ClickHouse via Azure Private Link. Azure-specific steps are provided as a reference to guide you on where to look, but they may change over time without notice from the Azure cloud provider. Please consider Azure configuration based on your specific use case.

  Please note that ClickHouse isn't responsible for configuring the required Azure private endpoints and DNS records.

  For any issues related to Azure configuration tasks, contact Azure Support directly.
</Warning>

In this section, we're going to create a Private Endpoint in Azure. You can use either the Azure Portal or Terraform.

<h3 id="option-1-using-azure-portal-to-create-a-private-endpoint-in-azure">
  Option 1: Using Azure Portal to create a private endpoint in Azure
</h3>

In the Azure Portal, open **Private Link Center → Private Endpoints**.

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-private-link-center.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=d9c347f124b516d3948912a75f2ccd68" size="lg" alt="Open Azure Private Center" border width="1485" height="693" data-path="images/cloud/security/azure-private-link-center.webp" />

Open the Private Endpoint creation dialog by clicking on the **Create** button.

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-private-link-center.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=d9c347f124b516d3948912a75f2ccd68" size="lg" alt="Open Azure Private Center" border width="1485" height="693" data-path="images/cloud/security/azure-private-link-center.webp" />

***

In the following screen, specify the following options:

* **Subscription** / **Resource Group**: Please choose the Azure subscription and resource group for the Private Endpoint.
* **Name**: Set a name for the **Private Endpoint**.
* **Region**: Choose a region where the deployed VNet that will be connected to ClickHouse Cloud via Private Link.

After you have completed the above steps, click the **Next: Resource** button.

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pe-create-basic.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=24f19464e799ac2bde676abfb623c770" size="md" alt="Create Private Endpoint Basic" border width="784" height="923" data-path="images/cloud/security/azure-pe-create-basic.webp" />

***

Select the option **Connect to an Azure resource by resource ID or alias**.

For the **Resource ID or alias**, use the `endpointServiceId` you have obtained from the [Obtain Azure connection alias for Private Link](#obtain-azure-connection-alias-for-private-link) step.

Click **Next: Virtual Network** button.

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pe-resource.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=5df4afb2267c72c4ef7d7ad009190be6" size="md" alt="Private Endpoint Resource Selection" border width="1122" height="911" data-path="images/cloud/security/azure-pe-resource.webp" />

***

* **Virtual network**: Choose the VNet you want to connect to ClickHouse Cloud using Private Link
* **Subnet**: Choose the subnet where Private Endpoint will be created

Optional:

* **Application security group**: You can attach ASG to Private Endpoint and use it in Network Security Groups to filter network traffic to/from Private Endpoint.

Click **Next: DNS** button.

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pe-create-vnet.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=0499d536c732468d4fa538221af4edfd" size="md" alt="Private Endpoint Virtual Network Selection" border width="1056" height="917" data-path="images/cloud/security/azure-pe-create-vnet.webp" />

Click the **Next: Tags** button.

***

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pe-create-dns.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=68da549d1d866baae8e2fbe58784e8df" size="md" alt="Private Endpoint DNS Configuration" border width="818" height="921" data-path="images/cloud/security/azure-pe-create-dns.webp" />

Optionally, you can attach tags to your Private Endpoint.

Click the **Next: Review + create** button.

***

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pe-create-tags.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=b643c83fde1656d9ceb909489a4ca221" size="md" alt="Private Endpoint Tags" border width="912" height="919" data-path="images/cloud/security/azure-pe-create-tags.webp" />

Finally, click the **Create** button.

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pe-create-review.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=a622720b6a4c59e7076c45289fb12bbd" size="md" alt="Private Endpoint Review" border width="911" height="919" data-path="images/cloud/security/azure-pe-create-review.webp" />

The **Connection status** of the created Private Endpoint will be in **Pending** state. It will change to **Approved** state once you add this Private Endpoint to the service allow list.

Open the network interface associated with Private Endpoint and copy the **Private IPv4 address**(10.0.0.4 in this example), you will need this information in the next steps.

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pe-ip.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=9c0fccdb2a70bfc48e1f89e15ffb1a5b" size="lg" alt="Private Endpoint IP Address" border width="1155" height="621" data-path="images/cloud/security/azure-pe-ip.webp" />

<h3 id="option-2-using-terraform-to-create-a-private-endpoint-in-azure">
  Option 2: Using Terraform to create a private endpoint in Azure
</h3>

Use the template below to use Terraform to create a Private Endpoint:

```json theme={null}
resource "azurerm_private_endpoint" "example_clickhouse_cloud" {
  name                = var.pe_name
  location            = var.pe_location
  resource_group_name = var.pe_resource_group_name
  subnet_id           = var.pe_subnet_id

  private_service_connection {
    name                              = "test-pl"
    private_connection_resource_alias = "<data from 'Obtain Azure connection alias for Private Link' step>"
    is_manual_connection              = true
  }
}
```

<h3 id="obtaining-private-endpoint-resourceid">
  Obtaining the Private Endpoint Resource ID
</h3>

In order to use Private Link, you need to add the Private Endpoint connection Resource ID to your service allow list.

The Private Endpoint Resource ID is exposed in the Azure Portal. Open the Private Endpoint created in the previous step and click **JSON View**:

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pe-view.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=c1842eaec4c17cdfa0a4b5af45c746ef" size="lg" alt="Private Endpoint View" border width="1329" height="839" data-path="images/cloud/security/azure-pe-view.webp" />

Under properties, find `id` field and copy this value:

**Preferred method: Using Resource ID**

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pe-resource-id.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=9105d9076d60599e23ee2c9dbb72c1ff" size="lg" alt="Private Endpoint Resource ID" border width="1704" height="1824" data-path="images/cloud/security/azure-pe-resource-id.webp" />

**Legacy method: Using resourceGUID**
You can still use the resourceGUID for backward compatibility. Find the `resourceGuid` field and copy this value:

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pe-resource-guid.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=35e544bfa40019510161104a43ab52f2" size="lg" alt="Private Endpoint Resource GUID" border width="1702" height="1830" data-path="images/cloud/security/azure-pe-resource-guid.webp" />

<h2 id="setting-up-dns-for-private-link">
  Setting up DNS for Private Link
</h2>

You will need to create a Private DNS zone (`${location_code}.privatelink.azure.clickhouse.cloud`) and attach it to your VNet to access resources via Private Link.

<h3 id="create-private-dns-zone">
  Create Private DNS zone
</h3>

**Option 1: Using Azure portal**

Please follow this guide to [create an Azure private DNS zone using the Azure Portal](https://learn.microsoft.com/en-us/azure/dns/private-dns-getstarted-portal).

**Option 2: Using Terraform**

Use the following Terraform template to create a Private DNS zone:

```json theme={null}
resource "azurerm_private_dns_zone" "clickhouse_cloud_private_link_zone" {
  name                = "${var.location}.privatelink.azure.clickhouse.cloud"
  resource_group_name = var.resource_group_name
}
```

<h3 id="create-a-wildcard-dns-record">
  Create a wildcard DNS record
</h3>

Create a wildcard record and point to your Private Endpoint:

**Option 1: Using Azure Portal**

1. Open the `MyAzureResourceGroup` resource group and select the `${region_code}.privatelink.azure.clickhouse.cloud` private zone.
2. Select + Record set.
3. For Name, type `*`.
4. For IP Address, type the IP address you see for Private Endpoint.
5. Select **OK**.

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pl-dns-wildcard.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=11288ed1cf32f85fbc26bb8d6a11e9d4" size="lg" alt="Private Link DNS Wildcard Setup" border width="1804" height="138" data-path="images/cloud/security/azure-pl-dns-wildcard.webp" />

**Option 2: Using Terraform**

Use the following Terraform template to create a wildcard DNS record:

```json theme={null}
resource "azurerm_private_dns_a_record" "example" {
  name                = "*"
  zone_name           = var.zone_name
  resource_group_name = var.resource_group_name
  ttl                 = 300
  records             = ["10.0.0.4"]
}
```

<h3 id="create-a-virtual-network-link">
  Create a virtual network link
</h3>

To link the private DNS zone to a virtual network, you'll need to create a virtual network link.

**Option 1: Using Azure Portal**

Please follow this guide to [link the virtual network to your private DNS zone](https://learn.microsoft.com/en-us/azure/dns/private-dns-getstarted-portal#link-the-virtual-network).

**Option 2: Using Terraform**

<Note>
  There are various ways to configure DNS. Please set up DNS according to your specific use case.
</Note>

You need to point "DNS name", taken from [Obtain Azure connection alias for Private Link](#obtain-azure-connection-alias-for-private-link) step, to Private Endpoint IP address. This ensures that services/components within your VPC/Network can resolve it properly.

<h3 id="verify-dns-setup">
  Verify DNS setup
</h3>

`xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud` domain should be pointed to the Private Endpoint IP. (10.0.0.4 in this example).

```bash theme={null}
nslookup xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud.
Server: 127.0.0.53
Address: 127.0.0.53#53

Non-authoritative answer:
Name: xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud
Address: 10.0.0.4
```

<h2 id="add-the-private-endpoint-id-to-your-clickhouse-cloud-organization">
  Add the Private Endpoint Resource ID to your ClickHouse Cloud organization
</h2>

<h3 id="option-1-clickhouse-cloud-console-1">
  Option 1: ClickHouse Cloud console
</h3>

To add an endpoint to the organization, proceed to the [Add the Private Endpoint Resource ID to your services allow list](#add-private-endpoint-id-to-services-allow-list) step. Adding the Private Endpoint Resource ID using the ClickHouse Cloud console to the services allow list automatically adds it to organization.

To remove an endpoint, open **Organization details -> Private Endpoints** and click the delete button to remove the endpoint.

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-pe-remove-private-endpoint.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=3f978e218a917c70b4db6d90a263fbbe" size="lg" alt="Remove Private Endpoint" border width="1478" height="807" data-path="images/cloud/security/azure-pe-remove-private-endpoint.webp" />

<h3 id="option-2-api-1">
  Option 2: API
</h3>

Set the following environment variables before running any commands:

```bash theme={null}
PROVIDER=azure
KEY_ID=<Key ID>
KEY_SECRET=<Key secret>
ORG_ID=<set ClickHouse organization ID>
ENDPOINT_ID=<Private Endpoint Resource ID>
REGION=<region code, use Azure format>
```

Set the `ENDPOINT_ID` environment variable using data from the [Obtaining the Private Endpoint Resource ID](#obtaining-private-endpoint-resourceid) step.

Run the following command to add the Private Endpoint:

```bash theme={null}
cat <<EOF | tee pl_config_org.json
{
  "privateEndpoints": {
    "add": [
      {
        "cloudProvider": "azure",
        "id": "${ENDPOINT_ID:?}",
        "description": "Azure private endpoint",
        "region": "${REGION:?}"
      }
    ]
  }
}
EOF
```

You can also run the following command to remove a Private Endpoint:

```bash theme={null}
cat <<EOF | tee pl_config_org.json
{
  "privateEndpoints": {
    "remove": [
      {
        "cloudProvider": "azure",
        "id": "${ENDPOINT_ID:?}",
        "region": "${REGION:?}"
      }
    ]
  }
}
EOF
```

After adding or removing a Private Endpoint, run the following command to apply it to your organization:

```bash theme={null}
curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" -X PATCH -H "Content-Type: application/json" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}" -d @pl_config_org.json
```

<h2 id="add-private-endpoint-id-to-services-allow-list">
  Add the Private Endpoint Resource ID to your services allow list
</h2>

By default, a ClickHouse Cloud service isn't available over a Private Link connection even if the Private Link connection is approved and established. You need to explicitly add the Private Endpoint Resource ID for each service that should be available using Private Link.

<h3 id="option-1-clickhouse-cloud-console-2">
  Option 1: ClickHouse Cloud console
</h3>

In the ClickHouse Cloud console, open the service that you would like to connect via PrivateLink then navigate to **Settings**. Enter the `Resource ID` obtained from the [previous](#obtaining-private-endpoint-resourceid) step.

<Note>
  If you want to allow access from an existing PrivateLink connection, use the existing endpoint drop-down menu.
</Note>

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-privatelink-pe-filter.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=b1b219fc307883f226a591d3d20e11b4" size="lg" alt="Private Endpoints Filter" border width="1898" height="918" data-path="images/cloud/security/azure-privatelink-pe-filter.webp" />

<h3 id="option-2-api-2">
  Option 2: API
</h3>

Set these environment variables before running any commands:

```bash theme={null}
PROVIDER=azure
KEY_ID=<Key ID>
KEY_SECRET=<Key secret>
ORG_ID=<set ClickHouse organization ID>
ENDPOINT_ID=<Private Endpoint Resource ID>
INSTANCE_ID=<Instance ID>
```

Execute it for each service that should be available using Private Link.

Run the following command to add the Private Endpoint to the services allow list:

```bash theme={null}
cat <<EOF | tee pl_config.json
{
  "privateEndpointIds": {
    "add": [
      "${ENDPOINT_ID:?}"
    ]
  }
}
EOF
```

You can also run the following command to remove a Private Endpoint from the services allow list:

```bash theme={null}
cat <<EOF | tee pl_config.json
{
  "privateEndpointIds": {
    "remove": [
      "${ENDPOINT_ID:?}"
    ]
  }
}
EOF
```

After adding or removing a Private Endpoint to the services allow list, run the following command to apply it to your organization:

```bash theme={null}
curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" -X PATCH -H "Content-Type: application/json" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}" -d @pl_config.json | jq
```

<h2 id="access-your-clickhouse-cloud-service-using-private-link">
  Access your ClickHouse Cloud service using Private Link
</h2>

Each service with Private Link enabled has a public and private endpoint. In order to connect using Private Link, you need to use a private endpoint which will be `privateDnsHostname`<sup>API</sup> or `DNS name`<sup>console</sup> taken from [Obtain Azure connection alias for Private Link](#obtain-azure-connection-alias-for-private-link).

<h3 id="obtaining-the-private-dns-hostname">
  Obtaining the private DNS hostname
</h3>

<h4 id="option-1-clickhouse-cloud-console-3">
  Option 1: ClickHouse Cloud console
</h4>

In the ClickHouse Cloud console, navigate to **Settings**. Click on the **Set up private endpoint** button. In the opened flyout, copy the **DNS Name**.

<Image img="https://mintcdn.com/private-7c7dfe99/Ph2XgLY43sq6v4yO/images/cloud/security/azure-privatelink-pe-dns.webp?fit=max&auto=format&n=Ph2XgLY43sq6v4yO&q=85&s=1b058b2bbb6dc5a9cc68ec8511492f22" size="lg" alt="Private Endpoint DNS Name" border width="1898" height="918" data-path="images/cloud/security/azure-privatelink-pe-dns.webp" />

<h4 id="option-2-api-3">
  Option 2: API
</h4>

Set the following environment variables before running any commands:

```bash theme={null}
KEY_ID=<Key ID>
KEY_SECRET=<Key secret>
ORG_ID=<set ClickHouse organization ID>
INSTANCE_ID=<Instance ID>
```

Run the following command:

```bash theme={null}
curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}/privateEndpointConfig" | jq  .result
```

You should receive a response similar to the following:

```response theme={null}
{
  ...
  "privateDnsHostname": "xxxxxxx.<region code>.privatelink.azure.clickhouse.cloud"
}
```

In this example, connection to the `xxxxxxx.region_code.privatelink.azure.clickhouse.cloud` hostname will be routed to Private Link. Meanwhile, `xxxxxxx.region_code.azure.clickhouse.cloud` will be routed over the internet.

Use the `privateDnsHostname` to connect to your ClickHouse Cloud service using Private Link.

<h2 id="troubleshooting">
  Troubleshooting
</h2>

<h3 id="test-dns-setup">
  Test DNS setup
</h3>

Run the following command:

```bash theme={null}
nslookup <dns name>
```

where "dns name" is the `privateDnsHostname`<sup>API</sup> or `DNS name`<sup>console</sup> from [Obtain Azure connection alias for Private Link](#obtain-azure-connection-alias-for-private-link)

You should receive the following response:

```response theme={null}
Non-authoritative answer:
Name: <dns name>
Address: 10.0.0.4
```

<h3 id="connection-reset-by-peer">
  Connection reset by peer
</h3>

Most likely, the Private Endpoint Resource ID wasn't added to the service allow-list. Revisit the [*Add Private Endpoint Resource ID to your services allow-list* step](#add-private-endpoint-id-to-services-allow-list).

<h3 id="private-endpoint-is-in-pending-state">
  Private Endpoint is in pending state
</h3>

Most likely, the Private Endpoint Resource ID wasn't added to the service allow-list. Revisit the [*Add Private Endpoint Resource ID to your services allow-list* step](#add-private-endpoint-id-to-services-allow-list).

<h3 id="test-connectivity">
  Test connectivity
</h3>

If you have problems with connecting using Private Link, check your connectivity using `openssl`. Make sure the Private Link endpoint status is `Accepted`.

OpenSSL should be able to connect (see CONNECTED in the output). `errno=104` is expected.

```bash theme={null}
openssl s_client -connect abcd.westus3.privatelink.azure.clickhouse.cloud:9440
```

```response highlight={1} theme={null}
CONNECTED(00000003)
write:errno=104
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 335 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
```

<h3 id="checking-private-endpoint-filters">
  Checking private endpoint filters
</h3>

Set the following environment variables before running any commands:

```bash theme={null}
KEY_ID=<Key ID>
KEY_SECRET=<Key secret>
ORG_ID=<please set ClickHouse organization ID>
INSTANCE_ID=<Instance ID>
```

Run the following command to check Private Endpoint filters:

```bash theme={null}
curl --silent --user "${KEY_ID:?}:${KEY_SECRET:?}" -X GET -H "Content-Type: application/json" "https://api.clickhouse.cloud/v1/organizations/${ORG_ID:?}/services/${INSTANCE_ID:?}" | jq .result.privateEndpointIds
```

<h2 id="more-information">
  More information
</h2>

For more information about Azure Private Link, please visit [azure.microsoft.com/en-us/products/private-link](https://azure.microsoft.com/en-us/products/private-link).
