Skip to content

Commit

Permalink
Update readme example to import async client (#15763)
Browse files Browse the repository at this point in the history
* Update readme example to import async client

* Update azure-core link
  • Loading branch information
mccoyp committed Dec 11, 2020
1 parent 2dd1409 commit 6fd1969
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sdk/keyvault/azure-keyvault-certificates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,23 +263,26 @@ for certificate in certificates:
This library includes a complete async API supported on Python 3.5+. To use it, you must
first install an async transport, such as [aiohttp](https://pypi.org/project/aiohttp/).
See
[azure-core documentation](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md#transport)
[azure-core documentation](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/CLIENT_LIBRARY_DEVELOPER.md#transport)
for more information.
Async clients should be closed when they're no longer needed. Each async
client is an async context manager and defines an async `close` method. For
example:
```py
from azure.keyvault.certificates import CertificateClient
from azure.identity.aio import DefaultAzureCredential
from azure.keyvault.certificates.aio import CertificateClient
credential = DefaultAzureCredential()
# call close when the client is no longer needed
client = CertificateClient()
client = CertificateClient(vault_url="https://my-key-vault.vault.azure.net/", credential=credential)
...
await client.close()
# alternatively, use the client as an async context manager
client = CertificateClient()
client = CertificateClient(vault_url="https://my-key-vault.vault.azure.net/", credential=credential)
async with client:
...
```
Expand Down

0 comments on commit 6fd1969

Please sign in to comment.