Repository: iterative/dvc

Issue:
Result inconsistency for `__call__`, `is_ignored_file` and `is_ignored_dir`
## Bug Report

### Please provide information about your setup

**Output of `dvc version`:**

```console
$ dvc version
```

master

**Additional Information (if any):**

If applicable, please also provide a `--verbose` output of the command, eg: `dvc add --verbose`.


Now there are several interfaces for the dvcignore. 
In `is_ignored_dir` we ignored all paths outside the repo.
https://github.com/iterative/dvc/blob/35dd1fda9cfb4b645ae431f4621f2d1853d4fb7c/dvc/ignore.py#L270-L272
In a direct call `__call__` all outside paths are included.
https://github.com/iterative/dvc/blob/35dd1fda9cfb4b645ae431f4621f2d1853d4fb7c/dvc/ignore.py#L241-L244
And in `is_ignored_files` there is a bug that makes us skipped "outside the repo" check and return False forever.
https://github.com/iterative/dvc/blob/35dd1fda9cfb4b645ae431f4621f2d1853d4fb7c/dvc/ignore.py#L275-L278

They should be unified. So in what condition do we need to mask files outside the repo? And should we put this logic in dvcignore?

Discussion:

Patch:
diff --git a/dvc/command/experiments.py b/dvc/command/experiments.py
index 34fcab00f..e74dcc53b 100644
--- a/dvc/command/experiments.py
+++ b/dvc/command/experiments.py
@@ -2,14 +2,57 @@ import argparse
 import io
 import logging
 from collections import OrderedDict
+from itertools import groupby
+from typing import Iterable, Optional
 
 from dvc.command.base import CmdBase, append_doc_link, fix_subparsers
 from dvc.command.metrics import DEFAULT_PRECISION
-from dvc.exceptions import DvcException
+from dvc.exceptions import DvcException, InvalidArgumentError
 
 logger = logging.getLogger(__name__)
 
 
+def _filter_names(
+    names: Iterable,
+    label: str,
+    include: Optional[Iterable],
+    exclude: Optional[Iterable],
+):
+    if include and exclude:
+        intersection = set(include) & set(exclude)
+        if intersection:
+            values = ", ".join(intersection)
+            raise InvalidArgumentError(
+                f"'{values}' specified in both --include-{label} and"
+                f" --exclude-{label}"
+            )
+
+    names = {tuple(name.split(".")) for name in names}
+
+    def _filter(filters, update_func):
+        filters = {tuple(name.split(".")) for name in filters}
+        for length, groups in groupby(filters, len):
+            for group in groups:
+                matches = [name for name in names if name[:length] == group]
+                if not matches:
+                    name = ".".join(group)
+                    raise InvalidArgumentError(
+                        f"'{name}' does not match any known {label}"
+                    )
+                update_func(matches)
+
+    if include:
+        ret = set()
+        _filter(include, ret.update)
+    else:
+        ret = set(names)
+
+    if exclude:
+        _filter(exclude, ret.difference_update)
+
+    return {".".join(name) for name in ret}
+
+
 def _update_names(names, items):
     from flatten_json import flatten
 
@@ -21,7 +64,7 @@ def _update_names(names, items):
             names.add(name)
 
 
-def _collect_names(all_experiments):
+def _collect_names(all_experiments, **kwargs):
     metric_names = set()
     param_names = set()
 
@@ -30,6 +73,19 @@ def _collect_names(all_experiments):
             _update_names(metric_names, exp.get("metrics", {}).items())
             _update_names(param_names, exp.get("params", {}).items())
 
+    metric_names = _filter_names(
+        metric_names,
+        "metrics",
+        kwargs.get("include_metrics"),
+        kwargs.get("exclude_metrics"),
+    )
+    param_names = _filter_names(
+        param_names,
+        "params",
+        kwargs.get("include_params"),
+        kwargs.get("exclude_params"),
+    )
+
     return sorted(metric_names), sorted(param_names)
 
 
@@ -83,11 +139,33 @@ def _collect_rows(
         yield row, style
 
 
-def _show_experiments(all_experiments, console, precision=None):
+def _parse_list(param_list):
+    ret = []
+    for param_str in param_list:
+        # we don't care about filename prefixes for show, silently
+        # ignore it if provided to keep usage consistent with other
+        # metric/param list command options
+        _, _, param_str = param_str.rpartition(":")
+        ret.extend(param_str.split(","))
+    return ret
+
+
+def _show_experiments(all_experiments, console, precision=None, **kwargs):
     from rich.table import Table
     from dvc.scm.git import Git
 
-    metric_names, param_names = _collect_names(all_experiments)
+    include_metrics = _parse_list(kwargs.get("include_metrics", []))
+    exclude_metrics = _parse_list(kwargs.get("exclude_metrics", []))
+    include_params = _parse_list(kwargs.get("include_params", []))
+    exclude_params = _parse_list(kwargs.get("exclude_params", []))
+
+    metric_names, param_names = _collect_names(
+        all_experiments,
+        include_metrics=include_metrics,
+        exclude_metrics=exclude_metrics,
+        include_params=include_params,
+        exclude_params=exclude_params,
+    )
 
     table = Table()
     table.add_column("Experiment", no_wrap=True)
@@ -136,7 +214,14 @@ class CmdExperimentsShow(CmdBase):
                     file=io.StringIO(), force_terminal=True, width=9999
                 )
 
-            _show_experiments(all_experiments, console)
+            _show_experiments(
+                all_experiments,
+                console,
+                include_metrics=self.args.include_metrics,
+                exclude_metrics=self.args.exclude_metrics,
+                include_params=self.args.include_params,
+                exclude_params=self.args.exclude_params,
+            )
 
             if not self.args.no_pager:
                 pager(console.file.getvalue())
@@ -285,6 +370,34 @@ def add_parser(subparsers, parent_parser):
         default=False,
         help="Do not pipe output into a pager.",
     )
+    experiments_show_parser.add_argument(
+        "--include-metrics",
+        action="append",
+        default=[],
+        help="Include the specified metrics in output table.",
+        metavar="<metrics_list>",
+    )
+    experiments_show_parser.add_argument(
+        "--exclude-metrics",
+        action="append",
+        default=[],
+        help="Exclude the specified metrics from output table.",
+        metavar="<metrics_list>",
+    )
+    experiments_show_parser.add_argument(
+        "--include-params",
+        action="append",
+        default=[],
+        help="Include the specified params in output table.",
+        metavar="<params_list>",
+    )
+    experiments_show_parser.add_argument(
+        "--exclude-params",
+        action="append",
+        default=[],
+        help="Exclude the specified params from output table.",
+        metavar="<params_list>",
+    )
     experiments_show_parser.set_defaults(func=CmdExperimentsShow)
 
     EXPERIMENTS_CHECKOUT_HELP = "Checkout experiments."
diff --git a/dvc/command/imp_url.py b/dvc/command/imp_url.py
index 4451b8e29..eb19896f7 100644
--- a/dvc/command/imp_url.py
+++ b/dvc/command/imp_url.py
@@ -42,20 +42,16 @@ def add_parser(subparsers, parent_parser):
     )
     import_parser.add_argument(
         "url",
-        help="Supported urls:\n"
-        "/path/to/file\n"
-        "/path/to/directory\n"
-        "C:\\\\path\\to\\file\n"
-        "C:\\\\path\\to\\directory\n"
+        help="Location of the data to download. Supported URLs:\n"
+        "/absolute/path/to/file/or/dir\n"
+        "relative/path/to/file/or/dir\n"
+        "C:\\\\path\\to\\file\\or\\dir\n"
         "https://example.com/path/to/file\n"
-        "s3://bucket/path/to/file\n"
-        "s3://bucket/path/to/directory\n"
-        "gs://bucket/path/to/file\n"
-        "gs://bucket/path/to/directory\n"
+        "s3://bucket/key/path\n"
+        "gs://bucket/path/to/file/or/dir\n"
         "hdfs://example.com/path/to/file\n"
-        "ssh://example.com:/path/to/file\n"
-        "ssh://example.com:/path/to/directory\n"
-        "remote://myremote/path/to/file (see `dvc remote`)",
+        "ssh://example.com/absolute/path/to/file/or/dir\n"
+        "remote://remote_name/path/to/file/or/dir (see `dvc remote`)",
     )
     import_parser.add_argument(
         "out", nargs="?", help="Destination path to put files to.",
diff --git a/dvc/command/remote.py b/dvc/command/remote.py
index 1cb4a3a86..de3f56653 100644
--- a/dvc/command/remote.py
+++ b/dvc/command/remote.py
@@ -172,7 +172,7 @@ def add_parser(subparsers, parent_parser):
     remote_add_parser.add_argument("name", help="Name of the remote")
     remote_add_parser.add_argument(
         "url",
-        help="URL. See full list of supported urls at {}".format(
+        help="Remote location. See full list of supported URLs at {}".format(
             format_link("https://man.dvc.org/remote")
         ),
     )
@@ -201,7 +201,7 @@ def add_parser(subparsers, parent_parser):
         formatter_class=argparse.RawDescriptionHelpFormatter,
     )
     remote_default_parser.add_argument(
-        "name", nargs="?", help="Name of the remote."
+        "name", nargs="?", help="Name of the remote"
     )
     remote_default_parser.add_argument(
         "-u",
@@ -220,7 +220,7 @@ def add_parser(subparsers, parent_parser):
         help=REMOTE_MODIFY_HELP,
         formatter_class=argparse.RawDescriptionHelpFormatter,
     )
-    remote_modify_parser.add_argument("name", help="Name of the remote.")
+    remote_modify_parser.add_argument("name", help="Name of the remote")
     remote_modify_parser.add_argument(
         "option", help="Name of the option to modify."
     )
diff --git a/dvc/ignore.py b/dvc/ignore.py
index 71569b38b..ea93db805 100644
--- a/dvc/ignore.py
+++ b/dvc/ignore.py
@@ -64,7 +64,7 @@ class DvcIgnorePatterns(DvcIgnore):
                 for line_no, line in enumerate(
                     map(str.strip, fobj.readlines())
                 )
-                if line
+                if line and not (line.strip().startswith("#"))
             ]
 
         return cls(path_spec_lines, dirname)
@@ -274,7 +274,7 @@ class DvcIgnoreFilter:
 
     def _is_ignored(self, path, is_dir=False):
         if self._outside_repo(path):
-            return True
+            return False
         dirname, basename = os.path.split(os.path.normpath(path))
         ignore_pattern = self._get_trie_pattern(dirname)
         if ignore_pattern:
@@ -296,6 +296,7 @@ class DvcIgnoreFilter:
         return self._is_ignored(path, True)
 
     def is_ignored_file(self, path):
+        path = os.path.abspath(path)
         return self._is_ignored(path, False)
 
     def _outside_repo(self, path):
@@ -325,3 +326,18 @@ class DvcIgnoreFilter:
                 if matches:
                     return CheckIgnoreResult(target, True, matches)
         return CheckIgnoreResult(target, False, ["::"])
+
+
+def init(path):
+    dvcignore = os.path.join(path, DvcIgnore.DVCIGNORE_FILE)
+    if os.path.exists(dvcignore):
+        return dvcignore
+
+    with open(dvcignore, "w") as fobj:
+        fobj.write(
+            "# Add patterns of files dvc should ignore, which could improve\n"
+            "# the performance. Learn more at\n"
+            "# https://dvc.org/doc/user-guide/dvcignore\n"
+        )
+
+    return dvcignore
diff --git a/dvc/repo/init.py b/dvc/repo/init.py
index 695d83bcb..67701c99d 100644
--- a/dvc/repo/init.py
+++ b/dvc/repo/init.py
@@ -6,6 +6,7 @@ import colorama
 from dvc import analytics
 from dvc.config import Config
 from dvc.exceptions import InitError, InvalidArgumentError
+from dvc.ignore import init as init_dvcignore
 from dvc.repo import Repo
 from dvc.scm import SCM
 from dvc.scm.base import SCMError
@@ -99,9 +100,13 @@ def init(root_dir=os.curdir, no_scm=False, force=False, subdir=False):
         with config.edit() as conf:
             conf["core"]["no_scm"] = True
 
+    dvcignore = init_dvcignore(root_dir)
+
     proj = Repo(root_dir)
 
-    scm.add([config.files["repo"], proj.plot_templates.templates_dir])
+    scm.add(
+        [config.files["repo"], dvcignore, proj.plot_templates.templates_dir]
+    )
 
     if scm.ignore_file:
         scm.add([os.path.join(dvc_dir, scm.ignore_file)])
diff --git a/dvc/tree/azure.py b/dvc/tree/azure.py
index 19f9ecdcb..78ada11b8 100644
--- a/dvc/tree/azure.py
+++ b/dvc/tree/azure.py
@@ -35,16 +35,20 @@ class AzureTree(BaseTree):
             container = self._az_config.get("storage", "container_name", None)
             self.path_info = self.PATH_CLS(f"azure://{container}")
 
-        self._conn_kwargs = {
-            opt: config.get(opt) or self._az_config.get("storage", opt, None)
-            for opt in ["connection_string", "sas_token"]
-        }
-        self._conn_kwargs["account_name"] = self._az_config.get(
-            "storage", "account", None
-        )
-        self._conn_kwargs["account_key"] = self._az_config.get(
-            "storage", "key", None
+        self._conn_str = config.get(
+            "connection_string"
+        ) or self._az_config.get("storage", "connection_string", None)
+
+        self._account_url = None
+        if not self._conn_str:
+            name = self._az_config.get("storage", "account", None)
+            self._account_url = f"https://{name}.blob.core.windows.net"
+
+        self._credential = config.get("sas_token") or self._az_config.get(
+            "storage", "sas_token", None
         )
+        if not self._credential:
+            self._credential = self._az_config.get("storage", "key", None)
 
     @cached_property
     def _az_config(self):
@@ -62,64 +66,71 @@ class AzureTree(BaseTree):
     @cached_property
     def blob_service(self):
         # pylint: disable=no-name-in-module
-        from azure.storage.blob import BlockBlobService
-        from azure.common import AzureMissingResourceHttpError
+        from azure.storage.blob import BlobServiceClient
+        from azure.core.exceptions import ResourceNotFoundError
 
         logger.debug(f"URL {self.path_info}")
-        logger.debug(f"Connection options {self._conn_kwargs}")
-        blob_service = BlockBlobService(**self._conn_kwargs)
+
+        if self._conn_str:
+            logger.debug(f"Using connection string '{self._conn_str}'")
+            blob_service = BlobServiceClient.from_connection_string(
+                self._conn_str, credential=self._credential
+            )
+        else:
+            logger.debug(f"Using account url '{self._account_url}'")
+            blob_service = BlobServiceClient(
+                self._account_url, credential=self._credential
+            )
+
         logger.debug(f"Container name {self.path_info.bucket}")
+        container_client = blob_service.get_container_client(
+            self.path_info.bucket
+        )
+
         try:  # verify that container exists
-            blob_service.list_blobs(
-                self.path_info.bucket, delimiter="/", num_results=1
-            )
-        except AzureMissingResourceHttpError:
-            blob_service.create_container(self.path_info.bucket)
+            container_client.get_container_properties()
+        except ResourceNotFoundError:
+            container_client.create_container()
+
         return blob_service
 
     def get_etag(self, path_info):
-        etag = self.blob_service.get_blob_properties(
+        blob_client = self.blob_service.get_blob_client(
             path_info.bucket, path_info.path
-        ).properties.etag
+        )
+        etag = blob_client.get_blob_properties().etag
         return etag.strip('"')
 
     def _generate_download_url(self, path_info, expires=3600):
         from azure.storage.blob import (  # pylint:disable=no-name-in-module
-            BlobPermissions,
+            BlobSasPermissions,
+            generate_blob_sas,
         )
 
         expires_at = datetime.utcnow() + timedelta(seconds=expires)
 
-        sas_token = self.blob_service.generate_blob_shared_access_signature(
-            path_info.bucket,
-            path_info.path,
-            permission=BlobPermissions.READ,
-            expiry=expires_at,
+        blob_client = self.blob_service.get_blob_client(
+            path_info.bucket, path_info.path
         )
-        download_url = self.blob_service.make_blob_url(
-            path_info.bucket, path_info.path, sas_token=sas_token
+
+        sas_token = generate_blob_sas(
+            blob_client.account_name,
+            blob_client.container_name,
+            blob_client.blob_name,
+            account_key=blob_client.credential.account_key,
+            permission=BlobSasPermissions(read=True),
+            expiry=expires_at,
         )
-        return download_url
+        return blob_client.url + "?" + sas_token
 
     def exists(self, path_info, use_dvcignore=True):
         paths = self._list_paths(path_info.bucket, path_info.path)
         return any(path_info.path == path for path in paths)
 
     def _list_paths(self, bucket, prefix):
-        blob_service = self.blob_service
-        next_marker = None
-        while True:
-            blobs = blob_service.list_blobs(
-                bucket, prefix=prefix, marker=next_marker
-            )
-
-            for blob in blobs:
-                yield blob.name
-
-            if not blobs.next_marker:
-                break
-
-            next_marker = blobs.next_marker
+        container_client = self.blob_service.get_container_client(bucket)
+        for blob in container_client.list_blobs(name_starts_with=prefix):
+            yield blob.name
 
     def walk_files(self, path_info, **kwargs):
         if not kwargs.pop("prefix", False):
@@ -137,7 +148,9 @@ class AzureTree(BaseTree):
             raise NotImplementedError
 
         logger.debug(f"Removing {path_info}")
-        self.blob_service.delete_blob(path_info.bucket, path_info.path)
+        self.blob_service.get_blob_client(
+            path_info.bucket, path_info.path
+        ).delete_blob()
 
     def get_file_hash(self, path_info):
         return self.get_etag(path_info)
@@ -145,21 +158,27 @@ class AzureTree(BaseTree):
     def _upload(
         self, from_file, to_info, name=None, no_progress_bar=False, **_kwargs
     ):
-        with Tqdm(desc=name, disable=no_progress_bar, bytes=True) as pbar:
-            self.blob_service.create_blob_from_path(
-                to_info.bucket,
-                to_info.path,
-                from_file,
-                progress_callback=pbar.update_to,
-            )
+
+        blob_client = self.blob_service.get_blob_client(
+            to_info.bucket, to_info.path
+        )
+        total = os.path.getsize(from_file)
+        with open(from_file, "rb") as fobj:
+            with Tqdm.wrapattr(
+                fobj, "read", desc=name, total=total, disable=no_progress_bar
+            ) as wrapped:
+                blob_client.upload_blob(wrapped)
 
     def _download(
         self, from_info, to_file, name=None, no_progress_bar=False, **_kwargs
     ):
-        with Tqdm(desc=name, disable=no_progress_bar, bytes=True) as pbar:
-            self.blob_service.get_blob_to_path(
-                from_info.bucket,
-                from_info.path,
-                to_file,
-                progress_callback=pbar.update_to,
-            )
+        blob_client = self.blob_service.get_blob_client(
+            from_info.bucket, from_info.path
+        )
+        total = blob_client.get_blob_properties().size
+        stream = blob_client.download_blob()
+        with open(to_file, "wb") as fobj:
+            with Tqdm.wrapattr(
+                fobj, "write", desc=name, total=total, disable=no_progress_bar
+            ) as wrapped:
+                stream.readinto(wrapped)
diff --git a/dvc/version.py b/dvc/version.py
index 3cecdfd93..3d59c1b6e 100644
--- a/dvc/version.py
+++ b/dvc/version.py
@@ -6,7 +6,7 @@
 import os
 import subprocess
 
-_BASE_VERSION = "1.4.0"
+_BASE_VERSION = "1.5.0"
 
 
 def _generate_version(base_version):
diff --git a/setup.py b/setup.py
index ed4c1c309..300b5a23b 100644
--- a/setup.py
+++ b/setup.py
@@ -89,7 +89,7 @@ install_requires = [
 gs = ["google-cloud-storage==1.19.0"]
 gdrive = ["pydrive2>=1.4.14"]
 s3 = ["boto3>=1.9.201"]
-azure = ["azure-storage-blob==2.1.0", "knack"]
+azure = ["azure-storage-blob>=12.0", "knack"]
 oss = ["oss2==2.6.1"]
 ssh = ["paramiko>=2.5.0"]
 hdfs = ["pyarrow>=0.17.0"]


Test patch:
diff --git a/tests/func/test_ignore.py b/tests/func/test_ignore.py
index 042329f79..b68f0f4f7 100644
--- a/tests/func/test_ignore.py
+++ b/tests/func/test_ignore.py
@@ -132,6 +132,7 @@ def test_ignore_on_branch(tmp_dir, scm, dvc):
     assert set(dvc.tree.walk_files(path)) == {
         path / "foo",
         path / "bar",
+        path / ".dvcignore",
     }
 
     dvc.tree = scm.get_tree("branch", use_dvcignore=True)
@@ -158,10 +159,17 @@ def test_match_nested(tmp_dir, dvc):
 def test_ignore_external(tmp_dir, scm, dvc, tmp_path_factory):
     tmp_dir.gen(".dvcignore", "*.backup\ntmp")
     ext_dir = TmpDir(os.fspath(tmp_path_factory.mktemp("external_dir")))
-    ext_dir.gen({"y.backup": "y", "tmp": "ext tmp"})
+    ext_dir.gen({"y.backup": "y", "tmp": {"file": "ext tmp"}})
 
     result = {relpath(f, ext_dir) for f in dvc.tree.walk_files(ext_dir)}
-    assert result == {"y.backup", "tmp"}
+    assert result == {"y.backup", os.path.join("tmp", "file")}
+    assert (
+        dvc.tree.dvcignore.is_ignored_dir(os.fspath(ext_dir / "tmp")) is False
+    )
+    assert (
+        dvc.tree.dvcignore.is_ignored_file(os.fspath(ext_dir / "y.backup"))
+        is False
+    )
 
 
 def test_ignore_subrepo(tmp_dir, scm, dvc):
diff --git a/tests/func/test_init.py b/tests/func/test_init.py
index 00fd8c90d..4ea9c9101 100644
--- a/tests/func/test_init.py
+++ b/tests/func/test_init.py
@@ -101,3 +101,13 @@ def test_subdir_init_no_option(tmp_dir, scm, monkeypatch, caplog):
         "`--subdir` if initializing inside a subdirectory of a parent SCM "
         "repository.".format(os.fspath(tmp_dir / "subdir"))
     ) in caplog.text
+
+
+def test_gen_dvcignore(tmp_dir):
+    DvcRepo.init(no_scm=True)
+    text = (
+        "# Add patterns of files dvc should ignore, which could improve\n"
+        "# the performance. Learn more at\n"
+        "# https://dvc.org/doc/user-guide/dvcignore\n"
+    )
+    assert text == (tmp_dir / ".dvcignore").read_text()
diff --git a/tests/func/test_ls.py b/tests/func/test_ls.py
index 85dd9eb1b..4c2681d52 100644
--- a/tests/func/test_ls.py
+++ b/tests/func/test_ls.py
@@ -61,6 +61,7 @@ def test_ls_repo(tmp_dir, dvc, scm):
     match_files(
         files,
         (
+            ((".dvcignore",), False),
             ((".gitignore",), False),
             (("README.md",), False),
             (("structure.xml.dvc",), False),
@@ -89,6 +90,7 @@ def test_ls_repo_with_color(tmp_dir, dvc, scm, mocker, monkeypatch, caplog):
 
     assert caplog.records[-1].msg == "\n".join(
         [
+            ".dvcignore",
             ".gitignore",
             "README.md",
             "\x1b[01;34mdata\x1b[0m",
@@ -107,6 +109,7 @@ def test_ls_repo_recursive(tmp_dir, dvc, scm):
     match_files(
         files,
         (
+            ((".dvcignore",), False),
             ((".gitignore",), False),
             (("README.md",), False),
             (("structure.xml.dvc",), False),
@@ -258,6 +261,7 @@ def test_ls_repo_with_removed_dvc_dir(tmp_dir, dvc, scm):
             (("out.dvc",), False),
             (("dep",), True),
             (("out",), False),
+            ((".dvcignore",), False),
             ((".gitignore",), False),
         ),
     )
@@ -275,6 +279,7 @@ def test_ls_repo_with_removed_dvc_dir_recursive(tmp_dir, dvc, scm):
             (("out.dvc",), False),
             (("dep",), True),
             (("out", "file"), True),
+            ((".dvcignore",), False),
             ((".gitignore",), False),
         ),
     )
@@ -306,6 +311,7 @@ def test_ls_remote_repo(erepo_dir):
     match_files(
         files,
         (
+            ((".dvcignore",), False),
             ((".gitignore",), False),
             (("README.md",), False),
             (("structure.xml.dvc",), False),
@@ -326,6 +332,7 @@ def test_ls_remote_repo_recursive(erepo_dir):
     match_files(
         files,
         (
+            ((".dvcignore",), False),
             ((".gitignore",), False),
             (("README.md",), False),
             (("structure.xml.dvc",), False),
@@ -393,6 +400,7 @@ def test_ls_remote_repo_with_rev(erepo_dir):
     match_files(
         files,
         (
+            ((".dvcignore",), False),
             ((".gitignore",), False),
             (("README.md",), False),
             (("model",), False),
@@ -422,6 +430,7 @@ def test_ls_remote_repo_with_rev_recursive(erepo_dir):
             (("model", "people.csv"), True),
             (("model", ".gitignore"), False),
             (("structure.xml",), True),
+            ((".dvcignore",), False),
             ((".gitignore",), False),
         ),
     )
diff --git a/tests/remotes/azure.py b/tests/remotes/azure.py
index 8dae521d2..27db33298 100644
--- a/tests/remotes/azure.py
+++ b/tests/remotes/azure.py
@@ -25,10 +25,10 @@ class Azure(Base, CloudURLInfo):
 @pytest.fixture(scope="session")
 def azure_server(docker_compose, docker_services):
     from azure.storage.blob import (  # pylint: disable=no-name-in-module
-        BlockBlobService,
+        BlobServiceClient,
     )
-    from azure.common import (  # pylint: disable=no-name-in-module
-        AzureException,
+    from azure.core.exceptions import (  # pylint: disable=no-name-in-module
+        AzureError,
     )
 
     port = docker_services.port_for("azurite", 10000)
@@ -36,11 +36,11 @@ def azure_server(docker_compose, docker_services):
 
     def _check():
         try:
-            BlockBlobService(
-                connection_string=connection_string,
+            BlobServiceClient.from_connection_string(
+                connection_string
             ).list_containers()
             return True
-        except AzureException:
+        except AzureError:
             return False
 
     docker_services.wait_until_responsive(
diff --git a/tests/unit/remote/test_azure.py b/tests/unit/remote/test_azure.py
index 0af52f046..a0614bcf6 100644
--- a/tests/unit/remote/test_azure.py
+++ b/tests/unit/remote/test_azure.py
@@ -17,7 +17,7 @@ def test_init_env_var(monkeypatch, dvc):
     config = {"url": "azure://"}
     tree = AzureTree(dvc, config)
     assert tree.path_info == "azure://" + container_name
-    assert tree._conn_kwargs["connection_string"] == connection_string
+    assert tree._conn_str == connection_string
 
 
 def test_init(dvc):
@@ -26,7 +26,7 @@ def test_init(dvc):
     config = {"url": url, "connection_string": connection_string}
     tree = AzureTree(dvc, config)
     assert tree.path_info == url
-    assert tree._conn_kwargs["connection_string"] == connection_string
+    assert tree._conn_str == connection_string
 
 
 def test_get_file_hash(tmp_dir, azure):