Storage Writer
This guide shows you how to work with Azure Functions locally using Azurite, Docker Compose, and Python. This lab demonstrates how to create an HTTP-triggered function that uploads files to Azurite blob storage.
Prerequisites
Section titled “Prerequisites”- Docker installed and running.
- Dev Containers extension installed (optional).
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- Install Azure Functions Core Tools: Follow the official installation guide.
- Install dependencies:
Terminal window pip3 install uv && uv sync
-
Start Infrastructure: Launch the Azurite container:
Terminal window docker compose up -d -
Start Function Host:
Terminal window func start --prefix ./upload-function/ -
Run the Example:
Terminal window python main.py
Validate results
Section titled “Validate results”Check using Azure Storage extension:
- Open: Open the Azure view in VS Code (Azure icon in the sidebar).
- Connect: Under Storage Accounts, click Attach Storage Account > Attach to a local emulator.
- Browse: Use the default Azurite connection settings to browse your containers and blobs visually.
Clean Up
Section titled “Clean Up”docker compose down -vTroubleshooting
Section titled “Troubleshooting”| Issue | Solution |
|---|---|
| Connection Refused | Ensure Azurite is running: docker ps |
| Module Not Found | Reinstall function dependencies: cd upload-function && pip install -r requirements.txt |