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 version | Display extension version |
Global Flags
These flags are available for all HTTP method commands.
Authentication
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--scope | -s | string | (auto) | OAuth scope. Auto-detected for Azure services if not provided. |
--no-auth | bool | false | Skip authentication. Use for public APIs. |
Request Configuration
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--header | -H | string[] | [] | Custom headers (repeatable). Format: Key:Value |
--data | -d | string | "" | Request body (JSON string) |
--data-file | string | "" | Read request body from file. Also accepts @file shorthand. | |
--timeout | -t | duration | 30s | Request timeout. Examples: 30s, 5m, 1h |
--insecure | -k | bool | false | Skip TLS certificate verification |
Response Configuration
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--format | -f | string | auto | Output format: auto (pretty JSON), json (compact), raw |
--output-file | string | "" | Write response to file | |
--binary | bool | false | Stream as binary without transformation | |
--verbose | -v | bool | false | Show headers, timing, request details (tokens redacted) |
Advanced Options
| Flag | Type | Default | Description |
|---|---|---|---|
--paginate | bool | false | Follow continuation tokens / next links |
--retry | int | 3 | Retry attempts with exponential backoff for transient errors |
--follow-redirects | bool | true | Follow HTTP redirects |
--max-redirects | int | 10 | Maximum redirect hops |
Version Command
# Default outputazd rest version
# Quiet — version number onlyazd rest version --quiet
# JSON outputazd rest version --format json| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
--quiet | -q | bool | false | Display only the version number |
--format | -f | string | auto | Output 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
| Service | Hostname Pattern | Scope |
|---|---|---|
| Azure Management API | management.azure.com | https://management.azure.com/.default |
| Microsoft Graph | graph.microsoft.com | https://graph.microsoft.com/.default |
| Azure Key Vault | *.vault.azure.net | https://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.io | https://containerregistry.azure.net/.default |
| Azure Cosmos DB | *.documents.azure.com | https://cosmos.azure.com/.default |
| Azure App Configuration | *.azconfig.io | https://azconfig.io/.default |
| Azure Batch | *.batch.azure.com | https://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.net | https://database.windows.net/.default |
| Azure Synapse | *.dev.azuresynapse.net | https://dev.azuresynapse.net/.default |
| Azure Data Lake | *.azuredatalakestore.net | https://datalake.azure.net/.default |
| Azure Media Services | *.media.azure.net | https://rest.media.azure.net/.default |
| Azure Log Analytics | api.loganalytics.io | https://api.loganalytics.io/.default |
| Azure DevOps | dev.azure.com*.visualstudio.com | 499b84ac-1321-427f-aa17-267ca6975798/.default |
| Azure Kusto | *.kusto.windows.net | https://{hostname}/.default |
| Azure Service Bus | *.servicebus.windows.net | https://servicebus.azure.net/.default |
| Azure Event Hubs | *.servicebus.windows.net | https://eventhubs.azure.net/.default |
Custom Scopes
For services not in the auto-detection list, provide a scope manually:
azd rest get https://api.myservice.com/data --scope https://myservice.com/.defaultPagination
When --paginate is enabled, azd rest automatically follows continuation tokens from Azure APIs. It looks for:
nextLinkin the JSON response body@odata.nextLinkin OData responsesLinkHTTP headers withrel="next"
# Get all resources across all pagesazd rest get https://management.azure.com/subscriptions/{sub}/resources?api-version=2021-04-01 --paginateRetry Configuration
azd rest automatically retries failed requests with exponential backoff for transient errors (5xx status codes, network errors).
# Default: 3 retriesazd rest get https://api.example.com/resource
# Custom retry countazd rest get https://api.example.com/resource --retry 5
# Disable retriesazd rest get https://api.example.com/resource --retry 0Exit Codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Request failed (HTTP error, network error) |
2 | Invalid arguments or configuration |
Troubleshooting
Authentication Errors
Error: failed to get token: credential unavailable
# Ensure you're logged in to Azureaz login
# Or use service principalexport AZURE_CLIENT_ID="..."export AZURE_CLIENT_SECRET="..."export AZURE_TENANT_ID="..."Scope Detection Issues
Error: Warning: Azure host detected but no scope found
# Manually specify scopeazd rest get https://management.azure.com/... --scope https://management.azure.com/.defaultNetwork Errors
Error: timeout or connection refused
# Increase timeoutazd rest get https://api.example.com/resource --timeout 5m
# Check proxy settingsecho $HTTP_PROXYecho $HTTPS_PROXYInvalid JSON Response
Error: failed to format response: invalid JSON
# Use raw format to see actual responseazd rest get https://api.example.com/resource --format raw