An Azure machine learning service for building and deploying models.
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.