-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImportError: cannot import name 'KeyVaultClient' #8591
Comments
@nuarhu , as we've been revamping the Azure SDKs, we have made the latest version of azure-keyvault a metapackage for our new SDKs. If you would like to continue using your code as is, make sure when you're installing from pip that you specify version less than or equal to 1.1.0: https://pypi.org/project/azure-keyvault/1.1.0/. If you would like to try using our new key vault SDKs, we have separate packages for keys, secrets, and certificates and you can use the latest azure-keyvault to download and use them: https://pypi.org/project/azure-keyvault/4.0.0/ Hope this helps! |
@iscai-msft If we would want to use the current version 4.0.0 instead of downgrading - would we have to change the import statements? Comparing our code to the current documentation, I fail to find the differences. Downgrading is only a temporary workaround, imho. |
@nuarhu downgrading would not be a temporary workaround because azure-keyvault is not being deprecated, you just need to add an upper-bound constraint for your azure-keyvault package (say, you can use 2.0.0 as your upper-bound because we follow semantic versioning). This way you won't have to rewrite your code that will work as long as you specify this upper-bound on the package. If you would like to use our new libraries, you would have to rewrite your code because the code that works for azure-keyvault will not work with our new libraries. Our new libraries have separate packages for keys, secrets, and certificates. From the code you've shared, I see you are getting secrets, so you would need to at least use the azure-keyvault-secrets library. At this link you can find how to get a secret as well. We would also highly recommend you use the authentication method specified in the link as that will automatically work with our libraries. P.S. Could you point me to the current documentation you are referring to? The code we have for our new libraries is very different, so there are definite differences between your code and the current documented code samples and I would like to clear up that confusion. Thanks! |
@iscai-msft |
@nuarhu - We are in the process of updating documentation to reflect the recent release. In the meantime, you can reference the Key Vault samples found here: Stop gap solution for you:
Here's how you would modify your code for v4:
You can decide if you want to move credential out of get_kvvalue (if it is shared). As an aside, have a look at DefaultAzureCredential, as it helps make your code more portable from dev environments to production environments. https://azuresdkdocs.blob.core.windows.net/$web/python/azure-identity/1.0.0/index.html#id2 |
@JoniGo - both the links you sent throw back 404 from azure.common.client_factory import get_client_from_cli_profile
from azure.keyvault.secrets import SecretClient
key_vault_client = get_client_from_cli_profile(SecretClient) This doesn't work and throws:
|
@pixelicous about the links not working - sorry, here are the updated links: |
@pixelicous #7035 is the right place to track that ask. |
@nuarhu - Closing this issue, because I believe you are unblocked now. Feel free to comment or reopen if not. Thanks, Jon |
Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment. |
Hello all,
we are running the following code since 2018 without problems but some days ago it started to fail with:
ImportError: cannot import name 'KeyVaultClient'
This code runs in Docker and the installation in the Dockerfile is done as follows:
Do we have to install a specific version to make it work again?
The text was updated successfully, but these errors were encountered: