Skip to content

Commit ea33265

Browse files
Merge pull request #208452 from aahill/kv-article
key vault article
2 parents 3b9d7a0 + 6987c42 commit ea33265

File tree

6 files changed

+689
-2
lines changed

6 files changed

+689
-2
lines changed

articles/cognitive-services/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
href: ./encryption/cognitive-services-encryption-keys-portal.md
8282
- name: Use virtual networks
8383
href: cognitive-services-virtual-networks.md
84+
- name: Use Azure key vault
85+
href: use-key-vault.md
8486
- name: Configure data loss prevention
8587
href: cognitive-services-data-loss-prevention.md
8688
- name: Security baseline

articles/cognitive-services/authentication.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author: PatrickFarley
77
manager: nitinme
88
ms.service: cognitive-services
99
ms.topic: how-to
10-
ms.date: 07/22/2021
10+
ms.date: 09/01/2022
1111
ms.author: pafarley
1212
---
1313

@@ -177,6 +177,12 @@ curl -X POST 'https://api.cognitive.microsofttranslator.com/translate?api-versio
177177

178178
[!INCLUDE [](../../includes/cognitive-services-azure-active-directory-authentication.md)]
179179

180+
## Use Azure key vault to securely access credentials
181+
182+
You can [use Azure Key Vault](./use-key-vault.md) to securely develop Cognitive Services applications. Key Vault enables you to store your authentication credentials in the cloud, and reduces the chances that secrets may be accidentally leaked, because you won't store security information in your application.
183+
184+
Authentication is done via Azure Active Directory. Authorization may be done via Azure role-based access control (Azure RBAC) or Key Vault access policy. Azure RBAC can be used for both management of the vaults and access data stored in a vault, while key vault access policy can only be used when attempting to access data stored in a vault.
185+
180186
## See also
181187

182188
* [What is Cognitive Services?](./what-are-cognitive-services.md)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: include file
3+
description: include file
4+
services: cognitive-services
5+
author: aahill
6+
ms.service: cognitive-services
7+
ms.topic: include
8+
ms.date: 08/25/2022
9+
ms.author: aahi
10+
ms.manager: nitinme
11+
ms.custom: include
12+
---
13+
14+
Before you can grant access to your key vault, you must authenticate with your Azure Active Directory user name and password.
15+
16+
# [Azure CLI](#tab/azure-cli)
17+
18+
To authenticate with the [Azure CLI](/cli/azure), run the `az login` command.
19+
20+
```azurecli-interactive
21+
az login
22+
```
23+
24+
On systems with a default web browser, the Azure CLI will launch the browser to authenticate. For systems without a default web browser, the `az login` command will use the device code authentication flow. You can also force the Azure CLI to use the device code flow rather than launching a browser by specifying the `--use-device-code` argument.
25+
26+
If you have multiple subscriptions, make sure to [select the Azure subscription](/cli/azure/manage-azure-subscriptions-azure-cli#change-the-active-subscription) that contains your key vault.
27+
28+
# [PowerShell](#tab/powershell)
29+
30+
You can also use [Azure PowerShell](/powershell/azure) to authenticate. Applications using the `DefaultAzureCredential` or the `AzurePowerShellCredential` can then use this account to authenticate calls in their application when running locally.
31+
32+
To authenticate with Azure PowerShell, run the `Connect-AzAccount` command. If you're running on a system with a default web browser and Azure PowerShell `v5.0.0` or later, it will launch the browser to authenticate the user.
33+
34+
For systems without a default web browser, the `Connect-AzAccount` command will use the device code authentication flow. You can also force Azure PowerShell to use the device code flow rather than launching a browser by specifying the `UseDeviceAuthentication` argument.
35+
36+
```powershell
37+
Connect-AzAccount
38+
```
39+
40+
If you have multiple subscriptions, make sure to [select the Azure subscription](/powershell/azure/manage-subscriptions-azureps) that contains your key vault.
41+
42+
---
43+
44+
## Grant access to your key vault
45+
46+
Create an access policy for your key vault that grants secret permissions to your user account.
47+
48+
# [Azure CLI](#tab/azure-cli)
49+
50+
To set the access policy, run the [az keyvault set-policy](/cli/azure/keyvault#az-keyvault-set-policy) command. Replace `Your-Key-Vault-Name` with the name of your key vault. Replace `[email protected]` with your Azure Active Directory user name.
51+
52+
```azurecli-interactive
53+
az keyvault set-policy --name Your-Key-Vault-Name --upn [email protected] --secret-permissions delete get list set purge
54+
```
55+
56+
# [PowerShell](#tab/powershell)
57+
58+
To set the access policy, run the [Set-AzKeyVaultAccessPolicy](/powershell/module/az.accounts/set-azcontext) command. Replace `Your-Key-Vault-Name` with the name of your key vault. Replace `[email protected]` with your Azure Active Directory user name.
59+
60+
```powershell
61+
Set-AzKeyVaultAccessPolicy -VaultName 'Your-Key-Vault-Name' -UserPrincipalName '[email protected]' -PermissionsToSecrets delete,get,list,set,purge -PassThru
62+
```
63+
64+
---
70.1 KB
Loading

0 commit comments

Comments
 (0)