Skip to main content

Azure Blob Storage Plugin for Search Toolkit

Azure Blob Storage backend for mistralai-search-toolkit.

This plugin implements the Search Toolkit's ObjectStorage interface, enabling the ingestion pipeline to load files directly from Azure Blob Storage.

Installation

pip install mistralai-search-toolkit-storage-azure

Or as an optional dependency of the core package:

pip install mistralai-search-toolkit[storage-azure]

Quick Start: Load Files from Azure in Ingestion Pipeline

1. Upload a File to Azure Blob Storage

import asyncio
from mistralai.search.toolkit.plugins.storage.azure import AzureBlobStorage


async def upload_file():
    storage = AzureBlobStorage(
        container_name="documents",
        account_name="your-account",
    )

    # Upload a file
    with open("document.pdf", "rb") as f:
        data = f.read()

    await storage.put(key="documents/document.pdf", data=data)


asyncio.run(upload_file())

2. Load Files from Azure in Ingestion Pipeline

import asyncio
import os
from mistralai.search.toolkit.ingestion.loaders import FileLoader
from mistralai.search.toolkit.ingestion.pipelines import Pipeline
from mistralai.search.toolkit.ingestion.text_splitters import CharacterTextSplitter
from mistralai.search.toolkit.embedders import MistralEmbedder, MODEL_1024_EMBEDDING
from mistralai.client import Mistral
from mistralai.search.toolkit.plugins.storage.azure import AzureBlobStorage
from mistralai.search.toolkit.plugins.vespa import VespaClientConfig
from vespa_app import app


async def ingest_from_azure():
    # Create Azure storage factory
    def azure_storage_factory():
        return AzureBlobStorage(
            container_name="documents",
            account_name="your-account",
        )

    # Create FileLoader backed by Azure
    file_loader = FileLoader(storage_factory=azure_storage_factory)

    # Create ingestion pipeline
    mistral_client = Mistral(api_key=os.environ.get("MISTRAL_API_KEY"))
    vespa_config = VespaClientConfig(
        endpoint=os.environ.get("VESPA_ENDPOINT", "http://localhost:8080"),
    )
    vector_store = app.get_search_index(vespa_config, collection_name="articles")

    pipeline = Pipeline(
        loader=file_loader,
        text_splitter=CharacterTextSplitter(chunk_size=512),
        embedder=MistralEmbedder(client=mistral_client, model_name=MODEL_1024_EMBEDDING),
        stores=vector_store,
    )

    # Ingest documents from Azure
    num_chunks = await pipeline.run(
        documents=[
            "documents/document1.pdf",
            "documents/document2.pdf",
        ]
    )

    print(f"Indexed {num_chunks} chunks")


asyncio.run(ingest_from_azure())

Configuration

Basic Setup

storage = AzureBlobStorage(
    container_name="documents",
    account_name="your-account",
)

Using Connection String

storage = AzureBlobStorage(
    container_name="documents",
    connection_string="DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...",
)

Using Account Key

storage = AzureBlobStorage(
    container_name="documents",
    account_name="your-account",
    account_key="your-key",
)

Using Managed Identity

from azure.identity.aio import DefaultAzureCredential

storage = AzureBlobStorage(
    container_name="documents",
    account_name="your-account",
    credential=DefaultAzureCredential(),
)

Local Development

For local testing, use Azurite:

docker run -p 10000:10000 mcr.microsoft.com/azure-storage/azurite azurite-blob --blobHost 0.0.0.0

Configure to use local emulator:

storage = AzureBlobStorage(
    container_name="documents",
    connection_string="DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=<key>;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1/;",
)

License

This plugin is licensed under the Apache License 2.0.

Support

For Search Toolkit issues, refer to the Search Toolkit documentation.

For Azure Blob Storage documentation, visit Azure Blob Storage Docs.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file mistralai_search_toolkit_storage_azure-0.0.11.tar.gz.

File metadata

File hashes

Hashes for mistralai_search_toolkit_storage_azure-0.0.11.tar.gz
Algorithm Hash digest
SHA256 a33c98f35620aae7231cec01794ff66449eb82b234ae2f26641110f40438355d
MD5 590d46e06f54b0c2433b2ecebf9121b0
BLAKE2b-256 97eb97b09946ac99a8753e19df5308f739fa2e2ee99ac629af4fc5c37054eb81

See more details on using hashes here.

Provenance

The following attestation bundles were made for mistralai_search_toolkit_storage_azure-0.0.11.tar.gz:

Publisher: search-toolkit-plugins.yaml on mistralai/dashboard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mistralai_search_toolkit_storage_azure-0.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for mistralai_search_toolkit_storage_azure-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 cc838006017bfc3acaa5907fa1bb15f31ea1b1e84d1ae89f4f93f0decd62e322
MD5 610e44488f2809178370a4a53e4aae6f
BLAKE2b-256 87ce77cc3de01a3084ea263db50ad28403e4bffd30cd5d958a9fa01aa1bd2542

See more details on using hashes here.

Provenance

The following attestation bundles were made for mistralai_search_toolkit_storage_azure-0.0.11-py3-none-any.whl:

Publisher: search-toolkit-plugins.yaml on mistralai/dashboard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.11 This release

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.6

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page