Share via

Azure ML mounting datastore while creating deployment

Eashwaran sridhar 0 Reputation points
2025-09-22T18:54:35.26+00:00

Hi Everyone, Had a question we have the default blob store in the Azure ML studio workspace. I have a scenario where I have stored image in blob and this will be further used for infrencing. I need to know is there any method by which I can mount the blob while creating the deployment or the endpoint

Azure Machine Learning
0 comments No comments

1 answer

Sort by: Most helpful
  1. Aryan Parashar 3,695 Reputation points Microsoft External Staff Moderator
    2025-09-23T03:30:14.7533333+00:00

    Hi Eashwaran,

    A file or a folder from blob storge can be mounted on a compute target inside a job. Below is the code:

    from azure.ai.ml import command, Input, MLClient, UserIdentityConfiguration, ManagedIdentityConfiguration
    from azure.ai.ml.entities import Data
    from azure.ai.ml.constants import AssetTypes, InputOutputModes
    from azure.identity import DefaultAzureCredential
    
    # Set your subscription, resource group and workspace name:
    subscription_id = "<SUBSCRIPTION_ID>"
    resource_group = "<RESOURCE_GROUP>"
    workspace = "<AML_WORKSPACE_NAME>"
    
    ml_client = MLClient(
        DefaultAzureCredential(), subscription_id, resource_group, workspace
    )
    
    path = "wasbs://******@azuremlexampledata.blob.core.windows.net/titanic.csv"
    
    
    data_type = AssetTypes.URI_FILE
    
    mode = InputOutputModes.RO_MOUNT
    
    
    identity = None
    
    inputs = {
        "input_data": Input(type=data_type, path=path, mode=mode)
    }
    
    job = command(
        command="head ${{inputs.input_data}}",
        inputs=inputs,
        environment="azureml://registries/azureml/environments/sklearn-1.1/versions/4",
        compute="cpu-cluster",
        identity=identity,
    )
    
    ml_client.jobs.create_or_update(job)
    
    

    However when using a real-time endpoint it is advised to access blobs using managed identity. Here is the supported documentation:
    https://learn.microsoft.com/en-us/azure/machine-learning/how-to-access-resources-from-endpoints-managed-identities?view=azureml-api-2&tabs=system-identity-cli

    For example:
    Set Entra ID Authentication for Blob and ML Studio.
    Use Azure Storage Blobs client library to access data from Blob inside deployment. Here is supported documentation:
    https://learn.microsoft.com/en-us/python/api/overview/azure/storage-blob-readme?view=azure-python

    Feel free to accept this as an answer.

    Thankyou for reaching out to the Microsoft QNA Portal.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.