dabla commented on code in PR #77376:
URL: https://github.com/apache/airflow/pull/77376#discussion_r4641138872


##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/fs/adls.py:
##########
@@ -77,8 +77,22 @@ def get_fs(conn_id: str | None, storage_options: dict[str, 
Any] | None = None) -
         # is the storage account name rather than part of an account URL.
         options["account_name"] = account_name
     elif conn_type != "adls" or conn.host or not tenant_id:
-        # WASB, full-URL, and custom-endpoint connections keep the historical 
account_url path.
-        options["account_url"] = parse_blob_account_url(conn.host, conn.login)
+        # adlfs has no account_url parameter and would silently drop it; it 
reads
+        # account_name and builds the URL from account_host, so derive both 
from
+        # the account URL. Only an endpoint host (one with a dot) supplies an
+        # account_host: a bare identifier is not an endpoint, and for those
+        # parse_blob_account_url builds the URL from the login. A bare login is
+        # the account name (wasb shared key), but with a tenant id the login 
is a
+        # service principal client id, so without an endpoint host nothing is
+        # derived and adlfs falls back to account_name from extras or the
+        # AZURE_STORAGE_ACCOUNT_NAME env var.
+        host_is_endpoint = bool(conn.host) and "." in 
conn.host.split("://")[-1]
+        if host_is_endpoint or (conn.login and not tenant_id):
+            account_url = urlparse(parse_blob_account_url(conn.host, 
conn.login))
+            if account_url.hostname:
+                options["account_name"] = account_url.hostname.split(".")[0]
+            if host_is_endpoint and account_url.netloc:
+                options["account_host"] = account_url.netloc

Review Comment:
   **[warning]** A `dfs` endpoint in `host` becomes the `account_host`, so 
adlfs builds its Blob client against the Data Lake endpoint.
   
   adlfs is a Blob client: without `account_host` it always builds 
`https://{account_name}.blob.core.windows.net` 
([spec.py#L530-L566](https://github.com/fsspec/adlfs/blob/2026.5.0/adlfs/spec.py#L530-L566)),
 also for `abfss://` paths. With this line, an `adls` connection whose host is 
`<account>.dfs.core.windows.net` (the endpoint an ADLS user naturally has, and 
one of the three shapes the PR description lists) gets 
`account_host="<account>.dfs.core.windows.net"`. I ran this head against adlfs 
2026.8.0:
   
   | Connection | `main` | this PR |
   | --- | --- | --- |
   | `adls`, host `acct.dfs.core.windows.net`, service principal | `ValueError` 
| `fs.account_url == "https://acct.dfs.core.windows.net"` |
   | same, plus `account_name` in Extra | `https://acct.blob.core.windows.net` 
| `https://acct.dfs.core.windows.net` |
   
   The second row is a connection that works today (the dropped `account_url` 
left adlfs on the blob endpoint) and now changes endpoint. Blob and Data Lake 
are separate endpoints with separate REST APIs ([standard 
endpoints](https://learn.microsoft.com/en-us/azure/storage/common/storage-account-overview#standard-endpoints)),
 so I would not send Blob calls to the `dfs` one.
   
   The same line also changes plain blob hosts, because `account_host` is set 
for the default endpoint too and adlfs builds the URL from `account_host` 
before `account_name` 
([spec.py#L548-L553](https://github.com/fsspec/adlfs/blob/2026.8.0/adlfs/spec.py#L548-L553)).
 Setting `account_name` in Extra is the workaround #77371 names, so such 
connections exist. With `host="https://acct.blob.core.windows.net"` and 
`{"account_name": "other"}` in Extra:
   
   | | `fs.account_name` | `fs.account_url` |
   | --- | --- | --- |
   | `main` | `other` | `https://other.blob.core.windows.net` |
   | this PR | `other` | `https://acct.blob.core.windows.net` |
   
   The filesystem reports one account and talks to another, while the 
description says an explicit `account_name` still wins. Setting `account_host` 
only when the netloc differs from `f"{account_name}.blob.core.windows.net"` 
keeps that override working and still preserves sovereign clouds, private 
endpoints and custom domains.
   
   Suggestion for the `dfs` case: map the service label back before setting it 
(`.dfs.` → `.blob.` in the netloc), which also keeps sovereign-cloud hosts 
working, and add the `dfs` host with a service principal to 
`test_get_fs_with_real_filesystem`, asserting `fs.account_url`. That test 
currently builds the real filesystem for two of the three shapes the 
description names; the service-principal-with-URL and `adls` full-endpoint ones 
are only covered through the mock.



##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/fs/adls.py:
##########
@@ -77,8 +77,22 @@ def get_fs(conn_id: str | None, storage_options: dict[str, 
Any] | None = None) -
         # is the storage account name rather than part of an account URL.
         options["account_name"] = account_name
     elif conn_type != "adls" or conn.host or not tenant_id:
-        # WASB, full-URL, and custom-endpoint connections keep the historical 
account_url path.
-        options["account_url"] = parse_blob_account_url(conn.host, conn.login)
+        # adlfs has no account_url parameter and would silently drop it; it 
reads
+        # account_name and builds the URL from account_host, so derive both 
from
+        # the account URL. Only an endpoint host (one with a dot) supplies an
+        # account_host: a bare identifier is not an endpoint, and for those
+        # parse_blob_account_url builds the URL from the login. A bare login is
+        # the account name (wasb shared key), but with a tenant id the login 
is a
+        # service principal client id, so without an endpoint host nothing is
+        # derived and adlfs falls back to account_name from extras or the
+        # AZURE_STORAGE_ACCOUNT_NAME env var.
+        host_is_endpoint = bool(conn.host) and "." in 
conn.host.split("://")[-1]

Review Comment:
   **[nit]** A second "is this host an endpoint" rule next to 
`_bare_account_name_from_host`.
   
   The module already has one classifier for bare name versus endpoint, a few 
lines up, and it works on the parsed hostname. This line adds another that 
looks for a dot anywhere after the scheme, so the two disagree on a host whose 
only dot is in the path (`myaccount/some.path`): the helper says "not bare", 
this says "endpoint", `parse_blob_account_url` then builds the URL from the 
login, and with a tenant id the client id ends up as `account_name` and in 
`account_host`. Reusing the hostname the helper already parses (or having it 
return it) keeps one rule in the module.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to