File size: 7,290 Bytes
a75037d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# SAP Finance Dashboard - Azure Container Apps Deployment Guide
## Prerequisites
1. **Azure CLI** - Install from: https://aka.ms/installazurecliwindows
2. **Azure Subscription** - Active Azure account
3. **Git** (optional) - For code updates
## Quick Deploy Steps
### Option 1: Automated Deployment Script
Open PowerShell as Administrator and run:
```powershell
cd "c:\Users\amlal\Downloads\VSCode-SAP-AI-Copilot-Projects2025\SAP-RPT-1-OSS-App"
.\deploy-azure.ps1
```
The script will:
- โ
Create Azure Resource Group
- โ
Create Azure Container Registry
- โ
Build Docker image in Azure (no local Docker needed)
- โ
Create Container Apps Environment
- โ
Deploy your application
- โ
Provide public URL
**Deployment Time:** ~10-15 minutes
### Option 2: Manual Deployment (Step-by-Step)
If the automated script doesn't work, follow these manual commands:
#### 1. Login to Azure
```bash
az login
```
#### 2. Set Variables
```bash
set RESOURCE_GROUP=rg-sap-finance-dashboard
set LOCATION=eastus
set ACR_NAME=acrsapfinance%RANDOM%
set ENVIRONMENT_NAME=env-sap-finance
set APP_NAME=sap-finance-dashboard
```
#### 3. Create Resource Group
```bash
az group create --name %RESOURCE_GROUP% --location %LOCATION%
```
#### 4. Create Container Registry
```bash
az acr create --resource-group %RESOURCE_GROUP% --name %ACR_NAME% --sku Basic --admin-enabled true
```
#### 5. Build Docker Image (Using Azure - No local Docker needed)
```bash
az acr build --registry %ACR_NAME% --image sap-finance-dashboard:latest .
```
#### 6. Create Container Apps Environment
```bash
az containerapp env create --name %ENVIRONMENT_NAME% --resource-group %RESOURCE_GROUP% --location %LOCATION%
```
#### 7. Deploy Container App
```bash
az containerapp create ^
--name %APP_NAME% ^
--resource-group %RESOURCE_GROUP% ^
--environment %ENVIRONMENT_NAME% ^
--image %ACR_NAME%.azurecr.io/sap-finance-dashboard:latest ^
--registry-server %ACR_NAME%.azurecr.io ^
--target-port 7862 ^
--ingress external ^
--cpu 2 ^
--memory 4Gi ^
--min-replicas 1 ^
--max-replicas 3
```
#### 8. Get Application URL
```bash
az containerapp show --name %APP_NAME% --resource-group %RESOURCE_GROUP% --query properties.configuration.ingress.fqdn -o tsv
```
## Post-Deployment Configuration
### Add Hugging Face Token (Required for AI Features)
1. Go to Azure Portal: https://portal.azure.com
2. Navigate to your Container App
3. Go to **Settings** > **Secrets**
4. Add secret:
- Name: `huggingface-token`
- Value: Your Hugging Face token (get from https://huggingface.co/settings/tokens)
5. Go to **Settings** > **Containers** > **Environment variables**
6. Add environment variable:
- Name: `HUGGINGFACE_TOKEN`
- Source: Reference a secret
- Value: Select `huggingface-token`
7. Click **Save** and wait for app to restart
### Optional: Add SAP OData Credentials
If connecting to SAP systems:
- `SAP_ODATA_BASE_URL`: Your SAP OData endpoint
- `SAP_USERNAME`: SAP username (as secret)
- `SAP_PASSWORD`: SAP password (as secret)
## Application Architecture
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Azure Container Apps โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ SAP Finance Dashboard โ โ
โ โ - Gradio Web Interface โ โ
โ โ - RPT-1-OSS AI Model โ โ
โ โ - Port 7862 โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Azure Container Registry โ โ
โ โ - Docker Image Storage โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
## Application Features
Once deployed, you'll have access to:
1. **๐ Dashboard** - Financial metrics and visualizations
2. **๐ Data Explorer** - Browse datasets
3. **๐ค Upload** - Upload custom CSV files
4. **๐ค AI Predictions** - SAP-RPT-1-OSS powered predictions
5. **๐ OData** - Connect to SAP systems
6. **๐ฎ Playground** - Custom model training
## Scaling Configuration
The default configuration:
- **Min Replicas:** 1 (always running)
- **Max Replicas:** 3 (auto-scale under load)
- **CPU:** 2 cores
- **Memory:** 4 GB
To adjust scaling:
```bash
az containerapp update ^
--name %APP_NAME% ^
--resource-group %RESOURCE_GROUP% ^
--min-replicas 1 ^
--max-replicas 5 ^
--cpu 4 ^
--memory 8Gi
```
## Cost Optimization
**Estimated Monthly Cost (East US):**
- Container Apps (1 replica, 2 vCPU, 4GB): ~$60/month
- Container Registry (Basic): ~$5/month
- **Total:** ~$65/month
**To reduce costs:**
1. Set min-replicas to 0 (app sleeps when not in use)
2. Use smaller CPU/memory allocation
3. Delete when not needed:
```bash
az group delete --name %RESOURCE_GROUP% --yes
```
## Monitoring & Logs
### View Live Logs
```bash
az containerapp logs show --name %APP_NAME% --resource-group %RESOURCE_GROUP% --follow
```
### View Metrics (Azure Portal)
1. Go to your Container App
2. Click **Monitoring** > **Metrics**
3. View:
- CPU usage
- Memory usage
- Request count
- Response time
## Updating Your Application
When you make code changes:
```bash
# Build new image
az acr build --registry %ACR_NAME% --image sap-finance-dashboard:latest .
# Update container app
az containerapp update ^
--name %APP_NAME% ^
--resource-group %RESOURCE_GROUP% ^
--image %ACR_NAME%.azurecr.io/sap-finance-dashboard:latest
```
## Troubleshooting
### App not starting?
Check logs:
```bash
az containerapp logs show --name %APP_NAME% --resource-group %RESOURCE_GROUP% --tail 100
```
### Out of memory?
Increase memory allocation:
```bash
az containerapp update --name %APP_NAME% --resource-group %RESOURCE_GROUP% --memory 8Gi
```
### Port issues?
Verify port is set to 7862:
```bash
az containerapp show --name %APP_NAME% --resource-group %RESOURCE_GROUP% --query properties.configuration.ingress
```
### Can't access URL?
Check ingress is enabled:
```bash
az containerapp ingress show --name %APP_NAME% --resource-group %RESOURCE_GROUP%
```
## Security Best Practices
1. **Use Managed Identity** for Azure service connections
2. **Store secrets** in Azure Key Vault
3. **Enable HTTPS only** (default enabled)
4. **Restrict ingress** to specific IPs if needed
5. **Rotate tokens** regularly
## Support
- **Azure Container Apps Docs:** https://learn.microsoft.com/azure/container-apps/
- **SAP-RPT-1-OSS:** https://github.com/SAP-samples/sap-rpt-1-oss
- **Gradio Docs:** https://gradio.app/docs
## Clean Up
To delete all resources and stop charges:
```bash
az group delete --name %RESOURCE_GROUP% --yes --no-wait
```
---
**Ready to deploy?** Run the automated script or follow the manual steps above! ๐
|