Comments (2)
I found out temporary solution.
The problem is that
at line 54-68 of file /node_modules/azure-keyvault/node_modules/ms-rest-azure/lib/credentials/keyVaultCredentials.js, there is type comparison and it is the one causing the error. The object I am getting from the call msRestAzure.loginWithAppServiceMSI is MSIAppServiceTokenCredentials and I created this object by require('ms-rest-azure') but the object the azure-keyvault is comparing using the instance it loads by require('ms-rest-azure'). So the instance I created is not the same type of the azure-keyvault created even-if the node module is the same copy.
Here is the temporary solution to get key/secret from key vault.
First expose the msRestAzure from the azure-keyvault node module. To do that update the node_modules/azure-keyvault/lib/keyVault.js file with this one line code.
module.exports.msRestAzure = msRestAzure;
Then the method look like this:
const KeyVault = require('azure-keyvault');
var getKeyValue = async (secretName, secretVersion)=>{
// The ms-rest-azure library allows us to login with MSI by providing the resource name. In this case the resource is Key Vault.
return KeyVault.msRestAzure.loginWithAppServiceMSI({resource: 'https://vault.azure.net'})
.then((credentials) => {
var vaultUri = "https://.vault.azure.net/";
const client = new KeyVault.KeyVaultClient(credentials);
return client.getSecret(vaultUri, secretName, secretVersion)
.then((result) => {
return result.value;
})
.catch((err)=>{
console.log(err);
return err;
});
})
.catch((err)=>{
console.log(err);
return err;
});
};
from azure-sdk-for-js-keyvault-secret-get-set-managedid.
This should be resolved in latest update. Please reopen if you are able to repro. Thank you
from azure-sdk-for-js-keyvault-secret-get-set-managedid.
Related Issues (2)
- Report a broken link HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-sdk-for-js-keyvault-secret-get-set-managedid.