CmdID / az / az vm / az vm secret
az vm secret format
Transform secrets into a form that can be used by VMs and VMSSes. Azure CLI reference
1 example Its page in the Azure CLI reference
Examples
Create a self-signed certificate with the default policy, and add it to a virtual machine.
az keyvault certificate create --vault-name vaultname -n cert1 -p "$(az keyvault certificate get-default-policy)"Identify--vault-nameName of the Vault.-nName of the certificate.-pJSON encoded policy definition.secrets=$(az keyvault secret list-versions --vault-name vaultname -n cert1 --query "[?attributes.enabled].id" -o tsv)Identify--vault-nameName of the Key Vault.-nName of the secret.--queryJMESPath query string.-oOutput formatvm_secrets=$(az vm secret format -s "$secrets")Identify-sSpace-separated list of key vault secret URIs.az vm create -g group-name -n vm-name --admin-username deploy --image Debian11 --secrets "$vm_secrets"Identify-gName of resource group.-nName of the virtual machine.--admin-usernameUsername for the VM.--imageThe name of the operating system image as a URN alias, URN, custom image name or ID, custom image version ID, or VHD blob URI.--secretsOne or many Key Vault secrets as JSON strings or files via @{path} containing [{ "sourceVault": { "id": "value" }, "vaultCertificates": [{ "certificateUrl": "value", "certificateStore": "cert store name (only on windows)"}] }]