Cannot access Azure Storage File Shares from Azure Machine Learning Notebook (Python SDK v2)

Rainbow 16 Reputation points
2023-01-02T14:35:13.473+00:00

When I try to access Azure Storage File Shares from Azure Machine Learning Notebook, I get the following error.

1. Error Message
DataAccessError(PermissionDenied(Some(NoIdentityOnCompute)))

275396-image.png

2. What I did
I executed the following code from Notebook to get image data stored in the Azure Storage File Shares.
Since the datasource is File Shares, I used "abfss" as the type, and followed the instructions written in the document (https://learn.microsoft.com/en-us/azure/machine-learning/how-to-read-write-data-v2?tabs=python)

from azure.ai.ml import command  
from azure.ai.ml import UserIdentityConfiguration  
from azure.ai.ml import Input  
  
gpu_compute_target = "gpu-cluster-rainbow"  
custom_env_name = "keras-env"  
web_path = "abfss://[file_shared_name]@[storage_account_name].dfs.core.windows.net/[file_shared_name]/[path]/"  
  
job_env = ml_client.environments.get(name=custom_env_name, version=str(len(list(ml_client.environments.list(name=custom_env_name)))))  
job = command(  
    inputs=dict(  
        data_folder=Input(type="uri_folder", path=web_path),  
    ),   
    compute=gpu_compute_target,  
    environment=f"{job_env.name}:{job_env.version}",  
    code="./src/",  
    command="python keras_image_preprocessing.py --data-folder ${{inputs.data_folder}}",  
    experiment_name="keras-images-preprocessing-kaggle",  
    display_name="keras-images-preprocessing",  
)  
ml_client.jobs.create_or_update(job)  

as per now I am allowing public access for the storage.

3. I also tried...
I also tried to make a data store using SDK v2, refering to the following document.

https://learn.microsoft.com/en-us/azure/machine-learning/how-to-datastore?tabs=cli-identity-based-access%2Ccli-adls-identity-based-access%2Csdk-azfiles-sas%2Csdk-adlsgen1-identity-access

But, this time I also stuck because I couldn't import the following package.

from azure.ai.ml.entities._datastore.credentials import SasTokenCredentials  

275389-image.png

I was assuming this import will succeed because I am using the Python SDK v2, but only the above import is failing.
I will also show the full piece of code (Both Sas Token, Account key is not working)

from azure.ai.ml.entities import AzureFileDatastore  
from azure.ai.ml.entities._datastore.credentials import SasTokenCredentials  
from azure.ai.ml import MLClient  
  
store = AzureFileDatastore(  
    name="file-sas-example",  
    description="Datastore pointing to a file share using sas token.",  
    account_name="rainbowmlstorage",  
    file_share_name="xxxx",  
    # credentials=SasTokenCredentials(  
    #     sas_token="?sv=xxxxxxxxxxxx"  
    # ),  
    credentials={  
        "account_key": "xxxx"  
    },  
)  

Would somebody help me?

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,642 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rainbow 16 Reputation points
    2023-01-24T12:20:19.3066667+00:00

    Dear @romungi-MSFT

    Thank you very much for your support.
    I succeeded importing the library.

    The only doubt remaining is what should I give for the value <identity> in the following syntax ?

    # Create an identity configuration from the user-assigned managed identity  
    managed_identity = ManagedIdentityConfiguration(resource_id="/subscriptions/<subscription_id>/resourcegroups/<resource_group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<identity>")  
    
    0 comments No comments