Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Node.JS Get Azure secret from vault using node js async issue

belgiancoder

New Coder
Hey,

I've setup a node js on azure and it's working, all credentials should be ok too but I can't figure out how to use an async function inside of it, should i wrap the whole program in it or how could i do this?

JavaScript:
const az_indentity = require('@azure/identity');
const az_kv = require('@azure/keyvault-secrets');
const credential = new az_indentity.DefaultAzureCredential();
const client = new az_kv.SecretClient('https://myvault.vault.azure.net/', credential);
const secretName = "secretname";
const secretVersion = '';
async function getValue(secretName, secretVersion) {
  const secret = await client.getSecret(secretName,secretVersion);
  return secret.value;
}

In the code i want to display it to see if it works (it's a test key off course)

JavaScript:
app.get('/p', (req, res) => {
    
    
    var keykey = getValue(secretName, secretVersion);
    res.send(keykey);   
     res.send('Hello!');
 

New Threads

Buy us a coffee!

Back
Top Bottom