Azure Blob 存储 (WASBS) - 如何获得访问权限?

问题描述 投票:0回答:1

我想解析 Blob 存储容器上的文本文件,但收到一条错误消息:访问流时权限被拒绝。

我想我必须为我的存储帐户使用访问密钥,但如何在代码中执行此操作?

我的程序在使用 microsoft learn 的公共 blob 容器时可以运行。

# Auth
from azure.identity import DefaultAzureCredential
from azure.ai.ml.entities import AmlCompute
from azure.ai.ml import UserIdentityConfiguration
from azure.ai.ml import MLClient, command, Input
from azure.ai.ml.constants import AssetTypes, InputOutputModes
import pandas as pd

from azure.storage.blob import BlobServiceClient

ml_client = MLClient.from_config(credential=DefaultAzureCredential())

gpu_compute_target = "gpu-cluster"

curated_env_name = "TensorFlow_Train_Env:2"

blob_csv_path = "wasbs://[email protected]/read1.txt"

job = command(
    inputs={
        "csv_file" : Input(type=AssetTypes.URI_FILE, path=blob_csv_path, mode=InputOutputModes.RO_MOUNT),
    },
    compute=gpu_compute_target,
    environment=curated_env_name,
    code="./src/",
    command="python test2.py --data-file ${{inputs.csv_file}}",
    experiment_name="tf-test-expname",
    display_name="tensorflow-test_displayname",
)

ml_client.jobs.create_or_update(job)
azure azure-blob-storage azure-machine-learning-service blobstorage
1个回答
0
投票

要从 blob 读取 CSV,您需要使用

https://
协议或
azureml://
协议给出路径。

首先,使用 CSV 所在的存储帐户创建数据存储。

转到数据 > 数据存储 > 创建

enter image description here

接下来,为数据存储命名并提供访问密钥。

enter image description here

点击创建。

创建后,浏览到您的 CSV 文件。

enter image description here

然后单击复制 uri。系统将提示您输入 2 种 URI。

enter image description here

URI

enter image description here

选择其中任何一个并将该路径传递给您的工作。 此数据存储可用于 Blob 存储中存在的任何数据,无需每次都进行配置。

© www.soinside.com 2019 - 2024. All rights reserved.