In this step, we are going to create a SymmetricKey. The way to use a secret with client-side encryption is via the SymmetricKey class, because a secret is essentially a symmetric key. Therefore, we need to run a PowerShell script in Azure Cloud Shell:
$key = "qwertyuiopasdfgh"
$b = [System.Text.Encoding]::UTF8.GetBytes($key)
$enc = [System.Convert]::ToBase64String($b)
$secretvalue = ConvertTo-SecureString $enc -AsPlainText -Force
# Substitute the VaultName and Name in this command.
$secret = Set-AzureKeyVaultSecret -VaultName 'PacktDataEncryptionVault' -Name 'Secret2' -SecretValue $secretvalue -ContentType "application/octet-stream"
In this section, we created and stored a SymmetricKey key in Azure Key Vault. In the next section, we are going to create the console application.