> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tornadoapi.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure Azure Blob Storage

> Configure Azure Blob Storage for your downloads

## Overview

Set up Azure Blob Storage for uploaded videos. Authenticate with either an account key or a SAS token. Credentials are verified before saving.

## Header Parameters

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication
</ParamField>

## Request Body

<ParamField body="account_name" type="string" required>
  Azure Storage Account name
</ParamField>

<ParamField body="container" type="string" required>
  Blob container name
</ParamField>

<ParamField body="account_key" type="string">
  Storage Account access key (Base64 encoded). Required if `sas_token` is not provided.
</ParamField>

<ParamField body="sas_token" type="string">
  SAS token for authentication. Required if `account_key` is not provided.
</ParamField>

<ParamField body="folder_prefix" type="string">
  Optional folder prefix for organizing uploads (e.g., `downloads/2024/`)
</ParamField>

<ParamField body="base_folder" type="string" default="videos">
  Base folder name for uploaded files. Defaults to `videos` if not specified. Set to a custom value to change the top-level folder where files are stored (e.g., `downloads`, `media`).
</ParamField>

<Warning>
  Provide either `account_key` OR `sas_token`, not both. At least one must be provided.
</Warning>

## Response

<ResponseField name="message" type="string">
  Success confirmation message
</ResponseField>

<ResponseField name="provider" type="string">
  Storage provider type: `blob`
</ResponseField>

<ResponseField name="container_or_bucket" type="string">
  The configured container name
</ResponseField>

<ResponseField name="folder_prefix" type="string">
  The configured folder prefix (if provided)
</ResponseField>

## Examples

<CodeGroup>
  ```bash Account Key theme={null}
  curl -X POST "https://api.tornadoapi.io/user/blob" \
    -H "x-api-key: sk_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "account_name": "mystorageaccount",
      "container": "tornado-downloads",
      "account_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxx=="
    }'
  ```

  ```bash SAS Token theme={null}
  curl -X POST "https://api.tornadoapi.io/user/blob" \
    -H "x-api-key: sk_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "account_name": "mystorageaccount",
      "container": "tornado-downloads",
      "sas_token": "sv=2022-11-02&ss=b&srt=co&sp=rwdlacyx&se=2025-12-31T23:59:59Z&sig=..."
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.tornadoapi.io/user/blob",
      headers={"x-api-key": "sk_your_api_key"},
      json={
          "account_name": "mystorageaccount",
          "container": "tornado-downloads",
          "account_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxx=="
      }
  )
  print(response.json())
  ```

  ```json Response theme={null}
  {
    "message": "Azure Blob storage configured successfully",
    "provider": "blob",
    "container_or_bucket": "tornado-downloads"
  }
  ```
</CodeGroup>

## Success Response

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "message": "Azure Blob storage configured successfully",
    "provider": "blob",
    "container_or_bucket": "tornado-downloads"
  }
  ```
</ResponseExample>

## Error Responses

<ResponseExample>
  ```json 400 Bad Request - Missing Auth theme={null}
  {
    "error": "Either account_key or sas_token must be provided"
  }
  ```

  ```json 400 Bad Request - Invalid Credentials theme={null}
  {
    "error": "Credential validation failed: AuthenticationFailed"
  }
  ```

  ```json 400 Bad Request - Invalid Key Format theme={null}
  {
    "error": "Account key must be valid Base64"
  }
  ```

  ```json 401 Unauthorized theme={null}
  {
    "error": "Invalid API Key"
  }
  ```

  ```json 503 Service Unavailable theme={null}
  {
    "error": "Azure Blob storage configuration is temporarily unavailable"
  }
  ```
</ResponseExample>

## Verification Process

When you submit storage configuration, Tornado:

1. Validates that either `account_key` or `sas_token` is provided
2. Creates a storage client with your credentials
3. Attempts to upload a small test file (`verify_credentials.txt`)
4. Deletes the test file
5. If successful, saves the configuration encrypted

## Required SAS Permissions

When using a SAS token, ensure these permissions are enabled:

* **Read** (r) - For generating download URLs
* **Write** (w) - For uploading files
* **Delete** (d) - For cleanup operations
* **List** (l) - For validation
