Skip to main content
azd extensions azd rest
azd rest

Commands

All HTTP method commands follow the same pattern: azd rest <method> <url> [flags]

Command Description
azd rest get <url>Execute a GET request
azd rest post <url>Execute a POST request
azd rest put <url>Execute a PUT request
azd rest patch <url>Execute a PATCH request
azd rest delete <url>Execute a DELETE request
azd rest head <url>Execute a HEAD request (headers only)
azd rest options <url>Execute an OPTIONS request
azd rest versionDisplay extension version

Global Flags

These flags are available for all HTTP method commands.

Authentication

FlagShortTypeDefaultDescription
--scope-sstring(auto)OAuth scope. Auto-detected for Azure services if not provided.
--no-authboolfalseSkip authentication. Use for public APIs.

Request Configuration

FlagShortTypeDefaultDescription
--header-Hstring[][]Custom headers (repeatable). Format: Key:Value
--data-dstring""Request body (JSON string)
--data-filestring""Read request body from file. Also accepts @file shorthand.
--timeout-tduration30sRequest timeout. Examples: 30s, 5m, 1h
--insecure-kboolfalseSkip TLS certificate verification

Response Configuration

FlagShortTypeDefaultDescription
--format-fstringautoOutput format: auto (pretty JSON), json (compact), raw
--output-filestring""Write response to file
--binaryboolfalseStream as binary without transformation
--verbose-vboolfalseShow headers, timing, request details (tokens redacted)

Advanced Options

FlagTypeDefaultDescription
--paginateboolfalseFollow continuation tokens / next links
--retryint3Retry attempts with exponential backoff for transient errors
--follow-redirectsbooltrueFollow HTTP redirects
--max-redirectsint10Maximum redirect hops

Version Command

Terminal window
# Default output
azd rest version
# Quiet — version number only
azd rest version --quiet
# JSON output
azd rest version --format json
FlagShortTypeDefaultDescription
--quiet-qboolfalseDisplay only the version number
--format-fstringautoOutput format: auto or json

Scope Detection

azd rest automatically detects the correct OAuth scope based on the URL hostname. This eliminates the need to manually specify scopes for most Azure API calls.

Supported Azure Services

ServiceHostname PatternScope
Azure Management APImanagement.azure.comhttps://management.azure.com/.default
Microsoft Graphgraph.microsoft.comhttps://graph.microsoft.com/.default
Azure Key Vault*.vault.azure.nethttps://vault.azure.net/.default
Azure Storage*.blob.core.windows.net
*.queue.core.windows.net
*.table.core.windows.net
*.file.core.windows.net
*.dfs.core.windows.net
https://storage.azure.com/.default
Azure Container Registry*.azurecr.iohttps://containerregistry.azure.net/.default
Azure Cosmos DB*.documents.azure.comhttps://cosmos.azure.com/.default
Azure App Configuration*.azconfig.iohttps://azconfig.io/.default
Azure Batch*.batch.azure.comhttps://batch.core.windows.net/.default
Azure Database (PostgreSQL/MySQL)*.postgres.database.azure.com
*.mysql.database.azure.com
*.mariadb.database.azure.com
https://ossrdbms-aad.database.windows.net/.default
Azure SQL Database*.database.windows.nethttps://database.windows.net/.default
Azure Synapse*.dev.azuresynapse.nethttps://dev.azuresynapse.net/.default
Azure Data Lake*.azuredatalakestore.nethttps://datalake.azure.net/.default
Azure Media Services*.media.azure.nethttps://rest.media.azure.net/.default
Azure Log Analyticsapi.loganalytics.iohttps://api.loganalytics.io/.default
Azure DevOpsdev.azure.com
*.visualstudio.com
499b84ac-1321-427f-aa17-267ca6975798/.default
Azure Kusto*.kusto.windows.nethttps://{hostname}/.default
Azure Service Bus*.servicebus.windows.nethttps://servicebus.azure.net/.default
Azure Event Hubs*.servicebus.windows.nethttps://eventhubs.azure.net/.default

Custom Scopes

For services not in the auto-detection list, provide a scope manually:

Terminal window
azd rest get https://api.myservice.com/data --scope https://myservice.com/.default

Pagination

When --paginate is enabled, azd rest automatically follows continuation tokens from Azure APIs. It looks for:

  • nextLink in the JSON response body
  • @odata.nextLink in OData responses
  • Link HTTP headers with rel="next"
Terminal window
# Get all resources across all pages
azd rest get https://management.azure.com/subscriptions/{sub}/resources?api-version=2021-04-01 --paginate

Retry Configuration

azd rest automatically retries failed requests with exponential backoff for transient errors (5xx status codes, network errors).

Terminal window
# Default: 3 retries
azd rest get https://api.example.com/resource
# Custom retry count
azd rest get https://api.example.com/resource --retry 5
# Disable retries
azd rest get https://api.example.com/resource --retry 0

Exit Codes

CodeMeaning
0Success
1Request failed (HTTP error, network error)
2Invalid arguments or configuration

Troubleshooting

Authentication Errors

Error: failed to get token: credential unavailable

Terminal window
# Ensure you're logged in to Azure
az login
# Or use service principal
export AZURE_CLIENT_ID="..."
export AZURE_CLIENT_SECRET="..."
export AZURE_TENANT_ID="..."

Scope Detection Issues

Error: Warning: Azure host detected but no scope found

Terminal window
# Manually specify scope
azd rest get https://management.azure.com/... --scope https://management.azure.com/.default

Network Errors

Error: timeout or connection refused

Terminal window
# Increase timeout
azd rest get https://api.example.com/resource --timeout 5m
# Check proxy settings
echo $HTTP_PROXY
echo $HTTPS_PROXY

Invalid JSON Response

Error: failed to format response: invalid JSON

Terminal window
# Use raw format to see actual response
azd rest get https://api.example.com/resource --format raw

More Resources