203 lines
6.1 KiB
Markdown
203 lines
6.1 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) │◄────│ │
|
|
└─────────────────┘ └──────────────────────────┘
|
|
```
|
|
|
|
---
|
|
|
|
## 1. Container App erstellen (Azure Portal)
|
|
|
|
1. **Azure Portal öffnen**: https://portal.azure.com
|
|
2. **Suche**: "Container Apps" in der Suchleiste
|
|
3. **+ 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):
|
|
1. https://github.com/settings/tokens/new
|
|
2. Note: "Azure Container App - teams-browser-bot"
|
|
3. Expiration: 90 days (oder länger)
|
|
4. Scope: ✅ `read:packages`
|
|
5. **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_URL` Variable 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 |
|
|
|
|
4. **Review + create** → **Create**
|
|
|
|
---
|
|
|
|
## 2. Container App URL kopieren
|
|
|
|
Nach dem Deployment:
|
|
|
|
1. Gehe zu **Container Apps** → `teams-browser-bot`
|
|
2. Im **Overview** Tab findest du die **Application Url**
|
|
3. 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)
|
|
|
|
1. **Azure Portal** → **Microsoft Entra ID** (früher Azure AD)
|
|
2. **App registrations** → **+ New registration**
|
|
- Name: `github-teams-browser-bot`
|
|
- Supported account types: Single tenant
|
|
- **Register**
|
|
3. Notiere die **Application (client) ID** und **Directory (tenant) ID**
|
|
4. **Certificates & secrets** → **+ New client secret**
|
|
- Description: "GitHub Actions"
|
|
- Expires: 24 months
|
|
- **Add** → Kopiere den **Value** (nur jetzt sichtbar!)
|
|
|
|
### 3.2 Service Principal Berechtigung geben
|
|
|
|
1. Gehe zu **Resource groups** → `resource-core`
|
|
2. **Access control (IAM)** → **+ Add** → **Add role assignment**
|
|
3. Role: **Contributor**
|
|
4. Members: Select members → Suche `github-teams-browser-bot` → **Select**
|
|
5. **Review + assign**
|
|
|
|
### 3.3 GitHub Secrets konfigurieren
|
|
|
|
1. GitHub Repo → **Settings** → **Secrets and variables** → **Actions**
|
|
2. **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
|
|
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
|