Use Azure Key Vault secrets in API tests

If your services on Azure read their keys from Key Vault, your API tests can read them from the same place. No copies in the API client, no copies in pipeline variables, nothing to update when a key rotates. The Requestarium CLI fetches the vault's secrets when a run starts and hands them to your requests as ordinary {{variables}}.

How it works

  1. An environment says which vault to read.
  2. When a run starts, the CLI fetches the vault's secrets from your machine, with your Azure sign-in.
  3. Each secret becomes a variable for that run, masked like a secret environment variable.

Requestarium never sees your Azure credentials or the secret values, and stores nothing.

Point an environment at a vault

Terminal
requestarium env set Staging RQ_AZURE_VAULT_URL https://orders-staging.vault.azure.net
requestarium env set Production RQ_AZURE_VAULT_URL https://orders-prod.vault.azure.net

Now switching from Staging to Production switches vaults too. Separate several vaults with commas. For a one-off run, use the flag instead:

Terminal
requestarium run-collection "Orders API" --azure-vault https://orders-staging.vault.azure.net

Which variables you get

Every enabled secret of the vault becomes a variable named after it. Key Vault names can't contain _, so a secret called db-password is also available as {{db_password}}. Use whichever reads better in your requests:

Output
Authorization: Bearer {{orders-api-key}}
X-Db-Password: {{db_password}}

Locally: az login

Terminal
az login
requestarium run-collection "Orders API" --env Staging

If no service principal is set in the environment, the CLI uses your az login session. Nothing else to configure.

In CI

A service principal, with its values stored as pipeline secrets:

Output
AZURE_TENANT_ID=...
AZURE_CLIENT_ID=...
AZURE_CLIENT_SECRET=...

When all three are set, the CLI signs in as that principal.

GitHub Actions with federated credentials, so no client secret is stored at all:

.github/workflows/api-tests.yml
permissions:
  id-token: write
  contents: read

steps:
  - uses: azure/login@v2
    with:
      client-id: ${{ vars.AZURE_CLIENT_ID }}
      tenant-id: ${{ vars.AZURE_TENANT_ID }}
      subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
  - uses: actions/setup-node@v4
    with:
      node-version: 22
  - run: npm install -g @requestarium/cli
  - env:
      REQUESTARIUM_TOKEN: ${{ secrets.REQUESTARIUM_TOKEN }}
    run: requestarium run-collection "Orders API" --env Staging --junit results.xml

In Azure Pipelines, an AzureCLI@2 task with your service connection does the same job.

Permissions

Give the identity the Key Vault Secrets User role on the vault, or Get and List secret permissions if the vault uses access policies. Both are read-only. If a run says Azure Key Vault … answered 403, that role is missing.

Precedence

Values from the vault override the environment's own values. A data file row, values set by scripts, and --var override them in turn. Secrets are fetched once per run.