- Configure ACR name: zdlas in azure-pipelines.yml - Add Azure Container Registry documentation and guides - Add scripts for ACR creation and image building - Add docker-compose config for ACR deployment - Remove temporary Excel lock file
311 lines
8.7 KiB
Markdown
311 lines
8.7 KiB
Markdown
# Azure DevOps Setup - Stap voor Stap Guide
|
|
|
|
Nu je code in Azure DevOps staat, volg deze stappen om Docker images automatisch te bouwen en naar Azure Container Registry te pushen.
|
|
|
|
## 📋 Stappenplan
|
|
|
|
### Stap 1: Azure Container Registry Aanmaken
|
|
|
|
Als je nog geen Azure Container Registry hebt:
|
|
|
|
**Optie A: Met Script (Aanbevolen) 🚀**
|
|
```bash
|
|
# Run het script (interactief)
|
|
./scripts/create-acr.sh
|
|
|
|
# Of met custom parameters:
|
|
./scripts/create-acr.sh rg-cmdb-gui zuyderlandcmdbacr westeurope Basic
|
|
```
|
|
|
|
Het script doet automatisch:
|
|
- ✅ Checkt of je ingelogd bent bij Azure
|
|
- ✅ Maakt resource group aan (als nodig)
|
|
- ✅ Controleert of ACR naam beschikbaar is
|
|
- ✅ Maakt ACR aan met Basic SKU
|
|
- ✅ Toont credentials
|
|
- ✅ Test Docker login
|
|
|
|
**Optie B: Via Azure CLI (Handmatig)**
|
|
```bash
|
|
# Login bij Azure
|
|
az login
|
|
|
|
# Resource group aanmaken (als nog niet bestaat)
|
|
az group create --name rg-cmdb-gui --location westeurope
|
|
|
|
# Container Registry aanmaken
|
|
az acr create \
|
|
--resource-group rg-cmdb-gui \
|
|
--name zuyderlandcmdbacr \
|
|
--sku Basic \
|
|
--admin-enabled true
|
|
```
|
|
|
|
**Optie C: Via Azure Portal**
|
|
1. Ga naar [Azure Portal](https://portal.azure.com)
|
|
2. Klik op **"Create a resource"**
|
|
3. Zoek naar **"Container Registry"**
|
|
4. Klik **"Create"**
|
|
5. Vul in:
|
|
- **Resource group**: Kies bestaande of maak nieuwe (bijv. `rg-cmdb-gui`)
|
|
- **Registry name**: Bijv. `zuyderlandcmdbacr` (moet uniek zijn, alleen kleine letters en cijfers)
|
|
- **Location**: `West Europe` (of gewenste regio)
|
|
- **SKU**: `Basic` (voor development/test) of `Standard` (voor productie)
|
|
6. Klik **"Review + create"** → **"Create"**
|
|
|
|
**Noteer je ACR naam!** Je hebt deze nodig in de volgende stappen.
|
|
|
|
**📚 Zie `docs/AZURE-ACR-QUICKSTART.md` voor een complete quick-start guide.**
|
|
|
|
---
|
|
|
|
### Stap 2: Service Connection Aanmaken in Azure DevOps
|
|
|
|
Deze connection geeft Azure DevOps toegang tot je Azure Container Registry.
|
|
|
|
1. **Ga naar je Azure DevOps project**
|
|
2. Klik op **⚙️ Project Settings** (onderaan links)
|
|
3. Ga naar **Service connections** (onder Pipelines)
|
|
4. Klik op **"New service connection"**
|
|
5. Kies **"Docker Registry"**
|
|
6. Kies **"Azure Container Registry"**
|
|
7. Vul in:
|
|
- **Azure subscription**: Selecteer je Azure subscription
|
|
- **Azure container registry**: Selecteer je ACR (bijv. `zuyderlandcmdbacr`)
|
|
- **Service connection name**: Bijv. `zuyderland-cmdb-acr-connection`
|
|
- **Description**: Optioneel
|
|
8. Klik **"Save"**
|
|
|
|
**✅ Noteer de service connection naam!** Je hebt deze nodig voor de pipeline.
|
|
|
|
---
|
|
|
|
### Stap 3: Pipeline Variabelen Aanpassen
|
|
|
|
Pas de `azure-pipelines.yml` aan naar jouw instellingen:
|
|
|
|
1. **Open** `azure-pipelines.yml` in je repository
|
|
2. **Pas de variabelen aan** (regel 15-20):
|
|
|
|
```yaml
|
|
variables:
|
|
# Pas deze aan naar jouw ACR naam
|
|
acrName: 'zuyderlandcmdbacr' # ← Jouw ACR naam hier
|
|
|
|
repositoryName: 'zuyderland-cmdb-gui'
|
|
|
|
# Pas deze aan naar de service connection naam die je net hebt gemaakt
|
|
dockerRegistryServiceConnection: 'zuyderland-cmdb-acr-connection' # ← Jouw service connection naam
|
|
|
|
imageTag: '$(Build.BuildId)'
|
|
```
|
|
|
|
3. **Commit en push** de wijzigingen:
|
|
```bash
|
|
git add azure-pipelines.yml
|
|
git commit -m "Configure Azure DevOps pipeline"
|
|
git push origin main
|
|
```
|
|
|
|
---
|
|
|
|
### Stap 4: Pipeline Aanmaken in Azure DevOps
|
|
|
|
1. **Ga naar je Azure DevOps project**
|
|
2. Klik op **Pipelines** (links in het menu)
|
|
3. Klik op **"New pipeline"** of **"Create Pipeline"**
|
|
4. Kies **"Azure Repos Git"** (of waar je code staat)
|
|
5. Selecteer je repository: **"Zuyderland CMDB GUI"** (of jouw repo naam)
|
|
6. Kies **"Existing Azure Pipelines YAML file"**
|
|
7. Selecteer:
|
|
- **Branch**: `main`
|
|
- **Path**: `/azure-pipelines.yml`
|
|
8. Klik **"Continue"**
|
|
9. **Review** de pipeline configuratie
|
|
10. Klik **"Run"** om de pipeline te starten
|
|
|
|
---
|
|
|
|
### Stap 5: Pipeline Uitvoeren
|
|
|
|
De pipeline start automatisch en zal:
|
|
|
|
1. ✅ Code uitchecken
|
|
2. ✅ Backend Docker image bouwen
|
|
3. ✅ Frontend Docker image bouwen
|
|
4. ✅ Images naar Azure Container Registry pushen
|
|
|
|
**Je kunt de voortgang volgen:**
|
|
- Klik op de running pipeline
|
|
- Bekijk de logs per stap
|
|
- Bij success zie je de image URLs
|
|
|
|
**Verwachte output:**
|
|
```
|
|
Backend Image: zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:123
|
|
Frontend Image: zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/frontend:123
|
|
```
|
|
|
|
---
|
|
|
|
### Stap 6: Images Verifiëren
|
|
|
|
**In Azure Portal:**
|
|
1. Ga naar je **Container Registry** (`zuyderlandcmdbacr`)
|
|
2. Klik op **"Repositories"**
|
|
3. Je zou moeten zien:
|
|
- `zuyderland-cmdb-gui/backend`
|
|
- `zuyderland-cmdb-gui/frontend`
|
|
4. Klik op een repository om de tags te zien (bijv. `latest`, `123`)
|
|
|
|
**Via Azure CLI:**
|
|
```bash
|
|
# Lijst repositories
|
|
az acr repository list --name zuyderlandcmdbacr
|
|
|
|
# Lijst tags voor backend
|
|
az acr repository show-tags --name zuyderlandcmdbacr --repository zuyderland-cmdb-gui/backend
|
|
|
|
# Lijst tags voor frontend
|
|
az acr repository show-tags --name zuyderlandcmdbacr --repository zuyderland-cmdb-gui/frontend
|
|
```
|
|
|
|
---
|
|
|
|
## 🚀 Automatische Triggers
|
|
|
|
De pipeline triggert automatisch bij:
|
|
|
|
1. **Push naar `main` branch** → Bouwt `latest` tag
|
|
2. **Git tags die beginnen met `v*`** → Bouwt versie tag (bijv. `v1.0.0`)
|
|
|
|
**Voorbeeld:**
|
|
```bash
|
|
# Tag aanmaken en pushen
|
|
git tag v1.0.0
|
|
git push origin v1.0.0
|
|
# → Pipeline triggert automatisch en bouwt versie 1.0.0
|
|
```
|
|
|
|
---
|
|
|
|
## 🔧 Troubleshooting
|
|
|
|
### Pipeline Fails: "Service connection not found"
|
|
|
|
**Oplossing:**
|
|
- Controleer of de service connection naam in `azure-pipelines.yml` overeenkomt met de naam in Azure DevOps
|
|
- Ga naar Project Settings → Service connections en verifieer de naam
|
|
|
|
### Pipeline Fails: "ACR not found"
|
|
|
|
**Oplossing:**
|
|
- Controleer of de `acrName` variabele correct is in `azure-pipelines.yml`
|
|
- Verifieer dat de ACR bestaat: `az acr list`
|
|
|
|
### Pipeline Fails: "Permission denied"
|
|
|
|
**Oplossing:**
|
|
- Controleer of de service connection de juiste permissions heeft
|
|
- Verifieer dat je Azure subscription toegang heeft tot de ACR
|
|
- Probeer de service connection opnieuw aan te maken
|
|
|
|
### Images worden niet gepusht
|
|
|
|
**Oplossing:**
|
|
- Check de pipeline logs voor specifieke errors
|
|
- Verifieer dat de Docker build succesvol is
|
|
- Controleer of de ACR admin-enabled is (voor development)
|
|
|
|
---
|
|
|
|
## 📦 Volgende Stappen: Deployment
|
|
|
|
Nu je images in Azure Container Registry staan, kun je ze deployen:
|
|
|
|
### Optie 1: Azure App Service
|
|
|
|
```bash
|
|
# Web App aanmaken en configureren
|
|
az webapp create --name cmdb-backend --resource-group rg-cmdb-gui --plan plan-cmdb-gui
|
|
az webapp config container set --name cmdb-backend --resource-group rg-cmdb-gui \
|
|
--docker-custom-image-name zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:latest \
|
|
--docker-registry-server-url https://zuyderlandcmdbacr.azurecr.io
|
|
```
|
|
|
|
### Optie 2: Docker Compose op VM
|
|
|
|
```bash
|
|
# Login bij ACR
|
|
az acr login --name zuyderlandcmdbacr
|
|
|
|
# Pull images
|
|
docker-compose -f docker-compose.prod.acr.yml pull
|
|
|
|
# Deploy
|
|
docker-compose -f docker-compose.prod.acr.yml up -d
|
|
```
|
|
|
|
### Optie 3: Azure Container Instances (ACI)
|
|
|
|
```bash
|
|
az container create \
|
|
--resource-group rg-cmdb-gui \
|
|
--name cmdb-backend \
|
|
--image zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:latest \
|
|
--registry-login-server zuyderlandcmdbacr.azurecr.io \
|
|
--registry-username <acr-username> \
|
|
--registry-password <acr-password>
|
|
```
|
|
|
|
---
|
|
|
|
## 📝 Checklist
|
|
|
|
- [ ] Azure Container Registry aangemaakt
|
|
- [ ] Service Connection geconfigureerd in Azure DevOps
|
|
- [ ] `azure-pipelines.yml` variabelen aangepast
|
|
- [ ] Pipeline aangemaakt en gerund
|
|
- [ ] Images succesvol gebouwd en gepusht
|
|
- [ ] Images geverifieerd in Azure Portal
|
|
- [ ] Automatische triggers getest (push naar main)
|
|
|
|
---
|
|
|
|
## 🎯 Quick Reference
|
|
|
|
**ACR Login:**
|
|
```bash
|
|
az acr login --name zuyderlandcmdbacr
|
|
```
|
|
|
|
**Images Lijsten:**
|
|
```bash
|
|
az acr repository list --name zuyderlandcmdbacr
|
|
az acr repository show-tags --name zuyderlandcmdbacr --repository zuyderland-cmdb-gui/backend
|
|
```
|
|
|
|
**Pipeline Handmatig Triggeren:**
|
|
- Ga naar Pipelines → Selecteer pipeline → "Run pipeline"
|
|
|
|
**Pipeline Logs Bekijken:**
|
|
- Ga naar Pipelines → Selecteer pipeline → Klik op de run → Bekijk logs per stap
|
|
|
|
---
|
|
|
|
## 📚 Meer Informatie
|
|
|
|
- [Azure Container Registry Docs](https://docs.microsoft.com/en-us/azure/container-registry/)
|
|
- [Azure DevOps Pipelines Docs](https://docs.microsoft.com/en-us/azure/devops/pipelines/)
|
|
- [Docker Task Reference](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/docker)
|
|
|
|
---
|
|
|
|
## 💡 Tips
|
|
|
|
1. **Gebruik versie tags voor productie**: Tag releases met `v1.0.0`, `v1.0.1`, etc.
|
|
2. **Monitor pipeline costs**: Azure DevOps geeft gratis build minuten per maand
|
|
3. **Enable retention policies**: Configureer ACR om oude images automatisch te verwijderen
|
|
4. **Use build caching**: Voor snellere builds bij volgende runs
|
|
5. **Set up notifications**: Configureer email/Slack notificaties voor pipeline status
|