# Fix: MSI Authentication Error in Azure Pipeline ## 🔴 Error Message ``` Could not fetch access token for Managed Service Principal. Please configure Managed Service Identity (MSI) for virtual machine ``` ## 🎯 Quick Fix De service connection gebruikt Managed Service Identity (MSI), wat niet werkt met Azure DevOps Services (cloud). **Oplossing: Herconfigureer de service connection met Service Principal authenticatie.** --- ## ✅ Stap-voor-Stap Oplossing ### Stap 1: Verwijder Bestaande Service Connection 1. Ga naar **Azure DevOps** 2. **Project Settings** (onderaan links) → **Service connections** 3. Zoek: `zuyderland-cmdb-acr-connection` 4. Klik op **...** (three dots menu) → **Delete** 5. Bevestig verwijdering ### Stap 2: Maak Nieuwe Service Connection 1. **Project Settings** → **Service connections** → **New service connection** 2. Kies **"Docker Registry"** 3. Kies **"Azure Container Registry"** 4. **⚠️ BELANGRIJK**: Zorg dat **"Service Principal"** is geselecteerd als Authentication type - **NIET** "Managed Identity" of "Workload Identity federation" - **WEL** "Service Principal" (standaard optie) 5. Vul in: - **Azure subscription**: Selecteer je subscription - **Azure container registry**: Selecteer `zdlasacr` uit de dropdown - **Service connection name**: `zuyderland-cmdb-acr-connection` - **Description**: Optioneel 6. Klik **"Save"** (of **"Verify and save"**) ### Stap 3: Test Pipeline 1. Ga naar **Pipelines** → Je pipeline 2. Klik **"Run pipeline"** 3. De pipeline zou nu moeten werken! --- ## 🔧 Alternatief: Gebruik "Others" Optie Als de Azure Container Registry optie nog steeds problemen geeft: ### Stap 1: Verwijder Bestaande Service Connection (Zelfde als hierboven) ### Stap 2: Maak Service Connection met "Others" 1. **Project Settings** → **Service connections** → **New service connection** 2. Kies **"Docker Registry"** 3. Kies **"Others"** (in plaats van "Azure Container Registry") 4. Vul handmatig in: - **Docker Registry**: `zdlasacr.azurecr.io` - **Docker ID**: (ACR admin username) - **Docker Password**: (ACR admin password) - **Service connection name**: `zuyderland-cmdb-acr-connection` ### Stap 3: Haal ACR Admin Credentials Op ```bash # Login bij Azure az login # Haal admin credentials op az acr credential show --name zdlasacr ``` **Output:** ```json { "username": "zdlasacr", "passwords": [ { "name": "password", "value": "xxxxxxxxxxxxx" ← Gebruik deze } ] } ``` **Gebruik:** - **Docker ID**: `zdlasacr` (of de username uit output) - **Docker Password**: `passwords[0].value` uit output ### Stap 4: Save en Test 1. Klik **"Save"** 2. Test de pipeline opnieuw --- ## 🔍 Waarom Gebeurt Dit? **Managed Service Identity (MSI)** werkt alleen met: - ✅ Azure DevOps Server (on-premises) met Managed Identity - ❌ **NIET** met Azure DevOps Services (cloud) - Dit is jouw situatie! **Service Principal** werkt met: - ✅ Azure DevOps Services (cloud) - **Dit is wat je nodig hebt!** - ✅ Azure DevOps Server (on-premises) - ✅ Alle Azure services --- ## ✅ Verificatie Na het herconfigureren, controleer: 1. **Service Connection Details:** - Ga naar **Service connections** → `zuyderland-cmdb-acr-connection` - Check dat **Authentication type** = **"Service Principal"** (niet MSI) 2. **Test Pipeline:** - Run de pipeline opnieuw - De Docker build stap zou nu moeten werken --- ## 📚 Gerelateerde Documentatie - **`AZURE-SERVICE-CONNECTION-TROUBLESHOOTING.md`** - Algemene troubleshooting - **`AZURE-SERVICE-CONNECTION-AUTH.md`** - Authentication types uitleg - **`AZURE-DEVOPS-SETUP.md`** - Service connection setup guide --- ## 🆘 Nog Steeds Problemen? Als het nog steeds niet werkt: 1. **Check ACR bestaat:** ```bash az acr show --name zdlasacr ``` 2. **Check ACR admin is enabled:** ```bash az acr show --name zdlasacr --query adminEnabled ``` Moet `true` zijn. Als `false`, enable het: ```bash az acr update --name zdlasacr --admin-enabled true ``` 3. **Check subscription toegang:** - Ga naar Azure Portal → Subscription → Access control (IAM) - Check of je account toegang heeft 4. **Gebruik "Others" optie** als laatste redmiddel (werkt altijd) --- **💡 Tip**: Service Principal is de aanbevolen methode voor Azure DevOps Services. Het is veilig, betrouwbaar en wordt automatisch beheerd door Azure DevOps.