Microsoft Azure Blob 存储
使用 dvc remote add 命令定义远程存储。设置一个名称和有效的 Azure Blob 存储 URL:
$ dvc remote add -d myremote azure://<mycontainer>/<path>要设置身份验证或其他配置,请使用 dvc remote modify 设置任意受支持的配置参数。
身份验证
这可能需要在账户上拥有 存储 Blob 数据参与者 和其他 角色。
始终需要提供存储账户名称 (account_name)。DVC 默认尝试使用其 默认凭据 进行身份验证。此方式会使用环境变量(通常在 Azure CLI 配置 期间设置)或某些 Microsoft 应用程序的数据。
$ dvc remote modify myremote account_name 'mystorage'使用默认身份验证时,您可能需要根据具体设置启用以下某些排除参数(详情):
$ dvc remote modify --system myremote \
exclude_environment_credential true
$ dvc remote modify --system myremote \
exclude_visual_studio_code_credential true
$ dvc remote modify --system myremote \
exclude_shared_token_cache_credential true
$ dvc remote modify --system myremote \
exclude_managed_identity_credential true对于自定义身份验证,您可以按以下顺序使用 dvc remote modify --local 设置以下配置参数、使用 环境变量 或使用 Azure CLI 配置文件。
通过 DVC 配置参数进行身份验证
以下参数按尝试顺序列出。
-
如果提供了 连接字符串 (
connection_string),则会使用它(推荐)。由于账户名称已包含在连接字符串中,因此account_name将被忽略。$ dvc remote modify --local myremote \ connection_string 'mysecret' -
如果提供了
tenant_id、client_id和client_secret,则将使用 Active Directory (AD) 服务主体 身份验证。$ dvc remote modify --local myremote tenant_id 'mytenant' $ dvc remote modify --local myremote client_id 'myclient' $ dvc remote modify --local myremote client_secret 'mysecret' -
接下来是存储账户密钥 (
account_key) 或共享访问签名令牌 (sas_token)。$ dvc remote modify --local myremote account_key 'mysecret'$ dvc remote modify --local myremote sas_token 'mysecret' -
如果设置了
allow_anonymous_login,则最后将尝试 匿名读取访问。仍需提供account_name。仅适用于公共容器。$ dvc remote modify myremote allow_anonymous_login true
通过环境变量进行身份验证
可以使用 这些环境变量 替代部分参数。
用于 Azure 连接字符串:
$ export AZURE_STORAGE_CONNECTION_STRING='mysecret'用于账户名和密钥/令牌身份验证:
$ export AZURE_STORAGE_ACCOUNT='myaccount'
# and
$ export AZURE_STORAGE_KEY='mysecret'
# or
$ export AZURE_STORAGE_SAS_TOKEN='mysecret'用于通过证书文件的身份验证(服务主体):
$ export AZURE_TENANT_ID='directory-id'
$ export AZURE_CLIENT_ID='client-id'
$ export AZURE_CLIENT_CERTIFICATE_PATH='/path/to/certificate'用于简单的用户名/密码登录:
$ export AZURE_CLIENT_ID='client-id'
$ export AZURE_USERNAME='myuser'
$ export AZURE_PASSWORD='mysecret'通过 Azure CLI 配置文件进行身份验证
如果没有显式设置参数或环境变量,则以下值可从 Azure CLI 配置文件(通常通过 az config 管理)继承:connection_string、account_name、account_key、sas_token 和 container_name。
更多配置参数
有关更多命令使用细节,请参阅 dvc remote modify。
-
url- 修改远程位置(详见上方说明) -
timeout- 服务器端超时时间。默认为 30 秒。参见 文档 -
read_timeout- 客户端在上传或下载文件时,两次连续读取操作之间等待服务器响应的秒数。默认为 60 秒。参见 Azure 文档。 -
connection_timeout- 客户端在上传或下载文件时,建立与服务器连接的等待秒数。默认为 20 秒。参见 Azure 文档。 -
exclude_environment_credential- 如果为true,则排除 Azure Remote 的环境凭证源。参见 Azure 凭证文档。默认值为false。 -
exclude_visual_studio_code_credential- 如果为true,则排除 Azure Remote 的 Visual Studio Code 凭证源。参见 Azure 凭证文档。默认值为false。 -
exclude_shared_token_cache_credential- 如果为true,则排除 Azure Remote 的共享令牌缓存凭证源。参见 Azure 凭证文档。默认值为false。 -
exclude_managed_identity_credential- 如果为true,则排除 Azure Remote 的托管身份凭证源。参见 Azure 凭证文档。默认值为false。