You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/synapse-analytics/machine-learning/tutorial-score-model-predict-spark-pool.md
+12-21Lines changed: 12 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,15 @@ Make sure all prerequisites are in place before following these steps for using
86
86
> [!NOTE]
87
87
> Update tenant, client, subscription, resource group, AML workspace and linked service details in this script before running it.
88
88
89
-
-**Through service principal:** You can use service principal client ID and secret directly to authenticate to AML workspace. Service principal must have "Contributor" access to the AML workspace.
89
+
-**(Recommended) Through linked service:** You can use linked service to authenticate to AML workspace. Linked service can use "service principal" or Synapse workspace's "Managed Service Identity (MSI)" for authentication. "Service principal" or "Managed Service Identity (MSI)" must have "Contributor" access to the AML workspace.
90
+
91
+
```python
92
+
#AML workspace authentication using linked service
93
+
from notebookutils.mssparkutils import azureML
94
+
ws = azureML.getWorkspace("<linked_service_name>") # "<linked_service_name>" is the linked service name, not AML workspace name. Also, linked service supports MSI and service principal both
95
+
```
96
+
97
+
-**Through service principal:** Though not recommended, you can use service principal client IDand secret directly to authenticate to AML workspace. Providing the service principal password directly poses some security risk, so we suggest using a linked service where possible. Service principal must have "Contributor" access to the AML workspace.
90
98
91
99
```python
92
100
#AML workspace authentication using service principal
@@ -112,14 +120,6 @@ Make sure all prerequisites are in place before following these steps for using
112
120
)
113
121
```
114
122
115
-
-**Through linked service:** You can use linked service to authenticate to AML workspace. Linked service can use "service principal"or Synapse workspace's "Managed Service Identity (MSI)" for authentication. "Service principal" or "Managed Service Identity (MSI)" must have "Contributor" access to the AML workspace.
116
-
117
-
```python
118
-
#AML workspace authentication using linked service
119
-
from notebookutils.mssparkutils import azureML
120
-
ws = azureML.getWorkspace("<linked_service_name>") # "<linked_service_name>" is the linked service name, not AML workspace name. Also, linked service supports MSI and service principal both
121
-
```
122
-
123
123
4. **Enable PREDICTin spark session:** Set the spark configuration `spark.synapse.ml.predict.enabled` to `true` to enable the library.
124
124
125
125
```python
@@ -331,6 +331,7 @@ Make sure all prerequisites are in place before following these steps for using
331
331
332
332
from azureml.core import Workspace, Model
333
333
from azureml.core.authentication import ServicePrincipalAuthentication
334
+
from notebookutils.mssparkutils import azureML
334
335
335
336
AZURE_TENANT_ID="xyz"
336
337
AZURE_CLIENT_ID="xyz"
@@ -340,18 +341,8 @@ Make sure all prerequisites are in place before following these steps for using
340
341
AML_RESOURCE_GROUP="xyz"
341
342
AML_WORKSPACE_NAME="xyz"
342
343
343
-
svc_pr = ServicePrincipalAuthentication(
344
-
tenant_id=AZURE_TENANT_ID,
345
-
service_principal_id=AZURE_CLIENT_ID,
346
-
service_principal_password=AZURE_CLIENT_SECRET
347
-
)
348
-
349
-
ws = Workspace(
350
-
workspace_name=AML_WORKSPACE_NAME,
351
-
subscription_id=AML_SUBSCRIPTION_ID,
352
-
resource_group=AML_RESOURCE_GROUP,
353
-
auth=svc_pr
354
-
)
344
+
#AML workspace authentication using linked service
345
+
ws = azureML.getWorkspace("<linked_service_name>") # "<linked_service_name>" is the linked service name, not AML workspace name. Also, linked service supports MSI and service principal both
0 commit comments