22title : Azure SQL and SQL Server
33description : This article provides information on how to use the connector for moving data between Azure MS SQL and serverless Apache Spark pools.
44services : synapse-analytics
5- author : midesa
6- ms.author : midesa
5+ author : eskot
6+ ms.author : eskot
77ms.service : synapse-analytics
88ms.topic : overview
99ms.subservice : spark
@@ -30,6 +30,8 @@ dbname = "<< database name >>"
3030url = servername + " ;" + " databaseName=" + dbname + " ;"
3131dbtable = " << table name >> "
3232user = " << username >>"
33+ principal_client_id = " << service principal client id >>"
34+ principal_secret = " << service principal secret ho>>"
3335password = mssparkutils.credentials.getSecret(' azure key vault name' ,' secret name' )
3436```
3537
@@ -87,20 +89,31 @@ except ValueError as error :
8789
8890### Python example with service principal
8991``` python
90- import adal
92+ import msal
9193
9294# Located in App Registrations from Azure Portal
9395tenant_id = " << tenant id >> "
9496
9597# Located in App Registrations from Azure Portal
9698resource_app_id_url = " https://database.windows.net/"
9799
100+ # Define scope of the Service for the app registration before requesting from AAD
101+ scope = " https://database.windows.net/.default"
102+
98103# Authority
99- authority = " https://login.windows.net/" + tenant_id
104+ authority = " https://login.microsoftonline.net/" + tenant_id
105+
106+ # Get service principal
107+ service_principal_id = mssparkutils.credentials.getSecret(' azure key vault name' ,' principal_client_id' )
108+ service_principal_secret = mssparkutils.credentials.getSecret(' azure key vault name' ,' principal_secret' )
109+
110+
111+ context = msal.ConfidentialClientApplication(
112+ service_principal_id, service_principal_secret, authority
113+ )
100114
101- context = adal.AuthenticationContext(authority)
102- token = context.acquire_token_with_client_credentials(resource_app_id_url, service_principal_id, service_principal_secret)
103- access_token = token[" accessToken" ]
115+ token = app.acquire_token_silent([scope])
116+ access_token = token[" access_token" ]
104117
105118jdbc_df = spark.read \
106119 .format(" com.microsoft.sqlserver.jdbc.spark" ) \
0 commit comments