Build a Python Flask CRUD App with Azure File Storage
This guide walks you through building a CRUD application using Python Flask and Azure File Storage from scratch. You'll learn how to connect Flask with Azure Blob Storage, handle file uploads, list files, and delete files seamlessly.
1. Prerequisites
- Python installed (Python 3.7+ recommended).
- An Azure account.
- Azure Storage Account created. Create one here if needed.
- Install the required Python packages:
2. Setting up Azure File Storage
Create a Storage Account:
- Go to the Azure portal and create a Storage Account.
- Note down the Storage Account Name and Access Key.
Create a File Share:
- Inside your Storage Account, navigate to File Shares.
- Create a new file share and note its Name.
3. Project Structure
Create the following directory structure for your project:
4. Installing Dependencies
Add the following to your requirements.txt
file:
Install the dependencies:
5. Configure Environment Variables
Create a .env
file to securely store your Azure credentials:
6. Flask Application Code
app.py
This is the main application code to interact with Azure File Storage.
7. HTML Templates
templates/index.html
templates/upload.html
templates/files.html
8. Running the Application
- Start the Flask server:
- Open your browser and navigate to
http://127.0.0.1:5000
.