-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[KeyVault] Keyvault access is broken in newer version on Managed Identity #21798
Comments
@sadasant / @KarishmaGhiya I wonder if this has something to do with multi-tenant support that was recently added to Identity? I'm not too familiar with these changes so hopefully you could offer some guidance? https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/keyvault/keyvault-secrets/CHANGELOG.md#features-added-1 @ashut0shk turning on verbose logging could hopefully help here by providing detailed logs from @azure/identity - could you run the same scenario with the azure logger in verbose mode? Instructions can be found here: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md#logging You can either set an environment variable Is there anything in the verbose logs that might help narrow down the problem? |
@maorleger The multi-tenant feature was added through these two PRs:
To disable it, one can set the environment variable |
Hello @ashut0shk I have tried the above code snippet with @azure/keyvault-secrets (v 4.4) and @azure/identity (v2.0.4) and it worked, provided the access policies are set correctly. First, I want to see the exact error message you are seeing on your end. Make sure you don't have any env variables set while doing this, since you want to use const identity = require("@azure/identity");
const keyvault = require("@azure/keyvault-secrets");
const credentials = new identity.DefaultAzureCredential();
const vaultName = "<vault-name>";
const vaultUrl = `https://${vaultName}.vault.azure.net`;
async function main(){
try{
const client = new keyvault.SecretClient(vaultUrl, credentials);
const value= await client.getSecret("secretName");
console.log(value);
} catch (e) {
console.log(e);
throw new Error(e);
}
}
main().catch((err)=>{
console.error(err);
process.exit(1);
}); Second, can you verify the following:
|
Hi @sadasant, I tried rechecking with setting up the variable |
Hi @KarishmaGhiya, thank you for the suggestion. I have captures the exact output of the above code snippet.
Meanwhile I re-verified the appropriate role as well as access policy assignments. The error is same as appeared previously. |
In case verbose logging information is needed, please refer below.
|
I currently believe the error comes specifically from this line in the code:
However, I can't imagine why the code within the
I wonder two things:
|
Hi @ashut0shk - thanks for the verbose logging, this was really helpful! I now noticed that in the issue description you mentioned you're using Node 8.x - is that correct? If so, we no longer support Node 8.x as it is outside of our support policy - we highly recommend upgrading to a Node version that is maintained. Please feel free to refer to the Node.JS releases page for information about what versions are currently maintained by the community. Production applications should only use Active LTS or Maintenance LTS releases. For more context - the URL class was made available on the global object as of Node 10.x and so the underlying error is likely to be "URL is not a function" (or something similar). There is an issue here though - since we catch any exception and return this blanket "the challenge authorization URI .... is invalid" we are likely masking errors such as this. Maybe we should revisit that and either:
|
Hi @maorleger That is a viable catch. I wonder, however, how the previous version manages to circumvent the issue. To answer the question, yes, the current node version on the machine is v8.17.xx |
@ashut0shk Checking with you if updating the node version resolves the issue you are having? |
@KarishmaGhiya I have not been able to upgrade the node on the managed identity machine (mainly because of a lot of dependencies) to validate the existence of the issue with latest one. I, however, tried to reproduce the same on a regular machine and it appears that it does vanish away with latest Node LTS, i.e., v16.15.xx NB: On regular machine with Node v8.xx, I was still hitting the same error. As if it's a underlying node library issue. Wouldn't it be nice to have a little more specific error message, I wonder. |
I can definitely try to capture the original error message where we are using the URL class and throw that error message. Thanks! |
Has this issue been resolved? Currently running into it now. |
Hey @GregorieCalderon! The original issue here stemmed from the use of Node 8, which we no longer support (see above). If you're using an unsupported Node version, my recommendation would be to upgrade to a supported version, if possible. This would hopefully resolve the underlying issue for you, although the problem with the misleading error message persists for the time being. |
Describe the bug
When using DefaultAzureCredential on a Managed Identity machine(azure vms), the credentials throw error while trying to access keyvault.SecretClient(url, cred). This makes complete inaccessibility of keyvault secrets.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The above code snippet should not throw any errors, when all the resources are aligned properly.
Note that the above snippet gives error in v4.4.x while v4.3.x works like charm.
Screenshots
N/A
Additional context
The sdk is tested on a managed identity machine, and previous version seems to be working file.
NB: for Microsoft support team, you can refer to a ticket with
TrackingID#2204050050000883
, without disclosing further details.(confidential)The text was updated successfully, but these errors were encountered: