๐๏ธ Storage Binding Configuration Guide
Cloudflare Workers Storage Integration - Complete Setup Guide
This guide provides step-by-step instructions to configure storage bindings for all 10 workers, improving integration health from 70% to 100%.
๐ Table of Contents
๐ฏ Quick Start
โ๏ธ Configuration
๐ง Implementation & Testing
๐ Next Steps
๐ Storage Binding Overview
Current Status: 7/10 workers configured (70%)
Target Status: 10/10 workers configured (100%)
Missing Bindings: 3 critical workers
apex-api- Core API (3 bindings)apex-auth- Authentication (2 bindings)apexodds-vip- VIP Services (2 bindings)
๐ Quick Setup Commands
Step 1: Create Missing Storage Resources
# Create any missing KV namespaces
bun run cf kv create apex-api-cache
bun run cf kv create apex-sessions
bun run cf kv create apex-dashboard-cache
# Create any missing D1 databases
bun run cf d1 create apex-users
bun run cf d1 create apex-analytics
bun run cf d1 create apex-logs
bun run cf d1 create apex-messages
# Create any missing R2 buckets
bun run cf r2 create apex-blog-assets
bun run cf r2 create apex-packages
Step 2: Apply Generated Configurations
The previous tool generated complete wrangler.toml configurations. Apply them to each worker:
- Navigate to worker directory
- Copy appropriate configuration
- Update worker-specific paths
- Deploy with new bindings
โ๏ธ Worker-by-Worker Configuration
1. ๐ฅ apex-api (Priority: HIGH)
Service: Core API
Bindings Required: 3
# Navigate to apex-api worker directory
cd workers/apex-api # or appropriate path
# Copy configuration from generated output
# Update wrangler.toml with:
# - KV: API_CACHE โ apex-api-cache
# - KV: SESSIONS โ apex-sessions
# - D1: USERS_DB โ apex-users
# Deploy with new bindings
bun wrangler deploy
2. ๐ฅ apex-auth (Priority: HIGH)
Service: Authentication
Bindings Required: 2
# Navigate to apex-auth worker directory
cd workers/apex-auth # or appropriate path
# Update wrangler.toml with:
# - KV: AUTH_SESSIONS โ apex-sessions
# - D1: USERS_DB โ apex-users
# Deploy with new bindings
bun wrangler deploy
3. ๐ฅ apexodds-vip (Priority: HIGH)
Service: VIP Services
Bindings Required: 2
# Navigate to apexodds-vip worker directory
cd workers/apexodds-vip # or appropriate path
# Update wrangler.toml with:
# - D1: USERS_DB โ apex-users
# - D1: ANALYTICS_DB โ apex-analytics
# Deploy with new bindings
bun wrangler deploy
๐ Generated Configuration Templates
๐ง Template 1: KV + D1 Binding (apex-api)
name = "apex-api"
compatibility_date = "2024-01-15"
main = "src/index.js"
[[kv_namespaces]]
binding = "API_CACHE"
id = "apex-api-cache-id" # Replace with actual ID
[[kv_namespaces]]
binding = "SESSIONS"
id = "apex-sessions-id" # Replace with actual ID
[[d1_databases]]
binding = "USERS_DB"
database_name = "apex-users"
database_id = "apex-users-uuid" # Replace with actual ID
๐ง Template 2: Multi-Database Binding (apexodds-vip)
name = "apexodds-vip"
compatibility_date = "2024-01-15"
main = "src/index.js"
[[d1_databases]]
binding = "USERS_DB"
database_name = "apex-users"
database_id = "apex-users-uuid" # Replace with actual ID
[[d1_databases]]
binding = "ANALYTICS_DB"
database_name = "apex-analytics"
database_id = "apex-analytics-uuid" # Replace with actual ID
๐ง Template 3: R2 + KV Binding (apex-blog)
name = "apex-blog"
compatibility_date = "2024-01-15"
main = "src/index.js"
[[kv_namespaces]]
binding = "BLOG_CONTENT"
id = "apex-blog-content-id" # Replace with actual ID
[[r2_buckets]]
binding = "BLOG_ASSETS"
bucket_name = "apex-blog-assets"
โ๏ธ Configuration Steps
๐ Step 1: Get Resource IDs
# Get KV namespace IDs
bun run cf kv list
# Get D1 database IDs
bun run cf d1 list
# Get R2 bucket names
bun run cf r2 list
๐ Step 2: Update Worker Configurations
For each worker:
- Locate wrangler.toml file
- Add binding configuration
- Replace placeholder IDs with actual IDs
- Verify configuration syntax
๐ Step 3: Deploy Workers
# Test configuration first
bun wrangler deploy --dry-run
# Deploy with new bindings
bun wrangler deploy
# Verify deployment
bun wrangler tail # Check for errors
๐ Step 4: Verify Bindings
# Check integration health after each deployment
bun run cf scan
# Expected: Storage binding percentage should increase
๐ฏ Expected Improvements
๐ After Configuring All Storage Bindings:
Before:
- Storage Bindings: 70% (7/10 workers)
- Overall Integration: 63%
After:
- Storage Bindings: 100% (10/10 workers) โ
- Overall Integration: 85% โ
๐ Performance Benefits:
- Faster data access - Direct storage bindings
- Reduced latency - Eliminating API calls
- Better caching - Proper KV integration
- Enhanced security - Direct database connections
๐จ Troubleshooting
๐ Common Issues:
โ 1. Resource Not Found
# Create missing resource first
bun run cf kv create resource-name
โ 2. Permission Errors
# Check API permissions
bun tools/diagnostics/apex-diagnostics.ts permissions
โ 3. Binding Conflicts
# Remove conflicting bindings from wrangler.toml
# Deploy clean configuration
โ 4. Deployment Failures
# Check wrangler.toml syntax
bun wrangler deploy --dry-run
# View detailed errors
bun wrangler tail
โ Verification Commands
After configuration:
# Check overall integration health
bun run cf scan
# Verify specific worker bindings
bun wrangler dev --local # Test locally first
# Check storage binding status
bun run cf kv list
# Test worker functionality
curl https://apex-api.workers.dev/health
curl https://apexodds-vip.workers.dev/status
๐ Next Steps
๐ After Storage Binding Configuration:
- DNS Configuration: Complete manual DNS setup
- Integration Testing: Verify all services work together
- Monitoring Setup: Enable continuous health monitoring
- Performance Optimization: Monitor and optimize bindings
๐ Integration Health Goals
๐ฏ Target Metrics After Full Configuration:
- DNS Integration: 100% (9/9 services)
- Storage Bindings: 100% (10/10 workers)
- Overall Integration Health: 100% ๐ฏ
- Deployment Readiness: READY โ
๐ Support & Resources
๐ง Health Check: bun run cf scan
๐ Full Guide: bun run cf --help
๐จ Troubleshooting: Use integration health check for status updates
๐ Monitoring: Real-time binding status and performance metrics
๐
Last Updated: August 11, 2025
๐ฏ Target: 100% Storage Binding Integration
โ
Status: Ready for Implementation