6.1 KiB
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) │◄────│ │
└─────────────────┘ └──────────────────────────┘
1. Container App erstellen (Azure Portal)
- Azure Portal öffnen: https://portal.azure.com
- Suche: "Container Apps" in der Suchleiste
- + Create klicken
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, Zone redundancy: Disabled → Create |
Container Tab
Zuerst GitHub PAT erstellen (brauchst du gleich):
- https://github.com/settings/tokens/new
- Note: "Azure Container App - teams-browser-bot"
- Expiration: 90 days (oder länger)
- Scope: ✅
read:packages - Generate token → Kopieren und sicher aufbewahren
Dann im Azure Portal:
| Feld | Wert |
|---|---|
| Registry | Other registry |
| Authentication type | Basic |
| Registry login server | ghcr.io |
| Username | valueonag |
| Password | Dein GitHub PAT von oben |
| Image | valueonag/service-teams-browser-bot |
| Image tag | latest |
Container Resources (weiter unten)
| Feld | Wert |
|---|---|
| CPU cores | 2 |
| Memory (Gi) | 4 |
Environment Variables
| Name | Value |
|---|---|
| NODE_ENV | production |
| PORT | 4100 |
| BOT_NAME | PowerOn AI |
| BOT_HEADLESS | true |
| LOG_LEVEL | info |
| SCREENSHOT_ON_ERROR | true |
⚠️ Wichtig: KEINE
GATEWAY_WS_URLVariable setzen! Die URL kommt dynamisch vom Gateway.
Ingress Tab
| Feld | Wert |
|---|---|
| Ingress | ✅ Enabled |
| Ingress traffic | Accepting traffic from anywhere |
| Ingress type | HTTP |
| Target port | 4100 |
Scale Tab
| Feld | Wert |
|---|---|
| Min replicas | 0 |
| Max replicas | 3 |
- Review + create → Create
2. Container App URL kopieren
Nach dem Deployment:
- Gehe zu Container Apps →
teams-browser-bot - Im Overview Tab findest du die Application Url
- Kopiere die URL, z.B.:
https://teams-browser-bot.niceocean-12345678.switzerlandnorth.azurecontainerapps.io
3. GitHub Actions für Auto-Deployment (Optional)
3.1 Service Principal erstellen (Azure Portal)
- Azure Portal → Microsoft Entra ID (früher Azure AD)
- App registrations → + New registration
- Name:
github-teams-browser-bot - Supported account types: Single tenant
- Register
- Name:
- Notiere die Application (client) ID und Directory (tenant) ID
- Certificates & secrets → + New client secret
- Description: "GitHub Actions"
- Expires: 24 months
- Add → Kopiere den Value (nur jetzt sichtbar!)
3.2 Service Principal Berechtigung geben
- Gehe zu Resource groups →
resource-core - Access control (IAM) → + Add → Add role assignment
- Role: Contributor
- Members: Select members → Suche
github-teams-browser-bot→ Select - Review + assign
3.3 GitHub Secrets konfigurieren
- GitHub Repo → Settings → Secrets and variables → Actions
- New repository secret für jedes:
| Secret Name | Wert |
|---|---|
| AZURE_CLIENT_ID | Application (client) ID |
| AZURE_TENANT_ID | Directory (tenant) ID |
| AZURE_CLIENT_SECRET | Client secret value |
| AZURE_SUBSCRIPTION_ID | Subscription ID* |
| AZURE_RESOURCE_GROUP | resource-core |
| AZURE_CONTAINER_APP_NAME | teams-browser-bot |
*Subscription ID findest du unter: Subscriptions → Subscription Product → Subscription ID
4. Gateway Konfiguration
In jeder Gateway-Instanz die gleiche Bot URL konfigurieren:
env_prod.env:
TEAMSBOT_BROWSER_BOT_URL=https://teams-browser-bot.<xyz>.switzerlandnorth.azurecontainerapps.io
env_int.env:
TEAMSBOT_BROWSER_BOT_URL=https://teams-browser-bot.<xyz>.switzerlandnorth.azurecontainerapps.io
env_dev.env (lokal):
TEAMSBOT_BROWSER_BOT_URL=http://localhost:4100
Ersetze <xyz> mit dem tatsächlichen Wert aus Schritt 3.
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
- Container Apps → teams-browser-bot
- Monitoring → Log stream (Live-Logs)
- Oder: Monitoring → Logs (historisch)
Container startet nicht
- Revisions and replicas → Klicke auf aktive Revision
- Console logs prüfen
- Häufige Probleme:
- Image nicht gefunden → Registry credentials prüfen
- Port falsch → Target port = 4100
Revision neu starten
- Revisions and replicas
- Aktive Revision → ... → Restart
WebSocket Probleme
- Container Apps unterstützen WebSockets standardmässig
- Gateway CORS-Einstellungen prüfen