@@ -132,7 +132,7 @@ def get_ui_field_behaviour() -> dict[str, Any]:
132
132
"relabeling" : {
133
133
"login" : "Blob Storage Login (optional)" ,
134
134
"password" : "Blob Storage Key (optional)" ,
135
- "host" : "Account Name (Active Directory Auth)" ,
135
+ "host" : "Account URL (Active Directory Auth)" ,
136
136
},
137
137
"placeholders" : {
138
138
"login" : "account name" ,
@@ -154,7 +154,7 @@ def __init__(
154
154
super ().__init__ ()
155
155
self .conn_id = wasb_conn_id
156
156
self .public_read = public_read
157
- self .blob_service_client = self .get_conn ()
157
+ self .blob_service_client : BlobServiceClient = self .get_conn ()
158
158
159
159
logger = logging .getLogger ("azure.core.pipeline.policies.http_logging_policy" )
160
160
try :
@@ -184,15 +184,19 @@ def get_conn(self) -> BlobServiceClient:
184
184
# connection_string auth takes priority
185
185
return BlobServiceClient .from_connection_string (connection_string , ** extra )
186
186
187
+ account_url = (
188
+ conn .host
189
+ if conn .host and conn .host .startswith ("https://" )
190
+ else f"https://{ conn .login } .blob.core.windows.net/"
191
+ )
192
+
187
193
tenant = self ._get_field (extra , "tenant_id" )
188
194
if tenant :
189
195
# use Active Directory auth
190
196
app_id = conn .login
191
197
app_secret = conn .password
192
198
token_credential = ClientSecretCredential (tenant , app_id , app_secret , ** client_secret_auth_config )
193
- return BlobServiceClient (account_url = conn .host , credential = token_credential , ** extra )
194
-
195
- account_url = conn .host if conn .host else f"https://{ conn .login } .blob.core.windows.net/"
199
+ return BlobServiceClient (account_url = account_url , credential = token_credential , ** extra )
196
200
197
201
if self .public_read :
198
202
# Here we use anonymous public read
@@ -210,19 +214,13 @@ def get_conn(self) -> BlobServiceClient:
210
214
if sas_token .startswith ("https" ):
211
215
return BlobServiceClient (account_url = sas_token , ** extra )
212
216
else :
213
- if not account_url .startswith ("https://" ):
214
- # TODO: require url in the host field in the next major version?
215
- account_url = f"https://{ conn .login } .blob.core.windows.net"
216
217
return BlobServiceClient (account_url = f"{ account_url .rstrip ('/' )} /{ sas_token } " , ** extra )
217
218
218
219
# Fall back to old auth (password) or use managed identity if not provided.
219
220
credential = conn .password
220
221
if not credential :
221
222
credential = DefaultAzureCredential ()
222
223
self .log .info ("Using DefaultAzureCredential as credential" )
223
- if not account_url .startswith ("https://" ):
224
- # TODO: require url in the host field in the next major version?
225
- account_url = f"https://{ conn .login } .blob.core.windows.net/"
226
224
return BlobServiceClient (
227
225
account_url = account_url ,
228
226
credential = credential ,
@@ -589,6 +587,12 @@ async def get_async_conn(self) -> AsyncBlobServiceClient:
589
587
)
590
588
return self .blob_service_client
591
589
590
+ account_url = (
591
+ conn .host
592
+ if conn .host and conn .host .startswith ("https://" )
593
+ else f"https://{ conn .login } .blob.core.windows.net/"
594
+ )
595
+
592
596
tenant = self ._get_field (extra , "tenant_id" )
593
597
if tenant :
594
598
# use Active Directory auth
@@ -598,12 +602,10 @@ async def get_async_conn(self) -> AsyncBlobServiceClient:
598
602
tenant , app_id , app_secret , ** client_secret_auth_config
599
603
)
600
604
self .blob_service_client = AsyncBlobServiceClient (
601
- account_url = conn . host , credential = token_credential , ** extra # type:ignore[arg-type]
605
+ account_url = account_url , credential = token_credential , ** extra # type:ignore[arg-type]
602
606
)
603
607
return self .blob_service_client
604
608
605
- account_url = conn .host if conn .host else f"https://{ conn .login } .blob.core.windows.net/"
606
-
607
609
if self .public_read :
608
610
# Here we use anonymous public read
609
611
# more info
@@ -625,7 +627,7 @@ async def get_async_conn(self) -> AsyncBlobServiceClient:
625
627
self .blob_service_client = AsyncBlobServiceClient (account_url = sas_token , ** extra )
626
628
else :
627
629
self .blob_service_client = AsyncBlobServiceClient (
628
- account_url = f"{ account_url } /{ sas_token } " , ** extra
630
+ account_url = f"{ account_url . rstrip ( '/' ) } /{ sas_token } " , ** extra
629
631
)
630
632
return self .blob_service_client
631
633
0 commit comments