Azure / Azure/azure-sdk-for-python
Allow casting between sync and async versions of TokenCredentials
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 3.4k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 193
Description
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I have either a async or sync TokenCredential, for instance a AzureCliCredential, but in some cases I need the sync version, while in others I need the async.
For example:
Using the AIProjectClient from `azure.ai.projects.aio` (because using non-async with these kinds of services doesn't make sense) needs a async TokenCredential, but if I then want to configure azure monitor, I need a sync Credential to set that up, so I would need to either import and create credentials twice, or do some trickery to make a derived version myself.
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
```python
from azure.identity.aio import AzureCliCredential
credential = AzureCliCredential()
sync_cred = credential.as_sync()
```
or the inverse:
```python
from azure.identity import AzureCliCredential
credential = AzureCliCredential()
async_cred = credential.as_async()
```
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
```python
from azure.identity.aio import AsyncAzureCliCredential
from azure.identity import AzureCliCredential
credential = AzureCliCredential()
async_cred = AsyncAzureCliCredential.from_credential(credential)
```
**Additional context**
Add any other context or screenshots about the feature request here.
Contributor guide
Assessment
This issue has not been assessed yet.