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. 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.Documentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Additional charges may be applied to inter-region traffic. Please check the latest Azure documentation.
- Obtain Azure connection alias for Private Link
- Create a Private Endpoint in Azure
- Add the Private Endpoint Resource ID to your ClickHouse Cloud organization
- Add the Private Endpoint Resource ID to your services allow list
- Access your ClickHouse Cloud service using Private Link
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.
Attention
ClickHouse attempts to group your services to reuse the same published Private Link service 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. Find Terraform examples at the ClickHouse Terraform Provider repository.Obtain Azure connection alias for Private Link
Option 1: ClickHouse Cloud console
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 theService name and DNS name which will be used for setting up Private Link.
Make a note of the Service name and DNS name, they will be needed in the next steps.
Option 2: API
Before you get started, you’ll need a ClickHouse Cloud API key. You can create a new key or use an existing one. Once you have your API key, set the following environment variables before running any commands:INSTANCE_ID by filtering by region, provider and service name:
endpointServiceId. You’ll use it in the next step.
Create a private endpoint in Azure
:::important 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. ::: In this section, we’re going to create a Private Endpoint in Azure. You can use either the Azure Portal or Terraform.Option 1: Using Azure Portal to create a private endpoint in Azure
In the Azure Portal, open Private Link Center → Private Endpoints. Open the Private Endpoint creation dialog by clicking on the Create button.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.
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 step.
Click Next: Virtual Network button.
- 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
- 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.
Optionally, you can attach tags to your Private Endpoint. Click the Next: Review + create button.
Finally, click the Create button. 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.
Option 2: Using Terraform to create a private endpoint in Azure
Use the template below to use Terraform to create a Private Endpoint:Obtaining the Private Endpoint Resource ID
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: Under properties, findid field and copy this value:
Preferred method: Using Resource ID
Legacy method: Using resourceGUID
You can still use the resourceGUID for backward compatibility. Find the resourceGuid field and copy this value:
Setting up DNS for Private Link
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.
Create Private DNS zone
Option 1: Using Azure portal Please follow this guide to create an Azure private DNS zone using the Azure Portal. Option 2: Using Terraform Use the following Terraform template to create a Private DNS zone:Create a wildcard DNS record
Create a wildcard record and point to your Private Endpoint: Option 1: Using Azure Portal- Open the
MyAzureResourceGroupresource group and select the${region_code}.privatelink.azure.clickhouse.cloudprivate zone. - Select + Record set.
- For Name, type
*. - For IP Address, type the IP address you see for Private Endpoint.
- Select OK.
Create a virtual network link
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. Option 2: Using TerraformThere are various ways to configure DNS. Please set up DNS according to your specific use case.
Verify DNS setup
xxxxxxxxxx.westus3.privatelink.azure.clickhouse.cloud domain should be pointed to the Private Endpoint IP. (10.0.0.4 in this example).
Add the Private Endpoint Resource ID to your ClickHouse Cloud organization
Option 1: ClickHouse Cloud console
To add an endpoint to the organization, proceed to the Add the Private Endpoint Resource ID to your 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.Option 2: API
Set the following environment variables before running any commands:ENDPOINT_ID environment variable using data from the Obtaining the Private Endpoint Resource ID step.
Run the following command to add the Private Endpoint:
Add the Private Endpoint Resource ID to your services allow list
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.Option 1: ClickHouse Cloud console
In the ClickHouse Cloud console, open the service that you would like to connect via PrivateLink then navigate to Settings. Enter theResource ID obtained from the previous step.
If you want to allow access from an existing PrivateLink connection, use the existing endpoint drop-down menu.
Option 2: API
Set these environment variables before running any commands:Access your ClickHouse Cloud service using Private Link
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 beprivateDnsHostnameAPI or DNS nameconsole taken from Obtain Azure connection alias for Private Link.
Obtaining the private DNS hostname
Option 1: ClickHouse Cloud console
In the ClickHouse Cloud console, navigate to Settings. Click on the Set up private endpoint button. In the opened flyout, copy the DNS Name.Option 2: API
Set the following environment variables before running any commands: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.
Troubleshooting
Test DNS setup
Run the following command:privateDnsHostnameAPI or DNS nameconsole from Obtain Azure connection alias for Private Link
You should receive the following response:
Connection reset by peer
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.Private Endpoint is in pending state
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.Test connectivity
If you have problems with connecting using Private Link, check your connectivity usingopenssl. Make sure the Private Link endpoint status is Accepted.
OpenSSL should be able to connect (see CONNECTED in the output). errno=104 is expected.