score:1
Accepted answer
using the loginwithappservicemsi()
method from ms-rest-azure will autodetect if you're on a webapp and get the token from the msi endpoint. so you must host your code on azure webapp. refer to this article for more details.
function getkeyvaultcredentials(){
return msrestazure.loginwithappservicemsi({resource: 'https://vault.azure.net'});
}
function getkeyvaultsecret(credentials) {
let keyvaultclient = new keyvault.keyvaultclient(credentials);
return keyvaultclient.getsecret(key_vault_uri, 'secret', "");
}
getkeyvaultcredentials().then(
getkeyvaultsecret
).then(function (secret){
console.log(`your secret value is: ${secret.value}.`);
}).catch(function (err) {
throw (err);
});
if you don't have to use managed service identity (msi), you can use msrestazure.loginwithserviceprincipalsecret(clientid, secret, domain)
to get the credentials.
function getkeyvaultcredentials(){
return msrestazure.loginwithserviceprincipalsecret(clientid, secret, domain);
}
Source: stackoverflow.com
Related Query
- How to retrieve Azure Key Vault in React JS
- How does Gatsby application access Azure Key Vault
- Can't resolve 'url' in node_modules error when trying to access Azure Key Vault with React
- How to detect Esc Key Press in React and how to handle it
- How unique should a React component Key be?
- How to use environment variables in React app hosted in Azure
- how to create React search filter for search multiple object key values
- How to integrate azure ad into a react web app that consumes a REST API in azure too
- Retrieve element's key in React
- How to integrate azure b2c with react
- How to replace %PUBLIC_URL% in react app on an azure website
- How can I search for a component with specific key in React Developer Tools?
- How to add a new key value to react js state array?
- How to create unique key for NavigationStateUtils using push route in React Native/Redux?
- In React how to add key prop to element passed as Object
- How to make Semantic UI react Search use id instead of title as key
- How to specify a key for React children when mapping over an array
- How to pass key to react route?
- How to retrieve the key into a Semantic-ui-react dropdown?
- react native how to filter data with some key object on json
- How do I deploy a React Webpack web app to Azure App Service?
- How to retrieve the parameter after a hash (#) with React Router and useParams hook?
- How retrieve current redux-form state field value in react class form component?
- how to set focus to next input on enter key press in react js with refs
- How can you access Azure Web App AppSettings from a React app at run time
- How to Disable the ENTER Key in React Material UI Autocomplete form
- How to deploy a NextJs SSR React app on Azure
- How to hide an the HTML element if a JSON key doesn't exist in React
- How to detect 'Enter' key on keyPress when used with React
- How to access from state another key inside the state in React
More Query from same tag
- How do you add multiple eventlisteners of different type in React?
- Django Backend Image not displaying
- this.props.dispatch is not a function
- Rendering React components from text
- Referencing `this` in React JSX
- GSAP Tween taking longer on each play in React
- How can I better conditionally render my components?
- How can i Solve Problem "X-Total-Count "?
- Trigger animation clicking on a specific component button in React
- Is it necessary to use in the array NavLink, Interface?
- Need to get data from (laravel api) using fetch then parse it on to another function
- React apollo client api calling two time
- React Router protected routes
- How to Convert the svgEdit files into React components?
- React Navigation Invariant violation: Attempt to get native tag
- Multiple markers on google map from state variable React
- Webpack 5.47.1 : Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema
- SetInterval isn't working in React functional component
- React reducer call twice
- How does Javascript know when to execute a function passed by reference implicitly? React example
- React - replace child component in props.children
- POST: 400 BAD REQUEST on REACT APP - using Express
- Issues with CSRF on login form with React SPA and Django
- React+Javascript:-Component will update is getting called too many times causing my application to crash
- React: Setting input state inside useEffect not working
- Set default color for text in Tailwind
- Make an integration between React and Laravel using CSRF token
- Best practice of setting state from axios request
- How to pass pageProps in next.js from a child component to _app.js?
- Webpack 4 + react router two sub path return null