Blob Storage
This guide shows you how to work with Azure Blob Storage locally using Azurite, Docker Compose, and Python. This lab demonstrates how to create containers and upload and download blobs.
Prerequisites
Section titled “Prerequisites”- Docker installed and running.
- Dev Containers extension installed (optional).
- Azure Storage extension (optional, included in Dev Container).
How to execute
Section titled “How to execute”-
Setup Environment:
Open VS Code in the project folder and execute this command in the Command Palette:
Terminal window > Dev Containers: Reopen in Container- Start Infrastructure: Launch the Azurite container.
Terminal window docker compose up -d - Run the setup script to install tools and dependencies.
Terminal window scripts/setup.sh
Use the Azurite VS Code extension instead of the container.
- Disable the container: Set
COMPOSE_PROFILES=(empty) in.envso the Azurite container is skipped. - Stop the Azurite container if it is running.
Terminal window docker compose stop azurite - Start the emulator from the Command Palette:
Terminal window > Azurite: Start - Run the setup script to install tools and dependencies.
Terminal window scripts/setup.sh
- Start Infrastructure: Launch the Azurite container.
-
Run the Example:
Terminal window python main.py
How to debug
Section titled “How to debug”- Python Script (main.py):
- Open: Open
main.pyin VS Code. - Run: Use the Python: main.py configuration in the Run and Debug tab.
- Open: Open
How to test
Section titled “How to test”- All tests: Run the automated script:
scripts/run_tests.sh - Individually: Use the VS Code Testing tab to run or debug specific test cases.
Validate results
Section titled “Validate results”Connect the Azure Storage extension to your running Azurite to browse containers and blobs visually.
- Open: Open the Azure view in VS Code (Azure icon in the sidebar).
- Attach: Under Storage Accounts, click Attach Storage Account > Attach to a local emulator and accept the defaults (account
devstoreaccount1). - Browse: Expand Local Emulator > Blob Containers to see
test-containerandhello.txt.
Clean Up
Section titled “Clean Up”docker compose down -vTroubleshooting
Section titled “Troubleshooting”| Issue | Solution |
|---|---|
| Port 10000 in use | Another Azurite is bound to it. Stop the VS Code Azurite extension emulator (> Azurite: Close) or the other container before starting. |
| Connection Refused | Ensure Azurite is running: docker ps |
| Module Not Found | Reinstall dependencies: scripts/setup.sh |
azurite.skipApiVersionCheck is not a registered configuration | REST API-version mismatch. The lab already starts Azurite with --skipApiVersionCheck; recreate it with docker compose up -d azurite, then reload the window (> Developer: Reload Window). |
Storage Account devstoreaccount1 is already attached | It is already connected. Locate the existing Local Emulator node and Refresh it instead of re-attaching. |