2
2
title : Azure SQL and SQL Server
3
3
description : This article provides information on how to use the connector for moving data between Azure MS SQL and serverless Apache Spark pools.
4
4
services : synapse-analytics
5
- author : midesa
6
- ms.author : midesa
5
+ author : eskot
6
+ ms.author : eskot
7
7
ms.service : synapse-analytics
8
8
ms.topic : overview
9
9
ms.subservice : spark
@@ -30,6 +30,8 @@ dbname = "<< database name >>"
30
30
url = servername + " ;" + " databaseName=" + dbname + " ;"
31
31
dbtable = " << table name >> "
32
32
user = " << username >>"
33
+ principal_client_id = " << service principal client id >>"
34
+ principal_secret = " << service principal secret ho>>"
33
35
password = mssparkutils.credentials.getSecret(' azure key vault name' ,' secret name' )
34
36
```
35
37
@@ -87,20 +89,31 @@ except ValueError as error :
87
89
88
90
### Python example with service principal
89
91
``` python
90
- import adal
92
+ import msal
91
93
92
94
# Located in App Registrations from Azure Portal
93
95
tenant_id = " << tenant id >> "
94
96
95
97
# Located in App Registrations from Azure Portal
96
98
resource_app_id_url = " https://database.windows.net/"
97
99
100
+ # Define scope of the Service for the app registration before requesting from AAD
101
+ scope = " https://database.windows.net/.default"
102
+
98
103
# 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
+ )
100
114
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" ]
104
117
105
118
jdbc_df = spark.read \
106
119
.format(" com.microsoft.sqlserver.jdbc.spark" ) \
0 commit comments