# AzureBlobBackend

> **Class** in `langchain_azure_storage`

📖 [View in docs](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend)

Azure Blob Storage filesystem backend for Deep Agents.

Implements ``BackendProtocol`` using Azure Blob Storage as the persistence
layer. File content is stored in blob bodies (UTF-8 text, or raw bytes for
binary uploads). Directories are synthesized on the fly from blob key
prefixes (no directory marker blobs).

Two operations destroy data already in the container, both reachable as
agent tools: :meth:`write` replaces an existing file in full, and
:meth:`delete` removes a path plus everything nested under it. Deleting
``"/"`` empties the configured ``prefix`` namespace -- or, with no
``prefix``, the entire container. Set a ``prefix`` and enable container
soft-delete/versioning to bound the blast radius.

The underlying Azure SDK clients are created lazily on first use and
cached; call :meth:`close`/:meth:`aclose` (or use the backend as a
context manager) to release them. Because the cached async client is
bound to the event loop it was first used on, drive a given backend
instance's async methods from a single event loop.

## Signature

```python
AzureBlobBackend(
    self,
    account_url: str,
    container_name: str,
    *,
    prefix: str | None = None,
    credential: _SDK_CREDENTIAL_TYPE = None,
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `account_url` | `str` | Yes | Account URL, e.g. ``https://<account>.blob.core.windows.net``. |
| `container_name` | `str` | Yes | Target blob container name. |
| `prefix` | `str \| None` | No | Optional key namespace prefix within the container. Scoping each agent/session to a prefix isolates their files. (default: `None`) |
| `credential` | `_SDK_CREDENTIAL_TYPE` | No | Credential to authenticate with. If ``None``, ``DefaultAzureCredential`` is used. (default: `None`) |

## Extends

- `BackendProtocol`

## Constructors

```python
__init__(
    self,
    account_url: str,
    container_name: str,
    *,
    prefix: str | None = None,
    credential: _SDK_CREDENTIAL_TYPE = None,
) -> None
```

| Name | Type |
|------|------|
| `account_url` | `str` |
| `container_name` | `str` |
| `prefix` | `str \| None` |
| `credential` | `_SDK_CREDENTIAL_TYPE` |


## Methods

- [`from_connection_string()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/from_connection_string)
- [`close()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/close)
- [`aclose()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/aclose)
- [`ls()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/ls)
- [`als()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/als)
- [`read()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/read)
- [`aread()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/aread)
- [`write()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/write)
- [`awrite()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/awrite)
- [`edit()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/edit)
- [`aedit()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/aedit)
- [`delete()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/delete)
- [`adelete()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/adelete)
- [`glob()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/glob)
- [`aglob()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/aglob)
- [`grep()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/grep)
- [`agrep()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/agrep)
- [`upload_files()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/upload_files)
- [`aupload_files()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/aupload_files)
- [`download_files()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/download_files)
- [`adownload_files()`](https://reference.langchain.com/python/langchain-azure-storage/deepagents/backend/AzureBlobBackend/adownload_files)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-azure/blob/e62c2a55aaa0942fdac739b4066011953b80018e/libs/azure-storage/langchain_azure_storage/deepagents/backend.py#L366)