Simple Azure Blob Downloader

0.1.0 · active · verified Thu Apr 16

simple-azure-blob-downloader is a Python library designed to simplify the process of downloading blobs from Azure Blob Storage. It provides a straightforward interface, acting as a wrapper around the official Azure Storage Blob client library. As of version 0.1.0, it offers basic download functionality.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to download a single blob from Azure Blob Storage using the `download_blob` function. Ensure your Azure Storage connection string, container name, and blob name are configured, preferably via environment variables for security.

import os
from simple_azure_blob_downloader import download_blob

# Set environment variables for secure access
# AZURE_STORAGE_CONNECTION_STRING should be your storage account's connection string
# e.g., 'DefaultEndpointsProtocol=https;AccountName=youraccount;AccountKey=yourkey;EndpointSuffix=core.windows.net'
connection_string = os.environ.get('AZURE_STORAGE_CONNECTION_STRING', 'YOUR_AZURE_STORAGE_CONNECTION_STRING')
container_name = os.environ.get('AZURE_BLOB_CONTAINER_NAME', 'my-container')
blob_name = os.environ.get('AZURE_BLOB_NAME', 'my-file.txt')
local_destination_path = os.environ.get('LOCAL_DOWNLOAD_PATH', 'downloaded_file.txt')

if connection_string == 'YOUR_AZURE_STORAGE_CONNECTION_STRING':
    print("Please set the AZURE_STORAGE_CONNECTION_STRING environment variable or replace the placeholder.")
else:
    try:
        # Download a single blob
        download_blob(connection_string, container_name, blob_name, local_destination_path)
        print(f"Successfully downloaded '{blob_name}' to '{local_destination_path}'.")
    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →