Opening a tracked file using python API: dvc.fs.azure.AzureAuthError: Authentication to Azure Blob Storage requires either account_name or connection_string

I’m trying to open a tracked file (blob storage Azure) and getting the following error.

Traceback (most recent call last):                                                                                                                                                              
  File "dvc_test.py", line 10, in <module>
    with dvc.api.open(
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/home/airudi/office/python_codes/test/venv/lib/python3.8/site-packages/dvc/api.py", line 76, in _open
    with _repo.open_by_relpath(
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/home/airudi/office/python_codes/test/venv/lib/python3.8/site-packages/dvc/repo/__init__.py", line 488, in open_by_relpath
    with fs.open(
  File "/home/airudi/office/python_codes/test/venv/lib/python3.8/site-packages/dvc/fs/repo.py", line 143, in open
    return dvc_fs.open(path_info, mode=mode, encoding=encoding, **kwargs)
  File "/home/airudi/office/python_codes/test/venv/lib/python3.8/site-packages/dvc/fs/dvc.py", line 79, in open
    remote_obj = self.repo.cloud.get_remote(remote)
  File "/home/airudi/office/python_codes/test/venv/lib/python3.8/site-packages/dvc/data_cloud.py", line 29, in get_remote
    return self._init_remote(name)
  File "/home/airudi/office/python_codes/test/venv/lib/python3.8/site-packages/dvc/data_cloud.py", line 49, in _init_remote
    return get_remote(self.repo, name=name)
  File "/home/airudi/office/python_codes/test/venv/lib/python3.8/site-packages/dvc/remote/__init__.py", line 8, in get_remote
    fs = cls(**config)
  File "/home/airudi/office/python_codes/test/venv/lib/python3.8/site-packages/dvc/fs/azure.py", line 83, in __init__
    super().__init__(**config)
  File "/home/airudi/office/python_codes/test/venv/lib/python3.8/site-packages/dvc/fs/fsspec_wrapper.py", line 19, in __init__
    self.fs_args.update(self._prepare_credentials(**kwargs))
  File "/home/airudi/office/python_codes/test/venv/lib/python3.8/site-packages/dvc/fs/azure.py", line 119, in _prepare_credentials
    raise AzureAuthError(
dvc.fs.azure.AzureAuthError: Authentication to Azure Blob Storage requires either account_name or connection_string.
Learn more about configuration settings at <https://man.dvc.org/remote/modify>

Code snippet:

with dvc.api.open(
    "Risk_Identification_Models/pipelines/data/train_data.xlsx",
    repo="git@ssh.dev.azure.com:v3/aaa/bbb/ccc",
    remote="risk_model_remote",
    rev="hyper_param_opt_loop_0.82_f1_on_test",
    mode="rb",
) as fd:

It is worth noting that I have configured remote and connection strings.

dvc remote add -d risk_model_remote azure://aaa/data

dvc remote modify --local risk_model_remote connection_string 'xxx'

dvc push/pull are working as expected but the above error throws when I tried to use Python API.

I hope the following will help to debug this issue.

venv) ➜  .dvc git:(master) ✗ dvc doctor
DVC version: 2.3.0 (pip)
---------------------------------
Platform: Python 3.8.5 on Linux-5.8.0-55-generic-x86_64-with-glibc2.29
Supports: azure, http, https
Cache types: <https://error.dvc.org/no-dvc-cache>
Caches: local
Remotes: azure
Workspace directory: ext4 on /dev/nvme0n1p2
Repo: dvc, git

Hi @upul, this has been answered on github: dvc.api.read doesn't read data from Azure Blob Storage · Issue #6209 · iterative/dvc · GitHub - you need to use the local path for your cloned repo instead of the git@... URL in order for the DVC API to work with local remote configs