架构概览
重要:Teable 需要 S3-compatible 存储。你可以选择:
- AWS S3(跨云方案)
- MinIO(在 Azure VM/AKS 自建)
- 其他 S3-compatible 服务
Azure Blob Storage 不直接支持,因为它使用不同的 API。
前置要求
- 已安装并登录 Azure CLI
- Azure 订阅具备 App Service、PostgreSQL、Redis 权限
- 具备 S3-compatible 存储访问权(例如 AWS S3 账号或 MinIO 部署)
步骤 1:创建 Azure 资源
1.1 创建资源组
az group create \
--name teable-rg \
--location eastus
1.2 创建 PostgreSQL Flexible Server
az postgres flexible-server create \
--resource-group teable-rg \
--name teable-db \
--location eastus \
--admin-user teableadmin \
--admin-password '<你的强密码>' \
--sku-name Standard_B2s \
--tier Burstable \
--storage-size 128 \
--version 16 \
--public-access 0.0.0.0-255.255.255.255
等待预配完成。获取连接字符串:az postgres flexible-server show \
--resource-group teable-rg \
--name teable-db \
--query "fullyQualifiedDomainName" --output tsv
结果:teable-db.postgres.database.azure.com
1.3 创建 Azure Cache for Redis
az redis create \
--resource-group teable-rg \
--name teable-cache \
--location eastus \
--sku Basic \
--vm-size c0 \
--minimum-tls-version 1.2
获取访问密钥:az redis list-keys \
--resource-group teable-rg \
--name teable-cache \
--query "primaryKey" --output tsv
步骤 2:设置 S3-compatible 存储
由于 Azure Blob Storage 不兼容 S3,请选择以下方案之一:
方案 A:使用 AWS S3(跨云)
如果你已有 AWS 访问权或不想管理 MinIO,这是最简单的方案。
-
在 AWS 上创建 S3 bucket(参见 AWS 部署指引 步骤 1.3-1.4)
- Public bucket:
teable-public-<唯一后缀>
- Private bucket:
teable-private-<唯一后缀>
-
配置 public bucket(参见 对象存储指引):
- 启用 public read 访问
- 配置 CORS 允许任意跨域
你将使用这些环境变量:
BACKEND_STORAGE_PROVIDER=s3
BACKEND_STORAGE_S3_REGION=us-west-2
BACKEND_STORAGE_S3_ENDPOINT=https://s3.us-west-2.amazonaws.com
BACKEND_STORAGE_S3_ACCESS_KEY=<aws-access-key>
BACKEND_STORAGE_S3_SECRET_KEY=<aws-secret-key>
BACKEND_STORAGE_PUBLIC_BUCKET=teable-public-<后缀>
BACKEND_STORAGE_PRIVATE_BUCKET=teable-private-<后缀>
STORAGE_PREFIX=https://teable-public-<后缀>.s3.us-west-2.amazonaws.com
方案 B:在 Azure 上部署 MinIO
如果希望所有资源都在 Azure,可部署 MinIO 作为 S3-compatible 网关。
快速设置(Azure VM):
- 创建 VM 并安装 MinIO:
wget https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio
sudo mv minio /usr/local/bin/
# 启动 MinIO
export MINIO_ROOT_USER=admin
export MINIO_ROOT_PASSWORD=<强密码>
minio server /data --console-address ":9001"
- 通过 MinIO 控制台(端口 9001)或 CLI 创建 bucket:
mc alias set myminio http://your-vm-ip:9000 admin <密码>
mc mb myminio/public
mc mb myminio/private
mc policy set download myminio/public
你将使用这些环境变量:
BACKEND_STORAGE_PROVIDER=minio
BACKEND_STORAGE_MINIO_ENDPOINT=<vm-ip-或域名>
BACKEND_STORAGE_MINIO_PORT=443
BACKEND_STORAGE_MINIO_USE_SSL=true
BACKEND_STORAGE_MINIO_ACCESS_KEY=admin
BACKEND_STORAGE_MINIO_SECRET_KEY=<密码>
BACKEND_STORAGE_PUBLIC_BUCKET=public
BACKEND_STORAGE_PRIVATE_BUCKET=private
STORAGE_PREFIX=https://<vm-ip-或域名>
步骤 3:准备环境变量
创建文件 app-settings.txt,包含所有必需变量:
# Core
PUBLIC_ORIGIN=https://teable-app.azurewebsites.net
SECRET_KEY=<生成32位随机字符串>
# Database
PRISMA_DATABASE_URL=postgresql://teableadmin:<密码>@teable-db.postgres.database.azure.com:5432/postgres?sslmode=require
# Redis(队列依赖)
BACKEND_CACHE_PROVIDER=redis
BACKEND_CACHE_REDIS_URI=rediss://:<redis-key>@teable-cache.redis.cache.windows.net:6380/0
# 性能缓存(可选;可指向同一个 Redis)
BACKEND_PERFORMANCE_CACHE=rediss://:<redis-key>@teable-cache.redis.cache.windows.net:6380/0
# Storage(S3-compatible)
# 方案 A(AWS S3):
BACKEND_STORAGE_PROVIDER=s3
BACKEND_STORAGE_S3_REGION=us-west-2
BACKEND_STORAGE_S3_ENDPOINT=https://s3.us-west-2.amazonaws.com
BACKEND_STORAGE_S3_ACCESS_KEY=<aws-access-key>
BACKEND_STORAGE_S3_SECRET_KEY=<aws-secret-key>
BACKEND_STORAGE_PUBLIC_BUCKET=teable-public-<后缀>
BACKEND_STORAGE_PRIVATE_BUCKET=teable-private-<后缀>
STORAGE_PREFIX=https://teable-public-<后缀>.s3.us-west-2.amazonaws.com
# 方案 B(MinIO):
# BACKEND_STORAGE_PROVIDER=minio
# BACKEND_STORAGE_MINIO_ENDPOINT=<vm-ip>
# BACKEND_STORAGE_MINIO_PORT=443
# BACKEND_STORAGE_MINIO_USE_SSL=true
# BACKEND_STORAGE_MINIO_ACCESS_KEY=admin
# BACKEND_STORAGE_MINIO_SECRET_KEY=<密码>
# BACKEND_STORAGE_PUBLIC_BUCKET=public
# BACKEND_STORAGE_PRIVATE_BUCKET=private
# STORAGE_PREFIX=https://<vm-ip>
步骤 4:部署到 Azure App Service
4.1 创建 App Service Plan
az appservice plan create \
--resource-group teable-rg \
--name teable-plan \
--location eastus \
--is-linux \
--sku P1v3
4.2 创建 Web App(容器方式)
az webapp create \
--resource-group teable-rg \
--plan teable-plan \
--name teable-app \
--deployment-container-image-name ghcr.io/teableio/teable:latest
4.3 配置容器设置
az webapp config container set \
--resource-group teable-rg \
--name teable-app \
--docker-custom-image-name ghcr.io/teableio/teable:latest \
--docker-registry-server-url https://ghcr.io
4.4 设置环境变量
# 将 app-settings.txt 转为 JSON 格式并应用
az webapp config appsettings set \
--resource-group teable-rg \
--name teable-app \
--settings \
WEBSITES_PORT=3000 \
PUBLIC_ORIGIN="https://teable-app.azurewebsites.net" \
SECRET_KEY="<你的secret>" \
PRISMA_DATABASE_URL="postgresql://..." \
BACKEND_CACHE_PROVIDER="redis" \
BACKEND_CACHE_REDIS_URI="rediss://..." \
BACKEND_PERFORMANCE_CACHE="rediss://..." \
BACKEND_STORAGE_PROVIDER="s3" \
BACKEND_STORAGE_S3_REGION="us-west-2" \
BACKEND_STORAGE_S3_ENDPOINT="https://s3.us-west-2.amazonaws.com" \
BACKEND_STORAGE_S3_ACCESS_KEY="***" \
BACKEND_STORAGE_S3_SECRET_KEY="***" \
BACKEND_STORAGE_PUBLIC_BUCKET="teable-public-xxx" \
BACKEND_STORAGE_PRIVATE_BUCKET="teable-private-xxx" \
STORAGE_PREFIX="https://teable-public-xxx.s3.us-west-2.amazonaws.com"
4.5 配置健康检查
az webapp config set \
--resource-group teable-rg \
--name teable-app \
--generic-configurations '{"healthCheckPath": "/health"}'
4.6 重启应用
az webapp restart \
--resource-group teable-rg \
--name teable-app
步骤 5:验证部署
- 检查应用状态:
az webapp show \
--resource-group teable-rg \
--name teable-app \
--query "state" --output tsv
预期:Running
- 查看日志:
az webapp log tail \
--resource-group teable-rg \
--name teable-app
- 测试健康检查:
curl https://teable-app.azurewebsites.net/health
预期返回:
- 浏览器访问 Teable:
https://teable-app.azurewebsites.net
故障排查
数据库连接错误
- 验证 PostgreSQL 防火墙允许 Azure 服务
- 检查连接字符串包含
?sslmode=require
- 确保数据库名称正确(默认是
postgres,不是 teable)
Redis 连接错误
- 使用
rediss://(双’s’)进行 TLS 连接
- 使用端口 6380(不是 6379)连接 Azure Cache for Redis
- 验证访问密钥正确
S3 访问错误(方案 A:AWS S3)
- 验证 AWS 凭据正确
- 检查 bucket 名称完全匹配
- 确保 public bucket 已配置 public read 策略与 CORS
- 测试 S3 从 Azure 的访问:
curl https://s3.us-west-2.amazonaws.com 应该可用
容器启动失败
- 检查日志:
az webapp log tail ...
- 验证所有必需环境变量已设置
- 确保
WEBSITES_PORT=3000 已设置
生产环境建议
-
高可用:
- App Service 横向扩展到 2+ 实例
- 启用 PostgreSQL zone redundancy
- 使用 Standard 或 Premium Redis tier 及副本
-
网络:
- 使用 VNet Integration 限制数据库/redis 仅允许 App Service 访问
- 移除 PostgreSQL 公共访问(
--public-access None)
-
安全:
- 使用 Azure Key Vault 存储敏感值(而非明文应用设置)
- 启用仅 HTTPS:
az webapp update --https-only true
- 使用托管标识访问 Azure 资源
-
监控:
- 为 App Service 启用 Application Insights
- 设置应用失败、高 CPU/内存、数据库连接错误的告警
-
备份:
- 启用 PostgreSQL 自动备份(默认 7 天保留)
- 为 S3 private bucket 启用版本控制
-
自定义域名:
# 添加自定义域名
az webapp config hostname add \
--resource-group teable-rg \
--webapp-name teable-app \
--hostname teable.yourcompany.com
# 创建托管 SSL 证书
az webapp config ssl create \
--resource-group teable-rg \
--name teable-app \
--hostname teable.yourcompany.com
相关文档
Last modified on December 23, 2025