nailo2c commented on code in PR #67600:
URL: https://github.com/apache/airflow/pull/67600#discussion_r3565935028


##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/batch.py:
##########
@@ -101,20 +103,23 @@ def get_conn(self) -> BatchServiceClient:
         if not batch_account_url:
             raise AirflowException("Batch Account URL parameter is missing.")
 
-        credentials: batch_auth.SharedKeyCredentials | 
AzureIdentityCredentialAdapter
-        if all([conn.login, conn.password]):
-            credentials = batch_auth.SharedKeyCredentials(conn.login, 
conn.password)
+        credential: AzureNamedKeyCredential | AzureIdentityCredentialAdapter
+        if conn.login and conn.password:
+            credential = AzureNamedKeyCredential(conn.login, conn.password)
         else:
             managed_identity_client_id = 
conn.extra_dejson.get("managed_identity_client_id")
             workload_identity_tenant_id = 
conn.extra_dejson.get("workload_identity_tenant_id")
-            credentials = AzureIdentityCredentialAdapter(
+            credential = AzureIdentityCredentialAdapter(
                 None,
                 resource_id="https://batch.core.windows.net/.default";,
                 managed_identity_client_id=managed_identity_client_id,
                 workload_identity_tenant_id=workload_identity_tenant_id,
             )
 
-        batch_client = BatchServiceClient(credentials, 
batch_url=batch_account_url)
+        batch_client = BatchClient(
+            endpoint=batch_account_url,
+            credential=credential,  # type: ignore[arg-type]

Review Comment:
   I wonder why we need to ignore the type here.
   
   According to the [BatchClient 
doc](https://learn.microsoft.com/en-us/python/api/azure-batch/azure.batch.batchclient?view=azure-python),
 `credential` should be either `AzureNamedKeyCredential` or `TokenCredential`. 
If `credential` is an `AzureIdentityCredentialAdapter`, as shown on line 112, 
will it still work?



-- 
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