Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Create a Salesforce connection in Catalog Explorer to store authentication credentials for Lakeflow Connect ingestion. Any user with the USE CONNECTION privilege on the connection can then create Salesforce ingestion pipelines without needing direct access to the credentials.
Alternatively, admin users can create a connection and a pipeline at the same time in the data ingestion UI. See Create an ingestion pipeline.
For privilege requirements, see Connect to managed ingestion sources.
Prerequisites
Salesforce applies usage restrictions to connected apps. The permissions in the following table are required for a successful first-time authentication. If you lack these permissions, Salesforce blocks the connection and requires an admin to install the Databricks connected app.
| Condition | Required permission |
|---|---|
| API Access Control is enabled. | Customize Application and either Modify All Data or Manage Connected Apps |
| API Access Control is not enabled. | Approve Uninstalled Connected Apps |
For background, see Prepare for Connected App Usage Restrictions Change in the Salesforce documentation.
Create a connection
Salesforce connections support three authentication types in Catalog Explorer. Choose the one that fits your organization:
- OAuth (user-to-machine): You sign in to Salesforce interactively to grant Azure Databricks access. See OAuth authentication.
- OAuth (machine-to-machine): Azure Databricks authenticates with the client ID and client secret of an External Client App that you create in your Salesforce org, using the OAuth client credentials flow. No one signs in interactively. Choose this when you want the connection to authenticate as an app instead of as a signed-in user. See OAuth machine-to-machine (M2M) authentication.
- Mutual TLS (mTLS): Azure Databricks and Salesforce exchange and verify client certificates to establish two-way trust, combined with the OAuth client credentials flow. Choose this for API-only users or when your organization requires mTLS. See Mutual TLS (mTLS) authentication.
OAuth authentication
In the Azure Databricks workspace, click Catalog > External data > Connections > Create connection.
On the Connection basics page of the Set up connection wizard, specify a unique Connection name.
In the Connection type drop-down menu, select Salesforce.
(Optional) Add a comment.
Click Next.
If you're ingesting from a Salesforce sandbox account, set Is sandbox to
true.Click Sign in with Salesforce.
You're redirected to Salesforce.
If you're ingesting from a Salesforce sandbox, click Use Custom Domain, provide the sandbox URL, and then click Continue.


Enter your Salesforce credentials and click Log in. Databricks recommends logging in as a Salesforce user that's dedicated to Databricks ingestion.
Important
For security purposes, only authenticate if you clicked an OAuth 2.0 link in the Azure Databricks UI.
After returning to the ingestion wizard, click Create connection.
OAuth machine-to-machine (M2M) authentication
With OAuth M2M, Azure Databricks uses the OAuth client credentials flow to get an access token for an External Client App that you create in your Salesforce org. The connection uses the permissions of the run-as user that you assign to the app. Set up the app in Salesforce, then create the connection in Azure Databricks.
To set up the External Client App in Salesforce, do the following:
- In Salesforce Setup, go to External Client App Manager, click New External Client App, enter a name and contact email, and enable OAuth settings for the app.
- Enter a Callback URL. The client credentials flow doesn't use it, so any placeholder works, for example
https://localhost. - Select the Manage user data via APIs (
api) and Perform requests at any time (refresh_token,offline_access) OAuth scopes. Azure Databricks doesn't request scopes in the client credentials flow, so the access token gets the scopes that you configure on the app. - Select Enable Client Credentials Flow, and then create the app.
- On the app's Policies tab, click Edit, and then do the following:
- Under OAuth Policies, confirm that Permitted Users is set to Admin approved users are pre-authorized.
- Under App Policies, move the Salesforce API Only System Integrations profile, or another profile that fits your organization, to Selected Profiles.
- Under OAuth Flows and External Client App Enhancements, confirm that Enable Client Credentials Flow is selected, and enter the username of the run-as user. The connection uses this user's permissions. Databricks recommends a Salesforce user that's dedicated to Azure Databricks ingestion.
- Click Save.
- Copy the app's consumer key and consumer secret from its OAuth settings. You use these as the client ID and client secret in the Azure Databricks setup.
- Note your org's My Domain URL. The client credentials flow requires it and doesn't support
login.salesforce.comortest.salesforce.com, including for sandbox orgs.
For details, see Configure the OAuth 2.0 Client Credentials Flow for External Client Apps in the Salesforce documentation.
To create the connection in Azure Databricks, do the following:
In the Azure Databricks workspace, click Catalog > External data > Connections > Create connection.
On the Connection basics page of the Set up connection wizard, specify a unique Connection name.
In the Connection type drop-down menu, select Salesforce.
In the Auth type drop-down menu, select OAuth Machine to Machine.
(Optional) Enter a comment.
Click Next.
Enter the following connection details:
Field Description Client ID The consumer key from your Salesforce External Client App. Client Secret The consumer secret from your Salesforce External Client App. Instance URL The My Domain URL of your Salesforce org, for example https://MyDomainName.my.salesforce.com. For a sandbox org, use the sandbox My Domain URL, for examplehttps://MyDomainName--SandboxName.sandbox.my.salesforce.com. The URL must use HTTPS and end insalesforce.com.Click Create connection.
To create the connection with SQL instead, run CREATE CONNECTION. Store the client secret in a secret scope and reference it with the secret function:
CREATE CONNECTION my_salesforce_m2m_connection
TYPE salesforce
OPTIONS (
client_id '<consumer-key>',
client_secret secret('<secret-scope>', '<secret-key>'),
instance_url 'https://MyDomainName.my.salesforce.com'
);
Azure Databricks gets a new access token from Salesforce automatically when the current token expires, so you don't need to update the connection.
Mutual TLS (mTLS) authentication
With mutual TLS, both Azure Databricks and Salesforce exchange and verify certificates, so each system confirms the other's identity before exchanging any data. Set up the certificate and an External Client App in Salesforce, then create the connection in Azure Databricks.
Salesforce setup
Ensure that mutual authentication is enabled for your Salesforce account. See Enable mutual authentication in the Salesforce documentation.
Generate and upload a certificate authority (CA)-signed certificate in Salesforce:
- From Setup, in the Quick Find box, enter
Certificate and Key Management, and then select Certificate and Key Management. - Select Create CA-Signed Certificate and enter the details to generate the certificate signing request (CSR).
- Send the CSR to a CA that Salesforce recognizes. For the list of trusted CAs, see the Salesforce CA list.
- Get the private key that corresponds to the certificate. You use this key in the Azure Databricks setup.
For detailed steps, see Upload a signed certificate in the Salesforce documentation.
- From Setup, in the Quick Find box, enter
Verify that the signed certificate bundle contains the root and intermediate certificates, and that the certificate metadata lists a public CA as the issuer.
Combine the client, intermediate, and root certificates into a single file, in the order Leaf (client), intermediate, then root. Separate each certificate with
BEGIN CERTIFICATEandEND CERTIFICATEblocks.Save the private key in a separate file in PEM (
.pem) format.Create an External Client App in your Salesforce org and configure it for the OAuth client credentials flow, as described in OAuth machine-to-machine (M2M) authentication. For the run-as user, enter the user for whom you enabled the mutual authentication profile. For detailed steps, see Configure the OAuth 2.0 Client Credentials Flow for External Client Apps in the Salesforce documentation.
Note the consumer key and consumer secret for the External Client App. You use these as the client ID and client secret in the Azure Databricks setup.
Azure Databricks setup
In the Azure Databricks workspace, click Catalog > External data > Connections > Create connection.
On the Connection basics page of the Set up connection wizard, specify a unique Connection name.
In the Connection type drop-down menu, select Salesforce.
In the Auth type drop-down menu, select Mutual TLS.
(Optional) Enter a comment.
Click Next.
Enter the following connection details:
Field Description Client ID The consumer key from your Salesforce External Client App. Client Secret The consumer secret from your Salesforce External Client App. Instance URL The domain URL for your Salesforce account, for example https://DomainName.my.salesforce.com. The URL must use HTTPS and end insalesforce.com.Client Private Key The private key in PEM format that corresponds to the certificate you uploaded to Salesforce. Client Certificate The certificate chain in PEM format. Enter the same certificate chain that you uploaded to Salesforce. Click Create connection.