Home / Databricks on Azure

Databricks on AzureTroubleshootingAdvanced

Azure Databricks workspace deployment fails with VNet injection: subnet delegation, NSG, policy and managed resource group errors

A new VNet-injected Azure Databricks workspace fails to deploy from the portal, Bicep or Terraform. Read the real ARM error, then fix subnet delegation, NSGs, shared subnets, policy denials and outbound access.

Deepak Bhardwaj7 min read

Applies toAzure Databricks (Premium), VNet injection with secure cluster connectivity, Azure CLI 2.x with the databricks extension, ARM/Bicep and Terraform azurerm

Symptom

You are creating a VNet-injected workspace and the deployment fails. Sometimes the portal shows Conflict or BadRequest. Sometimes Terraform prints waiting for creation of Workspace ... Code="...". Sometimes the workspace gets created, but the first cluster dies at launch. In every case the top-level message rarely names the cause. Fix the cause and redeploy. Retrying the same template gets you the same error.

Warning

Don't hand-edit the NSG rules or delegation that Azure Databricks adds to an existing workspace's subnets. Those rules are managed through the subnet delegation, and removing them can stop every cluster in the workspace from starting.

1. Get the real error

The inner error is in the deployment operations, not in the summary line.

RG=rg-dbx-prod
# Most recent deployments in the resource group
az deployment group list -g $RG --query "[].{name:name, state:properties.provisioningState, time:properties.timestamp}" -o table

# The failed operation and its full status message
az deployment operation group list -g $RG -n <deployment-name> \
  --query "[?properties.provisioningState=='Failed'].{resource:properties.targetResource.resourceName, code:properties.statusCode, msg:properties.statusMessage}" -o json

If the workspace was created by Terraform, run the same commands. azurerm still deploys through ARM. Or check the resource group's Activity log and filter on Failed for the Microsoft.Databricks/workspaces/write operation.

Error codes and wording change between API versions. Match on the meaning of the message, not the exact code string.

2. Map the message to the cause

What the message says Likely cause Fix
Subnet must be delegated / delegation missing Host or container subnet not delegated to Microsoft.Databricks/workspaces Add the delegation to both subnets (section 3)
NSG required / subnet has no network security group A subnet has no NSG attached Attach an NSG to both subnets. It can start empty
ConflictWithNetworkIntentPolicy An NSG rule conflicts with the rules Databricks needs, or a required rule is missing Remove the custom deny that overlaps, or redeploy with a clean NSG
Subnet already in use / referenced by another workspace Subnets reused from another or deleted workspace Use a new, empty subnet pair per workspace
Subnet contains other resources VMs, private endpoints or other NICs in the Databricks subnets Move them out. The two subnets must hold only Databricks
RequestDisallowedByPolicy Azure Policy denies something the deployment creates (often in the managed resource group) Exempt the managed resource group or fix the policy (section 4)
Managed resource group already exists Name collides with an existing RG Pick a new managed RG name. Databricks creates it
MissingSubscriptionRegistration Resource provider not registered az provider register --namespace Microsoft.Databricks
Deployment succeeds, clusters fail with bootstrap/network errors No outbound path, DNS or UDR problems Section 5

3. Check and fix the subnets

Both subnets need the same things: an NSG, delegation to Microsoft.Databricks/workspaces, no other resources and a non-overlapping CIDR. Databricks recommends nothing smaller than /26. You can't change the CIDR after deployment, so size it for peak node count now.

VNET_RG=rg-dbx-net; VNET=vnet-dbx
for S in snet-dbx-host snet-dbx-container; do
  az network vnet subnet show -g $VNET_RG --vnet-name $VNET -n $S \
    --query "{name:name, prefix:addressPrefix, nsg:networkSecurityGroup.id, delegations:delegations[].serviceName, ipConfigs:length(ipConfigurations || \`[]\`)}" -o json
done

You want nsg set, delegations containing Microsoft.Databricks/workspaces, and ipConfigs at 0 before the first deployment. To fix a subnet:

az network nsg create -g $VNET_RG -n nsg-dbx
for S in snet-dbx-host snet-dbx-container; do
  az network vnet subnet update -g $VNET_RG --vnet-name $VNET -n $S \
    --network-security-group nsg-dbx \
    --delegations Microsoft.Databricks/workspaces
done

Then deploy the workspace against those subnets:

az databricks workspace create -g rg-dbx-prod -n dbx-prod -l westeurope --sku premium \
  --managed-resource-group rg-dbx-prod-managed \
  --vnet /subscriptions/<sub>/resourceGroups/rg-dbx-net/providers/Microsoft.Network/virtualNetworks/vnet-dbx \
  --public-subnet snet-dbx-host --private-subnet snet-dbx-container \
  --enable-no-public-ip true

Flag names in the databricks CLI extension vary by version. Check az databricks workspace create --help on your build. In the template, "public" is the host subnet and "private" is the container subnet. If you use back-end Private Link only, set --required-nsg-rules NoAzureDatabricksRules as the Private Link guide describes.

Terraform specifics

In azurerm, the subnet's NSG link is a separate resource. Make the workspace depend on the association, or the workspace can be created before the NSG is attached:

resource "azurerm_databricks_workspace" "this" {
  # ...
  custom_parameters {
    no_public_ip                                         = true
    virtual_network_id                                   = azurerm_virtual_network.dbx.id
    public_subnet_name                                   = azurerm_subnet.host.name
    private_subnet_name                                  = azurerm_subnet.container.name
    public_subnet_network_security_group_association_id  = azurerm_subnet_network_security_group_association.host.id
    private_subnet_network_security_group_association_id = azurerm_subnet_network_security_group_association.container.id
  }
}

Also add lifecycle { ignore_changes = [security_rule] } to the azurerm_network_security_group if you declare it inline. Otherwise the next apply deletes the rules Databricks added.

4. Azure Policy denials

Databricks creates a managed resource group with a storage account, managed identity and, later, VMs and disks. Org-wide policies often block them, for example "require tag X", "deny public network access on storage", "allowed VM SKUs" or "deny public IPs". Find which assignment denied the deployment:

az monitor activity-log list -g rg-dbx-prod --offset 2h --status Failed \
  --query "[].{op:operationName.value, msg:properties.statusMessage}" -o json

Also check the managed resource group if it was created before the failure. The status message includes policyAssignmentId and policyDefinitionId. Options, best first:

  1. Add the planned managed resource group to the assignment's excluded scopes (notScopes). Or, if the group already exists, create a policy exemption on it.
  2. Change the policy effect from Deny to Audit for that resource type.
  3. For tag policies, set the tags on the workspace. They propagate to managed resources.
az policy exemption create -n dbx-managed-rg \
  --policy-assignment <policyAssignmentId> \
  --exemption-category Waiver \
  --scope /subscriptions/<sub>/resourceGroups/rg-dbx-prod-managed

Caution

Don't let anyone "clean up" the deny assignment or locks on the managed resource group to make a deployment pass. The deny assignment is what protects the workspace's managed resources. A lock on that group can block cluster creation and workspace deletion later.

5. Workspace deployed, clusters don't start

With secure cluster connectivity (no public IP), cluster nodes still need outbound access to the control plane, artifact storage and the metastore. Microsoft has announced that, from 31 March 2026, new Azure VNets default to private subnets with no default outbound internet access. New workspaces in those VNets need an explicit egress path. Check the current guidance for your region and VNet. Typical fixes:

  • Attach a NAT gateway to both subnets, or route 0.0.0.0/0 through Azure Firewall/NVA with the Databricks FQDNs and service tags allowed.
  • With custom DNS, confirm that the DNS servers are reachable from the subnets and can resolve public Azure names.
  • A UDR that sends control-plane traffic through a firewall that drops it causes bootstrap timeouts.
az network vnet subnet show -g $VNET_RG --vnet-name $VNET -n snet-dbx-host --query "{nat:natGateway.id, rt:routeTable.id}" -o json
az network vnet show -g $VNET_RG -n $VNET --query "dhcpOptions.dnsServers" -o json

Then start a small test cluster and read the termination reason:

databricks clusters events <cluster-id> --output json | jq '.events[] | select(.type=="TERMINATING") | .details.reason'

Prevent it next time

  • Keep one module that creates the VNet, both subnets, NSG, delegation, NAT gateway and associations. Make the workspace depend on all of them.
  • Give every workspace its own subnet pair, sized for peak nodes, and record the CIDRs in your IP plan.
  • Agree on policy exemptions for Databricks managed resource groups with the platform team before the first deployment, not during it.
  • Run terraform plan in CI and check that it doesn't remove Databricks-managed NSG rules.
  • After deployment, run a smoke test that starts a single-node cluster and reads from your storage account.