az keyvault secret

Manage Key Vault secrets.

Commands

Name Description Type Status
az keyvault secret delete

Delete all versions of a secret without purging it.

Core Preview
az keyvault secret list

List secret metadata across all pages.

Core Preview
az keyvault secret list-versions

List every version of a secret without its values.

Core Preview
az keyvault secret set

Set a secret or create a new version.

Core Preview
az keyvault secret set-attributes

Update secret attributes without changing its value.

Core Preview
az keyvault secret show

Retrieve secret metadata or explicitly retrieve its value.

Core Preview

az keyvault secret delete

Preview

Delete all versions of a secret without purging it.

Delete the named secret and all versions. Requires secrets/delete permission and explicit --yes confirmation. Output retains recovery metadata where returned by the service. The command never purges or bypasses purge protection. Recovery is not exposed in the CLI. A retained soft-deleted name cannot simply be reused as a new secret.

az keyvault secret delete --name
                          [--profile]
                          [--vault-name]
                          [--vault-url]
                          [--yes]

Examples

Confirm deletion

az keyvault secret delete --vault-name myvault --name app-password --yes

Required Parameters

--name

secret name.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--profile

Use the named connection profile.

--vault-name

Azure public-cloud vault name.

--vault-url

Root HTTPS vault URL. Use instead of vault name.

--yes

Confirm deletion of all secret versions.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h -help -? --?

Show help for the command or group and exit.

--no-cache

Bypass the extension discovery cache and reload extensions from disk.

--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, table, tsv, yaml, yamlc
--query

JMESPath query string to filter/project the command result before rendering.

az keyvault secret list

Preview

List secret metadata across all pages.

List base secret identifiers and attributes without retrieving values. Requires secrets/list permission. --maxresults sets the page size between 1 and 25, not the total result limit. Continuation requests stay within the selected vault.

az keyvault secret list [--maxresults]
                        [--profile]
                        [--vault-name]
                        [--vault-url]

Examples

List secrets

az keyvault secret list --vault-name myvault

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--maxresults

Page size from 1 to 25. All pages are returned.

--profile

Use the named connection profile.

--vault-name

Azure public-cloud vault name.

--vault-url

Root HTTPS vault URL. Use instead of vault name.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h -help -? --?

Show help for the command or group and exit.

--no-cache

Bypass the extension discovery cache and reload extensions from disk.

--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, table, tsv, yaml, yamlc
--query

JMESPath query string to filter/project the command result before rendering.

az keyvault secret list-versions

Preview

List every version of a secret without its values.

Return version identifiers and metadata across all pages. Requires secrets/list permission. --maxresults controls page size from 1 to 25, not total results.

az keyvault secret list-versions --name
                                 [--maxresults]
                                 [--profile]
                                 [--vault-name]
                                 [--vault-url]

Examples

List versions

az keyvault secret list-versions --vault-name myvault --name app-password

Required Parameters

--name

secret name.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--maxresults

Page size from 1 to 25. All pages are returned.

--profile

Use the named connection profile.

--vault-name

Azure public-cloud vault name.

--vault-url

Root HTTPS vault URL. Use instead of vault name.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h -help -? --?

Show help for the command or group and exit.

--no-cache

Bypass the extension discovery cache and reload extensions from disk.

--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, table, tsv, yaml, yamlc
--query

JMESPath query string to filter/project the command result before rendering.

az keyvault secret set

Preview

Set a secret or create a new version.

Set a UTF-8 secret using exactly one of --file or --value. Prefer a protected file to avoid putting the value in shell history or process arguments. File contents, including trailing newlines, are preserved. Values must not exceed 25 KiB. Requires secrets/set permission. The response contains metadata, not the value. No vault is created.

az keyvault secret set --name
                       [--content-type]
                       [--enabled]
                       [--expires]
                       [--file]
                       [--not-before]
                       [--profile]
                       [--tags]
                       [--value]
                       [--vault-name]
                       [--vault-url]

Examples

Set from a file

az keyvault secret set --vault-name myvault --name app-password --file ./secret.txt

Set with attributes

az keyvault secret set --vault-name myvault --name app-password --file ./secret.txt --enabled false --expires 2027-01-01T00:00:00Z --tags owner=app

Required Parameters

--name

secret name.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--content-type

Secret content type.

--enabled

Whether the secret is enabled: true or false.

--expires

Expiration timestamp in UTC.

--file

UTF-8 secret file; contents are preserved including newlines.

--not-before

Not-before timestamp in UTC.

--profile

Use the named connection profile.

--tags

Tags in NAME=VALUE form.

--value

Secret value. Prefer --file to avoid shell history.

--vault-name

Azure public-cloud vault name.

--vault-url

Root HTTPS vault URL. Use instead of vault name.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h -help -? --?

Show help for the command or group and exit.

--no-cache

Bypass the extension discovery cache and reload extensions from disk.

--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, table, tsv, yaml, yamlc
--query

JMESPath query string to filter/project the command result before rendering.

az keyvault secret set-attributes

Preview

Update secret attributes without changing its value.

Update the latest or specified version's enabled state, expiration, not-before time, content type or tags. Supply at least one update. Omitted properties remain unchanged; explicit --enabled false is preserved. Requires secrets/set permission. Tags supplied here replace the existing tag collection. Output contains metadata only. Use set to create a new secret value/version.

az keyvault secret set-attributes --name
                                  [--content-type]
                                  [--enabled]
                                  [--expires]
                                  [--not-before]
                                  [--profile]
                                  [--tags]
                                  [--vault-name]
                                  [--vault-url]
                                  [--version]

Examples

Disable a secret

az keyvault secret set-attributes --vault-name myvault --name app-password --enabled false

Update expiry

az keyvault secret set-attributes --vault-name myvault --name app-password --expires 2027-01-01T00:00:00Z

Required Parameters

--name

secret name.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--content-type

Secret content type.

--enabled

Whether the secret is enabled: true or false.

--expires

Expiration timestamp in UTC.

--not-before

Not-before timestamp in UTC.

--profile

Use the named connection profile.

--tags

Tags in NAME=VALUE form.

--vault-name

Azure public-cloud vault name.

--vault-url

Root HTTPS vault URL. Use instead of vault name.

--version

secret version. Omit for latest.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h -help -? --?

Show help for the command or group and exit.

--no-cache

Bypass the extension discovery cache and reload extensions from disk.

--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, table, tsv, yaml, yamlc
--query

JMESPath query string to filter/project the command result before rendering.

az keyvault secret show

Preview

Retrieve secret metadata or explicitly retrieve its value.

Get the latest version, or select one with --version. Requires secrets/get permission. Output has no secret-value property unless --as-plain-text is supplied; that option returns the value directly. Plaintext output can be captured by the terminal or calling process, so use it only when needed.

az keyvault secret show --name
                        [--as-plain-text]
                        [--profile]
                        [--vault-name]
                        [--vault-url]
                        [--version]

Examples

Get metadata

az keyvault secret show --vault-name myvault --name app-password

Retrieve a value explicitly

az keyvault secret show --vault-name myvault --name app-password --as-plain-text

Required Parameters

--name

secret name.

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--as-plain-text

Explicitly return the plaintext secret value.

--profile

Use the named connection profile.

--vault-name

Azure public-cloud vault name.

--vault-url

Root HTTPS vault URL. Use instead of vault name.

--version

secret version. Omit for latest.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h -help -? --?

Show help for the command or group and exit.

--no-cache

Bypass the extension discovery cache and reload extensions from disk.

--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, table, tsv, yaml, yamlc
--query

JMESPath query string to filter/project the command result before rendering.