You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/key-vault/secrets/multiline-secrets.md
+17-2Lines changed: 17 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ ms.author: mbaldwin
14
14
---
15
15
# Store a multi-line secret in Azure Key Vault
16
16
17
-
The [Azure CLI quickstart](quick-create-cli.md)and[Azure PowerShell quickstart](quick-create-powershell.md) demonstrate how to store a single-line secret. You can also use Key Vault to store a multi-line secret, such as a JSON file or RSA private key.
17
+
The [Azure CLI quickstart](quick-create-cli.md)or[Azure PowerShell quickstart](quick-create-powershell.md) demonstrate how to store a single-line secret. You can also use Key Vault to store a multi-line secret, such as a JSON file or RSA private key.
18
18
19
19
Multi-line secrets cannot be passed to the Azure CLI [az keyvault secret set](/cli/azure/keyvault/secret#az-keyvault-secret-set) command or the Azure PowerShell [Set-AzKeyVaultSecret](/powershell/module/az.keyvault/set-azkeyvaultsecret) cmdlet through the commandline. Instead, you must first store the multi-line secret as a text file.
20
20
@@ -26,11 +26,26 @@ multi-line
26
26
secret
27
27
```
28
28
29
+
## Set the secret using Azure CLI
30
+
29
31
You can then pass this file to the Azure CLI [az keyvault secret set](/cli/azure/keyvault/secret#az-keyvault-secret-set) command using the `--file` parameter.
30
32
31
33
```azurecli-interactive
32
34
az keyvault secret set --vault-name "<your-unique-keyvault-name>" --name "MultilineSecret" --file "secretfile.txt"
33
35
```
36
+
You can then view the stored secret using the Azure CLI [az keyvault secret show](/cli/azure/keyvault/secret#az-keyvault-secret-show) command.
37
+
38
+
```azurecli-interactive
39
+
az keyvault secret show --name "MultilineSecret" --vault-name "<your-unique-keyvault-name>" --query "value"
40
+
```
41
+
42
+
The secret will be returned with newlines embedded:
43
+
44
+
```bash
45
+
"This is\nmy multi-line\nsecret"
46
+
```
47
+
48
+
## Set the secret using Azure Powershell
34
49
35
50
With Azure PowerShell, you must first read in the file using the [Get-Content](/powershell/module/microsoft.powershell.management/get-content) cmdlet, then convert it to a secure string using [ConvertTo-SecureString](/powershell/module/microsoft.powershell.security/convertto-securestring).
36
51
@@ -45,7 +60,7 @@ Lastly, you store the secret using the [Set-AzKeyVaultSecret](/powershell/module
In either case, you can then view the stored secret using the Azure CLI [az keyvault secret show](/cli/azure/keyvault/secret#az-keyvault-secret-show) command or the Azure PowerShell [Get-AzKeyVaultSecret](/powershell/module/az.keyvault/get-azkeyvaultsecret) cmdlet.
63
+
You can then view the stored secret using the Azure CLI [az keyvault secret show](/cli/azure/keyvault/secret#az-keyvault-secret-show) command or the Azure PowerShell [Get-AzKeyVaultSecret](/powershell/module/az.keyvault/get-azkeyvaultsecret) cmdlet.
49
64
50
65
```azurecli-interactive
51
66
az keyvault secret show --name "MultilineSecret" --vault-name "<your-unique-keyvault-name>" --query "value"
0 commit comments