locked
Passing Parameters with Azure CLI RRS feed

  • Question

  • Hi,

    In PowerShell you can do such commands to pass parameters to a variable:

    $keyEncryptionKeyUrl = (Get-AzureKeyVaultKey -VaultName $KeyVaultName -Name $keyEncryptionKeyName).Key.kid;

    How is this done in Azure CLI? I've tried this but it doesn't return the value:

    $keyEncryptionKeyUrl =$(az keyvault key show --name <keyvaultkey> --vault-name <keyvaultname>).Key.kid

    If I do the following it shows what I need so it's the ability to extract that and pass to the variable:

    az keyvault key show --name <keyvaultkey> --vault-name <keyvaultname>

    Cheers

    Chris

    Friday, January 26, 2018 10:47 AM

Answers

  • You can pass parameters with Azure CLI as follows:

    keyid="$(az keyvault key show --name azure --vault-name azurevault --query key.kid)"

    You can use Query parameter to get specific values in Azure CLI 2.0 commands:

    az keyvault key show --name azure --vault-name azurevault --query key.kid

    You can use Output formats for Azure CLI 2.0 commands:

    az keyvault key show --name azure --vault-name azurevault --query key.kid --output table

    -----------------------------------------------------------------------------------------------

    Do click on "Mark as Answer" and “Vote as Helpful” on the post that helps you, this can be beneficial to other community members

    Sunday, January 28, 2018 2:25 PM