From e57cd99bd04bb3cf7ac543685a2de99eb0c1fea2 Mon Sep 17 00:00:00 2001 From: jugi92 Date: Thu, 5 Jun 2025 16:12:55 +0200 Subject: [PATCH] Add fsspec auth option example --- .../how-to-access-data-interactive.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/articles/machine-learning/how-to-access-data-interactive.md b/articles/machine-learning/how-to-access-data-interactive.md index 239428ce511..fc0b1a3cc50 100644 --- a/articles/machine-learning/how-to-access-data-interactive.md +++ b/articles/machine-learning/how-to-access-data-interactive.md @@ -222,6 +222,26 @@ df = pd.concat(dflist) df.head() ``` +#### Use different authentication +The Filesystem Class accepts a parameter ml_client, which can be used to use the same auth as the one for the ml_client authentication, for example the user managed identity by providing the correct client_id. +```python +from azureml.fsspec import AzureMachineLearningFileSystem +from azure.identity import ManagedIdentityCredential +from azure.ai.ml import MLClient + +credential = ManagedIdentityCredential(client_id='') # Replace with your client ID if needed + +ml_client = MLClient.from_config(credential=credential) + +# define the URI - update <> placeholders +uri = 'azureml://subscriptions//resourcegroups//workspaces//datastores/' + +# auth credential from ml_client will be used by filesystem +fs = AzureMachineLearningFileSystem(uri, ml_client=ml_client) + +fs.ls() +``` + #### Accessing data from your Azure Databricks filesystem (`dbfs`) Filesystem spec (`fsspec`) has a range of [known implementations](https://filesystem-spec.readthedocs.io/en/stable/_modules/index.html), including the Databricks Filesystem (`dbfs`).