---
name: azion-send-logs-to-azure-blob-storage
description: >-
  Create a stream that writes the logs of your applications to an Azure Blob Storage container, in Azion Console or with the Azion API, and confirm the delivery.
---

# Send logs to Azure Blob Storage

You can send the logs of a stream to an [Azure Blob Storage](https://azure.microsoft.com/en-us/products/storage/blobs) container from Azion Console or with the Azion API. To send them to a workspace in Azure Monitor instead, refer to [Send logs to Azure Monitor](/en/documentation/guides/platform/observability/endpoint-azure-monitor/).

[Data Stream](/en/documentation/platform/data-stream/) writes the log lines to a container of your Azure storage account. The stream form sets the endpoint in the field labeled **Connector**, where Azure Blob Storage is the *Azure Blob Storage* option. For every field and its bounds, refer to [Endpoints](/en/documentation/platform/data-stream/endpoints/#azure-blob-storage).

The example collects the requests of one workload with the *Applications* data source.

---

Select your interface once. The prerequisites and every task below show only that path.

## Prerequisites

- An Azion account with the **Edit Data Stream** permission. For the permissions, refer to [Stream settings](/en/documentation/platform/data-stream/stream-settings/#permissions).
- A [workload](/en/documentation/platform/workloads/) on the account that receives requests.
- An Azure storage account and its name, such as `mystorageaccount`.
- A container in the storage account. The container must exist before the stream sends to it.
- A shared access signature (SAS) token for the container, with the create, read, write, and list permissions.

**Console**

- Access to Azion Console. To sign in, refer to [How to access Azion Console](/en/documentation/guides/platform/account-and-billing/how-to-access-azion-console/).

**API**

- A personal token. To create one, refer to [How to manage a personal token](/en/documentation/guides/platform/account-and-billing/personal-tokens/).
- The ID of the workload.
- `curl`.

---

## Create the stream

A workload filter selects the workload the stream collects from. Your other streams stay active, which is not the case with sampling.

**Console**

To create the stream in Azion Console:

1. **Open Data Stream**

   Access [Azion Console](https://console.azion.com/) > **Data Stream**.

2. **Select + Stream**

3. **Name the stream**

   In the **General** section, enter a **Name**. For example: `logs-to-azure-blob`.

4. **Select the data source**

   In the **Input** section, select *Applications* in **Data Source**.

5. **Turn off Sampling**

   In the **Transform** section, turn off **Sampling** while **Option** is still *All Current and Future Workloads*, its starting value. A stream cannot carry sampling and a workload filter together.

6. **Choose the workload**

   In the **Transform** section, set **Option** to *Filter Workloads*. Select your workload in **Available Workload**, then use the arrow to move it to **Chosen Workload**.

7. **Select the template**

   In the **Render Template** section, select *Applications Event Collector* in **Template**.

8. **Select the Azure Blob Storage endpoint**

   In the **Output** section, select *Azure Blob Storage* in **Connector**.

9. **Enter the container location**

   Enter the name of the storage account in **Storage Account**, such as `mystorageaccount`. Enter the name of the container in **Container Name**, such as `azion-logs`.

10. **Enter the SAS token**

    Paste the SAS token of the container in **Blob SAS Token**.

11. **Keep the stream active**

    In the **Status** section, keep **Active** turned on.

12. **Select Save**

The Console shows `Your data stream has been created`. The **Data Stream** list shows the stream with `Azure Blob Storage` in the **Connector** column and the **Active** status.

**API**

To create the stream with the API, send a `POST` request to `https://api.azion.com/v4/workspace/stream/streams`. Replace `[TOKEN VALUE]` with your personal token, `<workload-id>` with the ID of your workload, and the storage values with your own:

```bash
curl -X POST 'https://api.azion.com/v4/workspace/stream/streams' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Token [TOKEN VALUE]' \
  -d '{
    "name": "logs-to-azure-blob",
    "active": true,
    "inputs": [
      { "type": "raw_logs", "attributes": { "data_source": "workloads" } }
    ],
    "transform": [
      { "type": "filter_workloads", "attributes": { "workloads": [<workload-id>] } },
      { "type": "render_template", "attributes": { "template": 2 } }
    ],
    "outputs": [
      {
        "type": "azure_blob_storage",
        "attributes": {
          "storage_account": "mystorageaccount",
          "container_name": "azion-logs",
          "blob_sas_token": "[SAS TOKEN]"
        }
      }
    ]
  }'
```

The `workloads` data source is *Applications* in the Console, and template `2` is *Applications Event Collector*. The API answers `201` with the stored stream:

```json
{
  "state": "executed",
  "data": {
    "id": 12357,
    "name": "logs-to-azure-blob",
    "last_editor": "user@example.com",
    "created": "2026-01-01T12:10:44.000000Z",
    "last_modified": "2026-01-01T12:10:44.000000Z",
    "product_version": "1.0",
    …
    "outputs": [
      {
        "type": "azure_blob_storage",
        "attributes": {
          "storage_account": "mystorageaccount",
          "container_name": "azion-logs",
          "blob_sas_token": "[SAS TOKEN]"
        }
      }
    ]
  }
}
```

The `id` identifies the stream in every later request, such as `/v4/workspace/stream/streams/12357`. For every key of the body, refer to [Stream settings](/en/documentation/platform/data-stream/stream-settings/#stream-object).

Neither the API nor the Console contacts the container when it saves the stream. A wrong storage account, container name, or SAS token appears only when the stream sends. An activation takes effect after one to two minutes.

---

## Confirm the delivery

[Real-Time Events](/en/documentation/platform/real-time-events/data-sources/#data-stream) records every send of a stream, with the status code the endpoint returned, whether the send succeeds or fails. Send a few requests to the workload, then wait about a minute. A stream sends a batch every 60 seconds, or earlier when the batch reaches 2,000 log lines.

**Console**

To find the sends in Azion Console:

1. **Open Real-Time Events**

   Access [Azion Console](https://console.azion.com/) > **Real-Time Events**.

2. **Select the Data Stream data source**

3. **Read the latest sends**

   Each row is one send. Find the rows with `AZURE_BLOB_STORAGE` in **Endpoint Type**, and read their **Status Code**.

A **Status Code** of `200` means the container accepted the batch. **Streamed Lines** gives the number of log lines in the batch.

**API**

To read the sends with the API, query the `dataStreamedEvents` dataset of the Real-Time Events GraphQL API. Replace the dates with a range that starts at the activation of the stream:

```bash
curl -X POST 'https://api.azion.com/v4/events/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Token [TOKEN VALUE]' \
  -d '{"query":"query { dataStreamedEvents(limit: 20, filter: {tsRange: {begin: \"2026-01-01T12:00:00\", end: \"2026-01-01T12:45:00\"}}, orderBy: [ts_DESC]) { ts endpointType statusCode streamedLines dataStreamed } }"}'
```

The API answers `200` with one record for each send, the latest first:

```json
{
  "data": {
    "dataStreamedEvents": [
      {
        "ts": "2026-01-01T12:02:04Z",
        "endpointType": "AZURE_BLOB_STORAGE",
        "statusCode": 200,
        "streamedLines": 2,
        "dataStreamed": 2797
      }
    ]
  }
}
```

A send to Azure Blob Storage carries `AZURE_BLOB_STORAGE` in `endpointType`. A `statusCode` of `200` means the container accepted the batch of `streamedLines` log lines and `dataStreamed` bytes. An empty `dataStreamedEvents` list means the stream has not sent in the range. For every field, refer to [Real-Time Events GraphQL fields](/en/documentation/devtools/graphql/gql-real-time-events-fields/#datastreamedevents-data-stream).

A status other than `200` comes from the endpoint, except `503`, which means Data Stream found the endpoint unavailable. For the causes, refer to [Troubleshoot Data Stream](/en/documentation/platform/data-stream/troubleshooting/).

---

## Next steps

- [Endpoints](/en/documentation/platform/data-stream/endpoints.md#azure-blob-storage): Every field of the Azure Blob Storage endpoint, with its type, bounds, and API name.
- [Send logs to Azure Monitor](/en/documentation/guides/platform/observability/endpoint-azure-monitor.md): Send the logs to a workspace in Azure Monitor instead of a container.
- [Edit, stop, or delete a stream](/en/documentation/guides/platform/observability/delete-data-stream.md): Change the container or the SAS token, pause the stream, or remove it.
- [Troubleshoot Data Stream](/en/documentation/platform/data-stream/troubleshooting.md): Find what to change when a send returns a status other than 200.
