A lightweight, serverless Azure Function that creates zip archives from multiple files sent via API. Perfect for integrating with Azure Logic Apps, Power Automate, or any application that needs on-demand zip file creation.
- Multi-file Support - Bundle multiple files into a single zip archive
- Smart Type Detection - Automatically handles both text and binary files
- Base64 Support - Seamlessly processes binary files (PDF, Word, Excel, images)
- Compression - Built-in ZIP_DEFLATED compression (level 6)
- Security - Filename sanitization and input validation
- Error Handling - Comprehensive error messages and logging
- Logic Apps Ready - Designed for Azure Logic Apps integration
- Cost Effective - Runs on Azure Functions Consumption Plan
- Python 3.9, 3.10, or 3.11
- Azure Functions Core Tools v4.x
- Azure CLI (for deployment)
-
Clone the repository
git clone https://github.com/Gopikrish25/MakeZip.git cd MakeZip -
Install dependencies (optional - automatically installed by Azure Functions)
pip install -r requirements.txt
-
Start the function locally
func start
-
Test the endpoint
curl -X POST http://localhost:7071/api/makezip \ -H "Content-Type: application/json" \ -d '[{"name":"test.txt","content":"Hello World!"}]' \ --output test.zip
POST /api/makezip
Send a JSON array of file objects:
[
{
"name": "filename.txt",
"content": "file content as string"
},
{
"name": "document.pdf",
"content": "base64_encoded_content",
"encoding": "base64"
}
]| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Filename including extension |
content |
string | Yes | File content (plain text or base64) |
encoding |
string | No | Set to "base64" for binary files (auto-detected if omitted) |
-
Success (200): Returns a zip file as binary data
- Content-Type:
application/zip - Content-Disposition:
attachment; filename="archive.zip"
- Content-Type:
-
Error (400): Invalid request
{ "error": "Description of the error" } -
Error (500): Internal server error
{ "error": "Internal server error: details" }
curl -X POST http://localhost:7071/api/makezip \
-H "Content-Type: application/json" \
-d '[
{"name":"readme.txt","content":"This is a text file"},
{"name":"config.json","content":"{\"setting\":\"value\"}"}
]' \
--output files.zip[
{
"name": "readme.txt",
"content": "This is a plain text file"
},
{
"name": "report.docx",
"content": "UEsDBBQABgAIAAAAIQ...[base64 content]...",
"encoding": "base64"
},
{
"name": "invoice.pdf",
"content": "JVBERi0xLjQKJeLjz9...[base64 content]...",
"encoding": "base64"
}
]-
Get File Content - Use appropriate connector (SharePoint, OneDrive, Blob Storage, SFTP)
Action: Get file content -
Convert to Base64 - Use Expression
base64(body('Get_file_content')) -
Compose JSON Array - Build the request payload
[ { "name": "@{triggerBody()?['Name']}", "content": "@{outputs('Convert_to_Base64')}", "encoding": "base64" } ] -
HTTP Action - Call the Azure Function
- Method:
POST - URI:
https://<your-function-app>.azurewebsites.net/api/makezip - Headers:
Content-Type: application/json - Body: Output from Compose action
- Method:
-
Save Result - Store or email the zip file
# Login to Azure
az login
# Deploy the function
func azure functionapp publish myZipFunctionApp- Install the Azure Functions extension
- Click on Azure icon in sidebar
- Click "Deploy to Function App..."
- Follow the prompts
| Metric | Value | Notes |
|---|---|---|
| Max Request Size | 100 MB | Azure Functions limit |
| Max Execution Time | 5 minutes | Consumption plan (can be extended with Premium) |
| Max Memory | 1.5 GB | Consumption plan |
| Compression Level | 6 | Balance between speed and size |
| Supported Files | All types | Text and binary |
- Small files (<10 MB): Works perfectly with default settings
- Medium files (10-50 MB): Monitor execution time
- Large files (>50 MB): Consider Premium plan or Blob Storage integration
- Filename Sanitization - Prevents path traversal attacks
- Input Validation - Comprehensive checks on all inputs
- Error Handling - No sensitive data in error messages
- Authentication - Supports Azure Function Keys (set
authLevelin function.json)
Symptoms: Zip file extracts but files won't open
Solution: Ensure binary files are base64 encoded
{
"name": "document.pdf",
"content": "base64_string_here",
"encoding": "base64" // β Required for binary files
}Symptoms: 400 Bad Request error
Solution:
- Validate JSON syntax (no trailing commas)
- Check quote escaping in content
- Use a JSON validator before sending
Symptoms: Function times out with many/large files
Solution:
- Split into multiple smaller requests
- Increase
functionTimeoutinhost.json - Consider Azure Functions Premium plan
Symptoms: Files are being treated as text instead of binary
Solution: Explicitly set "encoding": "base64" in the request
Running on Azure Functions Consumption Plan:
| Usage | Monthly Cost (USD) |
|---|---|
| 1,000 executions | Free (within free tier) |
| 10,000 executions | ~$0.04 |
| 100,000 executions | ~$0.42 |
| 1,000,000 executions | ~$4.20 |
Calculation based on:
- Execution time: 500ms average
- Memory: 512 MB
- Free tier: 1M executions + 400,000 GB-s per month
- Add password protection for zip files
- Support for nested folder structures
- Async processing for large files
- Webhook notifications on completion
- Multiple compression formats (tar.gz, 7z)
- Batch processing API
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/NewFeature) - Commit your changes (
git commit -m 'Add some NewFeature') - Push to the branch (
git push origin feature/NewFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Azure Functions
- Inspired by the need for better file handling in Azure Logic Apps
- Thanks to the Azure Functions team for the excellent Python support
- Issues: [GitHub Issues] (https://github.com/Gopikrish25/MakeZip/issues)
- Discussions: [GitHub Discussions] (https://github.com/Gopikrish25/MakeZip/discussions)
- Email: [gopi.sankagkrm@outlook.com] or [jamesfrancis1947@gmail.com]
If this project helped you, please consider giving it a star! β
Made with β€οΈ for the Azure community