service-teams-browser-bot/AZURE_SETUP.md
ValueOn AG 363c9df08e docs: Update AZURE_SETUP.md with final ACR configuration
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-15 00:05:34 +01:00

163 lines
4.8 KiB
Markdown

# Azure Setup für Teams Browser Bot
## Architektur
Der Browser Bot ist ein **zentraler Service** der von allen Gateway-Instanzen (dev, int, prod) genutzt wird.
Jede Gateway-Instanz sendet ihre eigene WebSocket-URL mit dem Join-Request, sodass der Bot
sich immer zur richtigen Gateway-Instanz zurückverbindet.
```
┌─────────────────┐ ┌──────────────────────────┐
│ Gateway PROD │────►│ │
│ (gateway.xyz) │◄────│ Teams Browser Bot │
├─────────────────┤ │ (zentraler Service) │
│ Gateway INT │────►│ │
│ (gateway-int..) │◄────│ resource-core │
├─────────────────┤ │ │
│ Gateway DEV │────►│ │
│ (localhost) │◄────│ │
└─────────────────┘ └──────────────────────────┘
```
## Aktuelle Konfiguration
| Ressource | Wert |
|-----------|------|
| Container App URL | `https://cae-poweron-shared.redwater-53d21339.switzerlandnorth.azurecontainerapps.io` |
| Azure Container Registry | `acrpoweron.azurecr.io` |
| Image | `acrpoweron.azurecr.io/teams-browser-bot:latest` |
| Health Check | `/health` |
---
## 1. Voraussetzungen
### 1.1 Azure Container Registry (ACR)
Eine ACR muss existieren. Falls nicht:
1. Azure Portal → Suche "Container registries" → **+ Create**
2. Name: `acrpoweron`, SKU: Basic, Location: Switzerland North
3. Nach Erstellung: **Access keys****Admin user** aktivieren
### 1.2 GitHub Secrets für CI/CD
Im GitHub Repo `valueonag/service-teams-browser-bot`:
**Settings****Secrets and variables****Actions**:
| Secret Name | Wert |
|-------------|------|
| `ACR_LOGIN_SERVER` | `acrpoweron.azurecr.io` |
| `ACR_USERNAME` | `acrpoweron` |
| `ACR_PASSWORD` | Password aus ACR Access keys |
---
## 2. Container App erstellen (Azure Portal)
1. **Azure Portal** → Suche "Container Apps" → **+ Create**
### Basics Tab
| Feld | Wert |
|------|------|
| Subscription | Subscription Product |
| Resource group | resource-core |
| Container app name | `teams-browser-bot` |
| Region | Switzerland North |
| Container Apps Environment | **Create new** → Name: `cae-poweron-shared` |
### Container Tab
| Feld | Wert |
|------|------|
| Use quickstart image | ❌ Deaktivieren |
| Registry | `acrpoweron` (Azure Container Registry) |
| Image | `teams-browser-bot` |
| Image tag | `latest` |
| Authentication type | Managed identity |
| CPU and memory | 2 CPU cores, 4 Gi memory |
### Environment Variables
| Name | Value |
|------|-------|
| NODE_ENV | production |
| PORT | 4100 |
| BOT_NAME | PowerOn AI |
| BOT_HEADLESS | true |
| LOG_LEVEL | info |
> ⚠️ **Wichtig:** KEINE `GATEWAY_WS_URL` Variable setzen! Die URL kommt dynamisch vom Gateway.
### Ingress Tab
| Feld | Wert |
|------|------|
| Ingress | ✅ Enabled |
| Ingress traffic | Accepting traffic from anywhere |
| Target port | 4100 |
2. **Review + create****Create**
---
## 3. Gateway Konfiguration
Die Gateway env-Files sind bereits konfiguriert:
**env_prod.env & env_int.env:**
```
TEAMSBOT_BROWSER_BOT_URL=https://cae-poweron-shared.redwater-53d21339.switzerlandnorth.azurecontainerapps.io
```
**env_dev.env (lokal):**
```
TEAMSBOT_BROWSER_BOT_URL=http://localhost:4100
```
---
## 4. CI/CD Pipeline
Der GitHub Actions Workflow (`build-deploy.yml`) pusht automatisch zu ACR bei jedem Push auf `main`.
**Manuelles Update der Container App:**
1. Azure Portal → Container Apps → `teams-browser-bot`
2. **Revisions and replicas****Create new revision**
3. Das neue Image wird automatisch gepullt
---
## 5. Kosten
Azure Container Apps (Consumption Plan):
- **vCPU**: ~$0.000024/vCPU-second
- **Memory**: ~$0.000003/GiB-second
- **Requests**: Erste 2M/Monat kostenlos
- **Scale to zero**: Keine Kosten wenn idle
Geschätzte Kosten bei 10h Bot-Nutzung/Tag:
- ~$15-25/Monat
---
## 6. Troubleshooting (Azure Portal)
### Logs anzeigen
1. Container Apps → teams-browser-bot
2. **Monitoring****Log stream** (Live-Logs)
3. Oder: **Monitoring****Logs** (historisch)
### Container startet nicht
1. **Revisions and replicas** → Klicke auf aktive Revision
2. **Console logs** prüfen
3. Häufige Probleme:
- Image nicht gefunden → Registry credentials prüfen
- Port falsch → Target port = 4100
### Revision neu starten
1. **Revisions and replicas**
2. Aktive Revision → **...** → **Restart**
### WebSocket Probleme
- Container Apps unterstützen WebSockets standardmässig
- Gateway CORS-Einstellungen prüfen