|
| 1 | +# Pipeline Examples for AZ-400 Training |
| 2 | + |
| 3 | +This directory contains verified YAML pipeline examples for teaching CI/CD concepts in the AZ-400 course. |
| 4 | + |
| 5 | +## 📁 Pipeline Files |
| 6 | + |
| 7 | +### 1. Single-Stage CI Pipeline (`single-stage-ci.yml`) |
| 8 | +**Purpose:** Basic continuous integration for Node.js applications |
| 9 | + |
| 10 | +**Key Features:** |
| 11 | +- Node.js setup and dependency installation |
| 12 | +- Linting and code quality checks |
| 13 | +- Unit testing with coverage |
| 14 | +- Artifact creation and publishing |
| 15 | +- Clear commenting for learning |
| 16 | + |
| 17 | +**Use Case:** Teaching CI fundamentals in Segment 2 |
| 18 | + |
| 19 | +### 2. Multi-Stage CI/CD Pipeline (`multi-stage-cicd.yml`) |
| 20 | +**Purpose:** Complete DevOps pipeline with multiple environments |
| 21 | + |
| 22 | +**Key Features:** |
| 23 | +- 5 stages: Build → Dev → Staging → Production → Post-Deploy |
| 24 | +- Environment approvals and gates |
| 25 | +- Blue-green deployment strategy |
| 26 | +- Automated rollback on failure |
| 27 | +- Performance and integration testing |
| 28 | +- Deployment slots and swapping |
| 29 | + |
| 30 | +**Use Case:** Advanced pipeline concepts in Segment 3 |
| 31 | + |
| 32 | +### 3. GitHub Actions Workflow (`../.github/workflows/node-azure-deploy.yml`) |
| 33 | +**Purpose:** GitHub-native CI/CD to Azure |
| 34 | + |
| 35 | +**Key Features:** |
| 36 | +- Matrix strategy for multiple Node versions |
| 37 | +- GitHub environments with protection rules |
| 38 | +- Azure Web App deployment |
| 39 | +- Release tagging |
| 40 | +- Security scanning with CodeQL |
| 41 | +- Reusable workflow patterns |
| 42 | + |
| 43 | +**Use Case:** Comparing Azure Pipelines vs GitHub Actions |
| 44 | + |
| 45 | +## 🚀 How to Use These Examples |
| 46 | + |
| 47 | +### For Azure Pipelines: |
| 48 | +1. Create a new pipeline in Azure DevOps |
| 49 | +2. Select "Existing Azure Pipelines YAML file" |
| 50 | +3. Choose the appropriate YAML file |
| 51 | +4. Update variables (service connections, resource names) |
| 52 | +5. Save and run |
| 53 | + |
| 54 | +### For GitHub Actions: |
| 55 | +1. Workflow is automatically detected in `.github/workflows/` |
| 56 | +2. Configure secrets in repository settings: |
| 57 | + - `AZURE_CREDENTIALS` - Service principal JSON |
| 58 | +3. Workflow triggers on push to main/master |
| 59 | + |
| 60 | +## 📝 Required Configuration |
| 61 | + |
| 62 | +### Azure Resources: |
| 63 | +```bash |
| 64 | +# Create resource group |
| 65 | +az group create --name rg-az400-demo --location eastus |
| 66 | + |
| 67 | +# Create App Service Plan |
| 68 | +az appservice plan create \ |
| 69 | + --name plan-az400-demo \ |
| 70 | + --resource-group rg-az400-demo \ |
| 71 | + --sku B1 \ |
| 72 | + --is-linux |
| 73 | + |
| 74 | +# Create Web Apps |
| 75 | +az webapp create \ |
| 76 | + --name webapp-az400-demo-dev \ |
| 77 | + --resource-group rg-az400-demo \ |
| 78 | + --plan plan-az400-demo \ |
| 79 | + --runtime "NODE:18-lts" |
| 80 | +``` |
| 81 | + |
| 82 | +### Service Connection (Azure DevOps): |
| 83 | +1. Project Settings → Service connections |
| 84 | +2. New service connection → Azure Resource Manager |
| 85 | +3. Service principal (automatic) |
| 86 | +4. Name: `AZ400-ServiceConnection` |
| 87 | + |
| 88 | +### GitHub Secrets: |
| 89 | +```bash |
| 90 | +# Create service principal |
| 91 | +az ad sp create-for-rbac \ |
| 92 | + --name "sp-az400-github" \ |
| 93 | + --role contributor \ |
| 94 | + --scopes /subscriptions/{subscription-id}/resourceGroups/rg-az400-demo \ |
| 95 | + --json-auth |
| 96 | +``` |
| 97 | + |
| 98 | +## 🎓 Teaching Points |
| 99 | + |
| 100 | +### Single-Stage Pipeline: |
| 101 | +- Pipeline triggers and paths |
| 102 | +- Agent pools and VM images |
| 103 | +- Variables and expressions |
| 104 | +- Task vs script steps |
| 105 | +- Artifact publishing |
| 106 | + |
| 107 | +### Multi-Stage Pipeline: |
| 108 | +- Stage dependencies |
| 109 | +- Deployment jobs vs regular jobs |
| 110 | +- Environment approvals |
| 111 | +- Deployment strategies |
| 112 | +- Failure handling |
| 113 | + |
| 114 | +### GitHub Actions: |
| 115 | +- Workflow syntax differences |
| 116 | +- Actions marketplace |
| 117 | +- Environments and secrets |
| 118 | +- Reusable workflows |
| 119 | +- GitHub-specific features |
| 120 | + |
| 121 | +## 🔧 Customization |
| 122 | + |
| 123 | +Students can modify these pipelines to: |
| 124 | +- Add additional testing frameworks |
| 125 | +- Implement different deployment strategies |
| 126 | +- Add notifications (Teams, Slack) |
| 127 | +- Include infrastructure as code |
| 128 | +- Add security scanning tools |
| 129 | + |
| 130 | +## 📚 Additional Resources |
| 131 | + |
| 132 | +- [Azure Pipelines YAML schema](https://learn.microsoft.com/azure/devops/pipelines/yaml-schema) |
| 133 | +- [GitHub Actions documentation](https://docs.github.com/actions) |
| 134 | +- [Azure Web Apps deployment](https://learn.microsoft.com/azure/app-service/deploy-github-actions) |
0 commit comments