Skip to content

Commit 997f809

Browse files
authored
Merge pull request #99107 from AmarBadal/ambadal_pr_datastore_fixes
fixed issues with json object for cred
2 parents 48ddfaf + fbfac7b commit 997f809

File tree

1 file changed

+35
-28
lines changed

1 file changed

+35
-28
lines changed

articles/machine-learning/how-to-datastore.md

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,20 @@ ml_client.create_or_update(store)
124124

125125
```python
126126
from azure.ai.ml.entities import AzureBlobDatastore
127+
from azure.ai.ml.entities._datastore.credentials import AccountKeyCredentials
127128
from azure.ai.ml import MLClient
128129

129130
ml_client = MLClient.from_config()
130131

131132
store = AzureBlobDatastore(
132-
name="blob-protocol-example",
133+
name="blob_protocol_example",
133134
description="Datastore pointing to a blob container using wasbs protocol.",
134135
account_name="mytestblobstore",
135136
container_name="data-container",
136137
protocol="wasbs",
137-
credentials={
138-
"account_key": "XXXxxxXXXxXXXXxxXXXXXxXXXXXxXxxXxXXXxXXXxXXxxxXXxxXXXxXxXXXxxXxxXXXXxxxxxXXxxxxxxXXXxXXX"
139-
},
138+
credentials=AccountKeyCredentials(
139+
account_key="XXXxxxXXXxXXXXxxXXXXXxXXXXXxXxxXxXXXxXXXxXXxxxXXxxXXXxXxXXXxxXxxXXXXxxxxxXXxxxxxxXXXxXXX"
140+
),
140141
)
141142

142143
ml_client.create_or_update(store)
@@ -146,18 +147,19 @@ ml_client.create_or_update(store)
146147

147148
```python
148149
from azure.ai.ml.entities import AzureBlobDatastore
150+
from azure.ai.ml.entities._datastore.credentials import SasTokenCredentials
149151
from azure.ai.ml import MLClient
150152

151153
ml_client = MLClient.from_config()
152154

153155
store = AzureBlobDatastore(
154-
name="blob-sas-example",
156+
name="blob_sas_example",
155157
description="Datastore pointing to a blob container using SAS token.",
156158
account_name="mytestblobstore",
157159
container_name="data-container",
158-
credentials={
159-
"sas_token": "?xx=XXXX-XX-XX&xx=xxxx&xxx=xxx&xx=xxxxxxxxxxx&xx=XXXX-XX-XXXXX:XX:XXX&xx=XXXX-XX-XXXXX:XX:XXX&xxx=xxxxx&xxx=XXxXXXxxxxxXXXXXXXxXxxxXXXXXxxXXXXXxXXXXxXXXxXXxXX"
160-
},
160+
credentials=SasTokenCredentials(
161+
sas_token= "?xx=XXXX-XX-XX&xx=xxxx&xxx=xxx&xx=xxxxxxxxxxx&xx=XXXX-XX-XXXXX:XX:XXX&xx=XXXX-XX-XXXXX:XX:XXX&xxx=xxxxx&xxx=XXxXXXxxxxxXXXXXXXxXxxxXXXXXxxXXXXXxXXXXxXXXxXXxXX"
162+
),
161163
)
162164

163165
ml_client.create_or_update(store)
@@ -230,20 +232,22 @@ ml_client.create_or_update(store)
230232

231233
```python
232234
from azure.ai.ml.entities import AzureDataLakeGen2Datastore
235+
from azure.ai.ml.entities._datastore.credentials import ServicePrincipalCredentials
236+
233237
from azure.ai.ml import MLClient
234238

235239
ml_client = MLClient.from_config()
236240

237241
store = AzureDataLakeGen2Datastore(
238-
name="adls-gen2-example",
242+
name="adls_gen2_example",
239243
description="Datastore pointing to an Azure Data Lake Storage Gen2.",
240244
account_name="mytestdatalakegen2",
241245
filesystem="my-gen2-container",
242-
credentials={
243-
"tenant_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
244-
"client_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
245-
"client_secret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
246-
},
246+
credentials=ServicePrincipalCredentials(
247+
tenant_id= "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
248+
client_id= "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
249+
client_secret= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
250+
),
247251
)
248252

249253
ml_client.create_or_update(store)
@@ -298,18 +302,19 @@ az ml datastore create --file my_files_datastore.yml
298302

299303
```python
300304
from azure.ai.ml.entities import AzureFileDatastore
305+
from azure.ai.ml.entities._datastore.credentials import AccountKeyCredentials
301306
from azure.ai.ml import MLClient
302307

303308
ml_client = MLClient.from_config()
304309

305310
store = AzureFileDatastore(
306-
name="file-example",
311+
name="file_example",
307312
description="Datastore pointing to an Azure File Share.",
308313
account_name="mytestfilestore",
309314
file_share_name="my-share",
310-
credentials={
311-
"account_key": "XXXxxxXXXxXXXXxxXXXXXxXXXXXxXxxXxXXXxXXXxXXxxxXXxxXXXxXxXXXxxXxxXXXXxxxxxXXxxxxxxXXXxXXX"
312-
},
315+
credentials=AccountKeyCredentials(
316+
account_key= "XXXxxxXXXxXXXXxxXXXXXxXXXXXxXxxXxXXXxXXXxXXxxxXXxxXXXxXxXXXxxXxxXXXXxxxxxXXxxxxxxXXXxXXX"
317+
),
313318
)
314319

315320
ml_client.create_or_update(store)
@@ -319,18 +324,19 @@ ml_client.create_or_update(store)
319324

320325
```python
321326
from azure.ai.ml.entities import AzureFileDatastore
327+
from azure.ai.ml.entities._datastore.credentials import SasTokenCredentials
322328
from azure.ai.ml import MLClient
323329

324330
ml_client = MLClient.from_config()
325331

326332
store = AzureFileDatastore(
327-
name="file-sas-example",
333+
name="file_sas_example",
328334
description="Datastore pointing to an Azure File Share using SAS token.",
329335
account_name="mytestfilestore",
330336
file_share_name="my-share",
331-
credentials={
332-
"sas_token": "?xx=XXXX-XX-XX&xx=xxxx&xxx=xxx&xx=xxxxxxxxxxx&xx=XXXX-XX-XXXXX:XX:XXX&xx=XXXX-XX-XXXXX:XX:XXX&xxx=xxxxx&xxx=XXxXXXxxxxxXXXXXXXxXxxxXXXXXxxXXXXXxXXXXxXXXxXXxXX"
333-
},
337+
credentials=SasTokenCredentials(
338+
sas_token="?xx=XXXX-XX-XX&xx=xxxx&xxx=xxx&xx=xxxxxxxxxxx&xx=XXXX-XX-XXXXX:XX:XXX&xx=XXXX-XX-XXXXX:XX:XXX&xxx=xxxxx&xxx=XXxXXXxxxxxXXXXXXXxXxxxXXXXXxxXXXXXxXXXXxXXXxXXxXX"
339+
),
334340
)
335341

336342
ml_client.create_or_update(store)
@@ -400,19 +406,20 @@ ml_client.create_or_update(store)
400406

401407
```python
402408
from azure.ai.ml.entities import AzureDataLakeGen1Datastore
409+
from azure.ai.ml.entities._datastore.credentials import ServicePrincipalCredentials
403410
from azure.ai.ml import MLClient
404411

405412
ml_client = MLClient.from_config()
406413

407414
store = AzureDataLakeGen1Datastore(
408-
name="adls-gen1-example",
415+
name="adls_gen1_example",
409416
description="Datastore pointing to an Azure Data Lake Storage Gen1.",
410417
store_name="mytestdatalakegen1",
411-
credentials={
412-
"tenant_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
413-
"client_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
414-
"client_secret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
415-
},
418+
credentials=ServicePrincipalCredentials(
419+
tenant_id= "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
420+
client_id= "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
421+
client_secret= "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
422+
),
416423
)
417424

418425
ml_client.create_or_update(store)

0 commit comments

Comments
 (0)