Skip to content

Commit 6fb81f8

Browse files
committed
Adds Azure Table Storage for persistent event storage
Enables indefinite event retention beyond memory Provides quick setup and full docs Maintains graceful fallback if not configured
1 parent 1a02363 commit 6fb81f8

File tree

12 files changed

+1952
-24
lines changed

12 files changed

+1952
-24
lines changed

AZURE_STORAGE_QUICK_SETUP.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Quick Setup: Azure Table Storage
2+
3+
Follow these steps to enable persistent webhook event storage.
4+
5+
## Prerequisites
6+
7+
- Azure subscription with access to `tps-app-scripting-rg` resource group
8+
- Azure CLI installed (optional, for CLI method)
9+
10+
## Step 1: Create Storage Account
11+
12+
### Option A: Azure Portal (5 minutes)
13+
14+
1. Navigate to [Azure Portal](https://portal.azure.com)
15+
2. Go to **Resource Groups**`tps-app-scripting-rg`
16+
3. Click **+ Create** → Search for "Storage account" → **Create**
17+
4. Fill in the form:
18+
- **Storage account name:** `tpsappscriptingstorage` (must be globally unique, lowercase, no hyphens)
19+
- **Region:** Same as your App Service (e.g., North Europe)
20+
- **Performance:** Standard
21+
- **Redundancy:** LRS (Locally Redundant Storage)
22+
- Leave other settings as default
23+
5. Click **Review + Create****Create**
24+
6. Wait ~1 minute for deployment
25+
26+
### Option B: Azure CLI (2 minutes)
27+
28+
```bash
29+
az storage account create \
30+
--name tpsappscriptingstorage \
31+
--resource-group tps-app-scripting-rg \
32+
--location northeurope \
33+
--sku Standard_LRS \
34+
--kind StorageV2
35+
```
36+
37+
## Step 2: Get Connection String
38+
39+
### Option A: Azure Portal
40+
41+
1. Go to the storage account → **Access keys** (left menu)
42+
2. Click **Show keys**
43+
3. Copy the **Connection string** from key1 or key2
44+
4. Should look like:
45+
```
46+
DefaultEndpointsProtocol=https;AccountName=tpsappscriptingstorage;AccountKey=xxxxxxxxxxxxx;EndpointSuffix=core.windows.net
47+
```
48+
49+
### Option B: Azure CLI
50+
51+
```bash
52+
az storage account show-connection-string \
53+
--name tpsappscriptingstorage \
54+
--resource-group tps-app-scripting-rg \
55+
--output tsv
56+
```
57+
58+
## Step 3: Configure App Service
59+
60+
### Option A: Azure Portal
61+
62+
1. Go to **App Service**`tps-app-scripting-editor`
63+
2. Click **Configuration** (left menu under Settings)
64+
3. Under **Application settings**, click **+ New application setting**
65+
4. Add:
66+
- **Name:** `AZURE_STORAGE_CONNECTION_STRING`
67+
- **Value:** (paste the connection string from Step 2)
68+
5. Click **OK**
69+
6. Click **Save** at the top
70+
7. Click **Continue** to confirm restart
71+
8. Wait ~30 seconds for restart
72+
73+
### Option B: Azure CLI
74+
75+
```bash
76+
# Get connection string
77+
CONNECTION_STRING=$(az storage account show-connection-string \
78+
--name tpsappscriptingstorage \
79+
--resource-group tps-app-scripting-rg \
80+
--output tsv)
81+
82+
# Set App Service configuration
83+
az webapp config appsettings set \
84+
--name tps-app-scripting-editor \
85+
--resource-group tps-app-scripting-rg \
86+
--settings AZURE_STORAGE_CONNECTION_STRING="$CONNECTION_STRING"
87+
88+
# Restart
89+
az webapp restart \
90+
--name tps-app-scripting-editor \
91+
--resource-group tps-app-scripting-rg
92+
```
93+
94+
## Step 4: Verify
95+
96+
1. Check App Service logs:
97+
```bash
98+
az webapp log tail \
99+
--name tps-app-scripting-editor \
100+
--resource-group tps-app-scripting-rg
101+
```
102+
103+
2. Look for this line:
104+
```
105+
✅ Azure Table Storage initialized: WebhookEvents
106+
```
107+
108+
3. Send a test webhook event and verify it appears in:
109+
- `GET https://app-scripting-editor.trackmangolfdev.com/api/webhook/<path>/events`
110+
- Response should include `"storageEnabled": true`
111+
112+
## Optional: Local Development
113+
114+
Add to your local `server/.env` file:
115+
116+
```bash
117+
AZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=https;AccountName=tpsappscriptingstorage;AccountKey=...;EndpointSuffix=core.windows.net
118+
```
119+
120+
This will use the same storage account as production. Consider adding `_dev` suffix to webhook paths to avoid collisions.
121+
122+
## Costs
123+
124+
Expected cost: **< $1/month** for typical usage
125+
126+
- Storage: ~$0.045/GB/month
127+
- Transactions: ~$0.00036/10,000 operations
128+
- 10,000 events/month ≈ $0.004/month
129+
- 1 million events/month ≈ $0.085/month
130+
131+
## Troubleshooting
132+
133+
**"Storage account name already exists"**
134+
→ Use a different name (e.g., `tpsappscriptingstorage2`, `tpswebhookstorage`)
135+
136+
**Storage not working after configuration**
137+
→ Check App Service logs for errors
138+
→ Verify connection string format (no extra spaces/newlines)
139+
→ Ensure App Service restarted after configuration change
140+
141+
**Events still not persisting**
142+
→ Check if `AZURE_STORAGE_CONNECTION_STRING` appears in App Service Configuration
143+
→ Try restarting the App Service manually
144+
→ Check Azure Storage Account firewall settings (should allow App Service)
145+
146+
## Full Documentation
147+
148+
See [`AZURE_TABLE_STORAGE_SETUP.md`](./AZURE_TABLE_STORAGE_SETUP.md) for:
149+
- Architecture details
150+
- API documentation
151+
- Advanced configuration (Managed Identity, retention, backup)
152+
- Monitoring and metrics
153+
- Security best practices

0 commit comments

Comments
 (0)