Skip to content

Commit 80fa8a5

Browse files
authored
Merge pull request #96768 from bigjonroberts/patch-1
Clarify steps for each method
2 parents d146349 + 1f5f55b commit 80fa8a5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

articles/key-vault/secrets/multiline-secrets.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ms.author: mbaldwin
1414
---
1515
# Store a multi-line secret in Azure Key Vault
1616

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.
1818

1919
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.
2020

@@ -26,11 +26,26 @@ multi-line
2626
secret
2727
```
2828

29+
## Set the secret using Azure CLI
30+
2931
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.
3032

3133
```azurecli-interactive
3234
az keyvault secret set --vault-name "<your-unique-keyvault-name>" --name "MultilineSecret" --file "secretfile.txt"
3335
```
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
3449

3550
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).
3651

@@ -45,7 +60,7 @@ Lastly, you store the secret using the [Set-AzKeyVaultSecret](/powershell/module
4560
$secret = Set-AzKeyVaultSecret -VaultName "<your-unique-keyvault-name>" -Name "MultilineSecret" -SecretValue $SecureSecret
4661
```
4762

48-
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.
4964

5065
```azurecli-interactive
5166
az keyvault secret show --name "MultilineSecret" --vault-name "<your-unique-keyvault-name>" --query "value"

0 commit comments

Comments
 (0)