# Azure Blob Storage

Send2Bucket writes block blobs to a container in your storage account. Authorise it one of two ways:

| `auth` | You give Send2Bucket | Use it when |
|---|---|---|
| `sas` | A SAS token for the container | You want the quickest setup, or your tenant does not allow outside apps |
| `entra` | A role on the container for Send2Bucket's Entra ID app, in your tenant | You want no stored secret and nothing to rotate |

:::note
We ran the writer against Azurite, Microsoft's storage emulator, with a SAS token. The Entra ID flow follows Microsoft's documentation for multi-tenant apps; it was not run against a real tenant for this page.
:::

## What you provide

- Settings: `account` (the storage account name), `container`, and an optional `prefix`, for example `analytics`, `raw-events` and `raw`.
- `auth`: `sas` or `entra`.
- With `sas`, the secret `sas_token`: a SAS for the container with read, create and write permissions.
- With `entra`, `tenant_id`: your Microsoft Entra tenant ID or primary domain.
- `endpoint`, only when your blob endpoint is not `https://<account>.blob.core.windows.net`.

## 1a. With a SAS token

Create a SAS for the container with read, create and write permissions (`sp=rcw`). Signed with the account key it can last as long as you choose; a user delegation SAS lasts at most seven days.

```bash
az storage container generate-sas \
  --account-name <account> --name <container> \
  --permissions rcw --expiry 2027-12-31T00:00Z --https-only \
  --account-key <account_key> --output tsv
```

Paste the output into `sas_token`. When the SAS expires or is revoked, Azure refuses writes, the destination becomes `blocked` and organization owners are emailed; accepted batches wait until you save a new token and verify again.

## 1b. With Entra ID

Send2Bucket's app client ID is shown in the dashboard on the destination. An admin of your tenant consents to the app once, which adds it to the tenant:

```text
https://login.microsoftonline.com/<tenant_id>/adminconsent?client_id=<azure_client_id>
```

Then grant it Storage Blob Data Contributor on the container:

```bash
az role assignment create \
  --assignee <azure_client_id> \
  --role "Storage Blob Data Contributor" \
  --scope "/subscriptions/<subscription>/resourceGroups/<group>/providers/Microsoft.Storage/storageAccounts/<account>/blobServices/default/containers/<container>"
```

Role assignments can take a few minutes to apply. Send2Bucket requests short-lived tokens for its app in your tenant; no credential is stored for the destination.

## 2. Add the destination

Enter the settings in the dashboard and select Verify. Send2Bucket writes a test blob under `raw/s2b/_verify/` and reads it back; the destination then becomes `active`.

## How uploads are made safe to retry

Send2Bucket puts each blob with `If-None-Match: *`, so an upload never replaces an existing blob, and tags it with the delivery batch ID as blob metadata. After a conflict or an ambiguous response it reads that metadata and marks the batch delivered only if the blob holds the same delivery batch.

Blobs use the layout in [Delivery format](../delivery-format.md).

## Query your data

No querying guide covers Azure Blob Storage yet. An engine that reads gzip NDJSON from Azure can read the blobs in place, with the layout in [Delivery format](../delivery-format.md#object-keys). The [querying overview](../querying/index.md) lists the engines we document for the other destinations.
