Azure Synapse Analytics – How to get Salesforce data using Notebook via a python script
In this blog, we will learn how to get Salesforce data using Notebook via a python script. In part1 we created an Azure synapse analytics workspace. In this, we will create a Notebook and write a python script to get Salesforce data step by step.
Step 1: Sign to the Azure portal. Open Azure Synapse Analytics and click on Open Synapse Studio to create a Notebook.
Step 2: Once the Synapse Studio opens click on “Develop” and create a new Notebook.
Step 3: Provide the suitable name for your Notebook, select a language as python, and attached the apache-spark pool that you have created.
Step 4: Before you write a python script to get data from Salesforce. You have to first create a new “Connected App” in your Salesforce portal(prod or sandbox).
Go in “Setup”, open the “App Manager”. Then, create a “New Connected App”. Name your application. Tick the box “Enable OAuth Settings”. In “Selected OAuth Scopes”, make all scopes available. Type “http://localhost/” in “Callback URL”. Save.
In the end, you should get and note down the “Consumer Key” and the “Consumer Secret”.
Using user id, password, consumer key, and secret we can get the Salesforce access token.
Step 5: Once you have the above information, write the following python script to get the Salesforce data. To read the data from Salesforce, here I have used the “Simple_Salesforce” python library.
Step 6: Here is the output of the script.
Hope this will help.