Azure / Azure/azure-sdk-for-python

Allow casting between sync and async versions of TokenCredentials

Aperta
#44,361 1 commento 0 reazioni 2 assegnatari Rivendicata da @pvaneck Vedi su GitHub
Azure.Identity Client customer-reported feature-request needs-team-attention
Lingua principale
Python
Stelle
5.6k
Fork
3.4k
Merge medio
2g 2h
PR unite (30g)
213

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.