|
| 1 | +--- |
| 2 | +title: 'Tutorial: JavaScript connect to Azure services securely with Key Vault' |
| 3 | +description: Learn how to secure connectivity to back-end Azure services that don't support managed identity natively from a JavaScript web app |
| 4 | +ms.devlang: javascript, azurecli |
| 5 | +ms.topic: tutorial |
| 6 | +ms.date: 10/26/2021 |
| 7 | + |
| 8 | +ms.reviewer: madsd |
| 9 | +ms.custom: devx-track-azurecli, devx-track-js |
| 10 | +--- |
| 11 | + |
| 12 | +# Tutorial: Secure Cognitive Service connection from JavaScript App Service using Key Vault |
| 13 | + |
| 14 | + |
| 15 | +[!INCLUDE [tutorial-content-above-code](./includes/tutorial-connect-msi-key-vault/introduction.md)] |
| 16 | + |
| 17 | +## Configure JavaScript app |
| 18 | + |
| 19 | +Clone the sample repository locally and deploy the sample application to App Service. Replace *\<app-name>* with a unique name. |
| 20 | + |
| 21 | +```azurecli-interactive |
| 22 | +# Clone and prepare sample application |
| 23 | +git clone https://github.com/Azure-Samples/app-service-language-detector.git |
| 24 | +cd app-service-language-detector/javascript |
| 25 | +zip default.zip *.* |
| 26 | +
|
| 27 | +# Save app name as variable for convenience |
| 28 | +appName=<app-name> |
| 29 | +
|
| 30 | +az appservice plan create --resource-group $groupName --name $appName --sku FREE --location $region --is-linux |
| 31 | +az webapp create --resource-group $groupName --plan $appName --name $appName --runtime "node|14-lts" |
| 32 | +az webapp config appsettings set --resource-group $groupName --name $appName --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true |
| 33 | +az webapp deployment source config-zip --resource-group $groupName --name $appName --src ./default.zip |
| 34 | +``` |
| 35 | + |
| 36 | +The preceding commands: |
| 37 | +* Create a linux app service plan |
| 38 | +* Create a web app for Node.js 14 LTS |
| 39 | +* Configure the web app to install the npm packages on deployment |
| 40 | +* Upload the zip file, and install the npm packages |
| 41 | + |
| 42 | +## Configure secrets as app settings |
| 43 | + |
| 44 | +[!INCLUDE [tutorial-content-below-code](./includes/tutorial-connect-msi-key-vault/cleanup.md)] |
0 commit comments