Skip to content

Commit f74b638

Browse files
friggogCharlie Hewittisidentical
authored
azure: use account_name with default credentials (#5725)
* Fix DefaultAzureCredential usage * Fix typo and printout * Update dvc/fs/azure.py Co-authored-by: Batuhan Taskaya <[email protected]> * Disable logging spam * Run precommit hook Co-authored-by: Charlie Hewitt <[email protected]> Co-authored-by: Batuhan Taskaya <[email protected]>
1 parent ddb1ece commit f74b638

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

dvc/fs/azure.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def __init__(self, repo, config):
5151
def _prepare_credentials(self, config):
5252
from azure.identity.aio import DefaultAzureCredential
5353

54+
# Disable spam from failed cred types for DefaultAzureCredential
55+
logging.getLogger("azure.identity.aio").setLevel(logging.ERROR)
56+
5457
login_info = {}
5558
login_info["connection_string"] = config.get(
5659
"connection_string",
@@ -69,8 +72,12 @@ def _prepare_credentials(self, config):
6972
login_info["client_id"] = config.get("client_id")
7073
login_info["client_secret"] = config.get("client_secret")
7174

72-
if not any(login_info.values()):
73-
login_info["credentials"] = DefaultAzureCredential()
75+
if not any(
76+
value for key, value in login_info.items() if key != "account_name"
77+
):
78+
login_info["credential"] = DefaultAzureCredential(
79+
exclude_interactive_browser_credential=False
80+
)
7481

7582
for login_method, required_keys in [ # noqa
7683
("connection string", ["connection_string"]),
@@ -80,8 +87,11 @@ def _prepare_credentials(self, config):
8087
),
8188
("account key", ["account_name", "account_key"]),
8289
("SAS token", ["account_name", "sas_token"]),
90+
(
91+
f"default credentials ({_DEFAULT_CREDS_STEPS})",
92+
["account_name", "credential"],
93+
),
8394
("anonymous login", ["account_name"]),
84-
(f"default credentials ({_DEFAULT_CREDS_STEPS})", ["credentials"]),
8595
]:
8696
if all(login_info.get(key) is not None for key in required_keys):
8797
break

0 commit comments

Comments
 (0)