When deploying a Databricks app in a workspace that does not allow external public access, you need to ensure that your app communicates with Databricks over the appropriate setup, such as a private or internal network connection. Below are detailed solutions to address the error you're encountering: "public access is not allowed":
1. Use Azure Private Link (if on Azure) or AWS PrivateLink (if on AWS)
Databricks workspaces can be configured to use a Private Link, which eliminates the need for public IPs by routing traffic securely over private virtual networks.
For Azure Databricks:
- Use Azure Private Link to expose Databricks APIs and WebApp endpoints privately within your virtual network.
- Verify that your Databricks app is deployed in an environment connected to the same VNET where the workspace operates (or is peered with the Databricks VNET).
- Make sure the Private Link endpoint is set up for both:
- WebApp (Databricks workspace): so your app can access Databricks’ web services.
- Databricks REST API: to communicate programmatically from your app.
For AWS Databricks:
- Use AWS PrivateLink for Amazon-hosted Databricks workspaces.
- Ensure your app is deployed in the same VPC (Virtual Private Cloud) or a peered VPC where the workspace resides.
- Set up a private interface endpoint to access Databricks services.
Steps:
- Check your Databricks workspace's private connectivity configuration.
- Confirm that your app's deployment environment supports private access to the Databricks workspace through Private Link.
2. Deploy your App Within the Same VNet (Azure) or VPC (AWS)
If external IP addresses are blocked, you must ensure your app resides inside the same secure network as your Databricks workspace to access it.
-
Azure: Deploy the application within the same Azure Virtual Network (VNet) where your Databricks workspace is deployed. This can be accomplished by:
- Deploying your app as an Azure Function, Azure App Service (within the VNet), or in a VM that is part of the same VNet.
- Using VNet service endpoints or private endpoints to securely access the Databricks workspace.
-
AWS: Similarly, the app should be deployed in the same VPC or a peered VPC that has private access to the Databricks workspace.
Key Considerations:
- Ensure proper network peering or integration.
- Configure your app to communicate with Databricks endpoints over the private IP space.
- Set up the appropriate firewall/security group rules to enable communication.
3. Use Public IP Allowlisting as a Temporary Measure
If deploying your app inside the same network is not immediately feasible, you may explicitly allow your app’s public IP address to access the workspace. This allows your app to temporarily bypass the restriction of "no public access."
Steps:
- Obtain the app’s static public IP address (note that this is required, as dynamic IP addresses will change and fail).
- Go to your Databricks workspace settings (in Azure or AWS) and add this IP to the allowlist:
- Azure: Update the workspace's Firewall Settings in the Azure Portal by adding the app's IP to the allowed IP ranges.
- AWS: Modify the workspace's security groups or firewall settings to allow ingress traffic from the app's public IP.
Note: This option has security risks and should only be used as a last resort or for testing purposes.
4. Use a VPN or ExpressRoute/Direct Connect
If your app is deployed in a private environment but outside of the Databricks workspace's immediate VNet/VPC, you can connect it securely through a site-to-site VPN or a private connection (e.g., Azure ExpressRoute or AWS Direct Connect).
- Azure: Use ExpressRoute to connect your external app’s VLAN to the VNet where the Databricks workspace resides. Configure peering to route private traffic.
- AWS: Use Direct Connect for private IP traffic routing between your app and Databricks.
- Set up necessary routing tables and private endpoints for Databricks REST API and UI traffic.
5. Configure Your App for Private Access
Your app will need some adjustments or configurations to ensure it uses private endpoints when accessing the Databricks workspace.
- Use Databricks CLI or REST API over private endpoints instead of public-facing endpoints.
- Confirm that the app is configured with:
- Private endpoints: Use the workspace's private DNS to resolve Databricks hostnames privately.
- Authentication: Use a secure access token (such as a Personal Access Token or Azure Active Directory token).
Example: Configure the app to use the workspace URL as <databricks-instance>.privatelink.<region>.azuredatabricks.net or an equivalent private endpoint for AWS.
6. Use a Jump Box / Bastion Host
In environments where you cannot move the app into the same VNet or VPC, you can set up a jump box or bastion host within the private network to serve as an intermediary for communication.
Steps:
- Deploy a VM or lightweight service (such as NGINX) in the same private network as Databricks.
- Route your app’s traffic through the jump box to the Databricks workspace.
7. Check Workspace Configuration for Validation
Finally, validate the following configurations in the Databricks workspace:
- Enable secure private traffic: Access via private or internal networks only.
- Firewall configuration: Ensure that the app's traffic matches the allowed inbound traffic rules.
Run the following commands to check access:
curl -X GET https://<databricks-instance>.privatelink.<region>.azuredatabricks.net/api/2.0/clusters/list \
-H "Authorization: Bearer <your-databricks-token>"
databricks clusters list --profile <profile_name>
If the connection fails, ensure the network or private link setup is complete.
8. Common Debugging Checklist
- Verify that your app is deployed in the correct network or has access to an intermediary (e.g., VPN, ExpressRoute).
- Check that the Databricks workspace has private access enabled (and you are using DNS for private endpoints).
- Use proper authentication tokens for API and CLI commands.
- Verify firewall rules or security groups that affect inbound/outbound traffic.
By ensuring your app operates within the same private network infrastructure as the Databricks workspace and using private connectivity options like Private Link, you can avoid the "public access is not allowed" error.