Skip to content

azure-ai-ml: Support async clients #46496

@cecheta

Description

@cecheta

Is your feature request related to a problem? Please describe.
I would like to use async Azure clients when running jobs in Azure ML. To authenicate, I have to use AzureMLOnBehalfOfCredential, which is synchronous. There is an async AzureMLOnBehalfOfCredential at azure.ai.ml.identity._credentials.aml_on_behalf_of.py. but it doesn't work.

_AzureMLOnBehalfOfCredential.get_token failed: 'AsyncManagedIdentityClient' object has no attribute
'_identity_config'
Traceback (most recent call last):
  File "/mnt/azureml/cr/j/d6897a2a75074d37b0c49770a344d016/exe/wd/script.py", line 52, in <module>
    asyncio.run(main())
  File "/opt/miniconda/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/miniconda/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/mnt/azureml/cr/j/d6897a2a75074d37b0c49770a344d016/exe/wd/script.py", line 17, in main
    token = await credential.get_token("https://ai.azure.com/.default")
  File "/opt/miniconda/lib/python3.10/site-packages/azure/ai/ml/identity/_aio/_credentials/aml_on_behalf_of.py",
line 42, in get_token
    return await self._credential.get_token(*scopes, **kwargs)
  File "/opt/miniconda/lib/python3.10/site-packages/azure/ai/ml/identity/_aio/_internal/managed_identity_base.py",
line 47, in get_token
    return await super().get_token(*scopes, **kwargs)
  File "/opt/miniconda/lib/python3.10/site-packages/azure/ai/ml/identity/_aio/_internal/get_token_mixin.py", line
72, in get_token
    token = await self._request_token(*scopes, **kwargs)
  File "/opt/miniconda/lib/python3.10/site-packages/azure/ai/ml/identity/_aio/_internal/managed_identity_base.py",
line 55, in _request_token
    return await cast(AsyncManagedIdentityClient, self._client).request_token(*scopes, **kwargs)
  File "/opt/miniconda/lib/python3.10/site-packages/azure/ai/ml/identity/_aio/_internal/managed_identity_client.py",
 line 31, in request_token
    request = self._request_factory(resource, self._identity_config)  # type: ignore
AttributeError: 'AsyncManagedIdentityClient' object has no attribute '_identity_config'

Additionally, there is only a synchronous MLClient.

Describe the solution you'd like
Asynchronous clients and credentials.

Metadata

Metadata

Labels

Machine LearningService AttentionWorkflow: This issue is responsible by Azure service team.feature-requestThis issue requires a new behavior in the product in order be resolved.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions