Skip to content
This repository was archived by the owner on Jun 17, 2024. It is now read-only.

Commit 463a7c3

Browse files
committed
minor fixes
1 parent 92c7d08 commit 463a7c3

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ With [Managed Service Identity (MSI)](https://docs.microsoft.com/en-us/azure/app
1818
## Prerequisites
1919
To run and deploy this sample, you need the following:
2020
1. An Azure subscription to create an App Service and a Key Vault.
21-
2. [Azure CLI 2.0](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) to run the application on your local development machine.
2221

2322
### Step 1: Create an App Service with a Managed Service Identity (MSI)
2423
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fapp-service-msi-keyvault-node%2Fmaster%2Fazuredeploy.json" target="_blank">
@@ -66,7 +65,7 @@ and grant it the same access.
6665
npm install
6766
```
6867
69-
3. Set up the environment variable `KEY_VAULT_URL` with your KeyVault URL of replace the variable in the index.js file.
68+
3. Set up the environment variable `KEY_VAULT_URL` with your KeyVault URL or replace the variable in the index.js file.
7069
7170
1. Export these environment variables into your current shell or update the credentials in the index.js file.
7271
@@ -99,17 +98,17 @@ and grant it the same access.
9998
Using the `loginWithAppServiceMSI()` method from [ms-rest-azure](https://www.npmjs.com/package/ms-rest-azure) will autodetect if you're on a WebApp and get the token from the MSI endpoint. Then, the code is simply:
10099
101100
```javascript
102-
function get_key_vault_credentials(){
101+
function getKeyVaultCredentials(){
103102
return msRestAzure.loginWithAppServiceMSI({resource: 'https://vault.azure.net'});
104103
}
105104
106-
function get_key_vault_secret(credentials) {
105+
function getKeyVaultSecret(credentials) {
107106
let keyVaultClient = new KeyVault.KeyVaultClient(credentials);
108107
return keyVaultClient.getSecret(KEY_VAULT_URI, 'secret', "");
109108
}
110109
111-
get_key_vault_credentials().then(
112-
get_key_vault_secret
110+
getKeyVaultCredentials().then(
111+
getKeyVaultSecret
113112
).then(function (secret){
114113
console.log(`Your secret value is: ${secret.value}.`);
115114
}).catch(function (err) {
@@ -122,7 +121,7 @@ If you want to execute this same code in your local environment machine, just us
122121
If you need a fallback mechanism to allow this code to switch automatically from MSI to another approach, you can test for environment variables:
123122

124123
```javascript
125-
function get_key_vault_credentials(){
124+
function getKeyVaultCredentials(){
126125
if (process.env.APPSETTING_WEBSITE_SITE_NAME){
127126
return msRestAzure.loginWithAppServiceMSI({resource: 'https://vault.azure.net'});
128127
} else {

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ let clientId = process.env['CLIENT_ID']; // service principal
88
let domain = process.env['DOMAIN']; // tenant id
99
let secret = process.env['APPLICATION_SECRET'];
1010

11-
function get_key_vault_credentials(){
11+
function getKeyVaultCredentials(){
1212
if (process.env.APPSETTING_WEBSITE_SITE_NAME){
1313
return msRestAzure.loginWithAppServiceMSI();
1414
} else {
1515
return msRestAzure.loginWithServicePrincipalSecret(clientId, secret, domain);
1616
}
1717
}
1818

19-
function get_key_vault_secret(credentials) {
19+
function getKeyVaultSecret(credentials) {
2020
let keyVaultClient = new KeyVault.KeyVaultClient(credentials);
2121
return keyVaultClient.getSecret(KEY_VAULT_URI, 'secret', "");
2222
}
2323

2424
app.get('/', function (req, res) {
25-
get_key_vault_credentials().then(
26-
get_key_vault_secret
25+
getKeyVaultCredentials().then(
26+
getKeyVaultSecret
2727
).then(function (secret){
2828
res.send(`Your secret value is: ${secret.value}.`);
2929
}).catch(function (err) {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
"node": ">=6.9.1"
1010
},
1111
"dependencies": {
12-
"express": "^4.16.2",
1312
"async": "^2.6.0",
1413
"azure-arm-keyvault": "1.1.0-preview",
1514
"azure-keyvault": "git://github.com/williexu/testkv.git",
16-
"ms-rest-azure": "git://github.com/williexu/testkv.git#ms-rest-azure",
15+
"express": "^4.16.2",
1716
"ms-rest": "^2.3.0",
17+
"ms-rest-azure": "git://github.com/williexu/testkv.git#ms-rest-azure",
1818
"util": "0.10.3"
1919
},
2020
"scripts": {

0 commit comments

Comments
 (0)