# API Reference


## Refresh tokens and credentials


Find the `az login` refresh token, or sign in for one, and redeem it.


[refresh_token_from_az_cli()](refresh_token_from_az_cli.md#dazapiz.refresh_token_from_az_cli)  
The refresh token of the account the Azure CLI is signed in as.

[RefreshTokenInfo](RefreshTokenInfo.md#dazapiz.RefreshTokenInfo)  
A refresh token with the client ID and tenant it belongs to.

[SupportsRefreshToken](SupportsRefreshToken.md#dazapiz.SupportsRefreshToken)  
Anything that can hand over a refresh token with its client ID and tenant.

[AZURE_CLI_CLIENT_ID](AZURE_CLI_CLIENT_ID.md#dazapiz.AZURE_CLI_CLIENT_ID)  
The Azure CLI's public client ID, to which `az login` refresh tokens are issued.

[RefreshTokenCredential](RefreshTokenCredential.md#dazapiz.RefreshTokenCredential)  
A `TokenCredential` that redeems a refresh token for access tokens.

[DeviceCodeCredential](DeviceCodeCredential.md#dazapiz.DeviceCodeCredential)  
`azure.identity.DeviceCodeCredential` with a persisted cache and `get_refresh_token()`.

[InteractiveBrowserCredential](InteractiveBrowserCredential.md#dazapiz.InteractiveBrowserCredential)  
`azure.identity.InteractiveBrowserCredential` with a persisted cache and `get_refresh_token()`.


## Spark


Hadoop ABFS configuration for PySpark.


[spark_storage_conf()](spark_storage_conf.md#dazapiz.spark_storage_conf)  
Build the Hadoop `fs.azure.*` keys that let Spark read ADLS Gen2.

[SparkStorageConf](SparkStorageConf.md#dazapiz.SparkStorageConf)  
The `fs.azure.*` keys of `spark_storage_conf()`, as a plain `dict[str, str]`.


## REST client


A small httpx client for one Azure-protected REST API, and its credentials.


[ApiClient](ApiClient.md#dazapiz.ApiClient)  
A client for one REST API, meant to be subclassed once per API.

[app_credential()](app_credential.md#dazapiz.app_credential)  
The credential an API's client uses, chosen from the environment now.


## az CLI


Log the Azure CLI in and out, and read its current account.


[az_login()](az_login.md#dazapiz.az_login)  
Log the Azure CLI in with a device code, unless it already is.

[az_logout()](az_logout.md#dazapiz.az_logout)  
Log the Azure CLI out, by `az logout`.

[az_is_login()](az_is_login.md#dazapiz.az_is_login)  
Whether the Azure CLI is logged in, by `az account show`.

[az_account_show()](az_account_show.md#dazapiz.az_account_show)  
The Azure CLI's current account, from `az account show --output json`.


## DuckDB


Azure secrets and settings for DuckDB, in `dazapiz.duckdb` (needs `dazapiz[duckdb]`).


[duckdb.set_credential_secret()](duckdb.set_credential_secret.md#dazapiz.duckdb.set_credential_secret)  
Register an access token from any `TokenCredential` as a DuckDB Azure secret.

[duckdb.set_token_secret()](duckdb.set_token_secret.md#dazapiz.duckdb.set_token_secret)  
Register an access token as a DuckDB Azure secret.

[duckdb.set_sp_secret()](duckdb.set_sp_secret.md#dazapiz.duckdb.set_sp_secret)  
Register a service principal as a DuckDB Azure secret.

[duckdb.set_chain_secret()](duckdb.set_chain_secret.md#dazapiz.duckdb.set_chain_secret)  
Register a DuckDB credential-chain secret, which DuckDB resolves itself.

[duckdb.list_secrets()](duckdb.list_secrets.md#dazapiz.duckdb.list_secrets)  
The connection's Azure secrets, as `quak::az_list_secrets()`.

[duckdb.azure_settings()](duckdb.azure_settings.md#dazapiz.duckdb.azure_settings)  
The connection's Azure settings, as `quak::az_conn_settings()`.

[duckdb.tune()](duckdb.tune.md#dazapiz.duckdb.tune)  
Set the Azure read and transport settings, as `quak::az_tune()`.

[duckdb.STORAGE_SCOPE](duckdb.STORAGE_SCOPE.md#dazapiz.duckdb.STORAGE_SCOPE)  
The Azure Storage token scope, `set_credential_secret()`'s default `scope`.


## Testing


Test doubles for code built on dazapiz, in `dazapiz.testing`.


[testing.StaticTokenCredential](testing.StaticTokenCredential.md#dazapiz.testing.StaticTokenCredential)  
A credential that returns a fixed token and records what it was asked for.


## Errors


Everything dazapiz raises derives from `DazapizError`.


[DazapizError](DazapizError.md#dazapiz.DazapizError)  
Base class of every error dazapiz raises.

[RefreshTokenNotFoundError](RefreshTokenNotFoundError.md#dazapiz.RefreshTokenNotFoundError)  
No refresh token was found where one was looked for.

[UnsupportedPlatformError](UnsupportedPlatformError.md#dazapiz.UnsupportedPlatformError)  
The operation is not available on this operating system.

[AzCliError](AzCliError.md#dazapiz.AzCliError)  
An `az` command failed; the message carries what `az` wrote to stderr.

[AzCliNotFoundError](AzCliNotFoundError.md#dazapiz.AzCliNotFoundError)  
No `az` on PATH.

[AzCliNotLoggedInError](AzCliNotLoggedInError.md#dazapiz.AzCliNotLoggedInError)  
The Azure CLI is not logged in.

[AzCliNonInteractiveError](AzCliNonInteractiveError.md#dazapiz.AzCliNonInteractiveError)  
`az_login()` was called where nobody can answer the device-code prompt.

[AzCliTimeoutError](AzCliTimeoutError.md#dazapiz.AzCliTimeoutError)  
An `az` command did not finish within its timeout and was killed.

[ApiError](ApiError.md#dazapiz.ApiError)  
An `ApiClient` request ended in a non-2xx response, after any retries.

[ResponseParseError](ResponseParseError.md#dazapiz.ResponseParseError)  
A successful response's body could not be parsed or was rejected by `parse=`.
