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?
In the code i want to display it to see if it works (it's a test key off course)
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!');