You need to use the Azure CLI to create a new Azure Key Vault, store a database connection string as a secret, and then retrieve that secret. What is the correct sequence of Azure CLI commands to achieve this?
- 1Run `az group create` to create a resource group.
- 2Run `az keyvault create` to create the Key Vault.
- 3Run `az keyvault secret set` to add the secret.
- 4Run `az keyvault secret show` to retrieve the secret value.
Answer
The correct sequence is to first create the resource group with `az group create`, then create the Key Vault with `az keyvault create`, next store the secret with `az keyvault secret set`, and finally retrieve the secret with `az keyvault secret show`.
To store and retrieve a secret using the Azure CLI, you must progress from global resource containers to the specific secret value. First, the resource group is created. Next, the Key Vault is provisioned within that resource group. Once the vault exists, the secret is written using the set command, and finally, the secret is retrieved using the show command.
Step-by-Step Solution
Key Concept
Azure Key Vault CLI Secret Management Lifecycle