AZURE : WINDOWS SELF HOSTED AGENT - From Your Laptop to Live Azure App Service
Self Hosted Agent Windows
From Your Laptop to Live Azure App Service
End-to-End Flow Visualization
[YOUR LAPTOP] → [AZURE DEVOPS] → [SELF-HOSTED AGENT] → [AZURE APP SERVICE] → [INTERNET USERS]
Phase 1: Code Creation on Your Laptop
Step 1.1: Local Development
On Your Laptop:
C:\Projects\propel-pro-2025\ ├── app.py ├── requirements.txt └── azure-pipelines.yml
What Happens:
You write Flask code in
app.pyon your Windows laptopYou define dependencies in
requirements.txtYou create the YAML pipeline configuration
Technical Details:
Your laptop has Python, Flask, and git installed
Code is stored locally in your file system
Phase 2: Code Commit & Push
Step 2.1: Git Operations
On Your Laptop:
git add . git commit -m "Update Flask API" git push origin master
What Happens:
Local Repository: Your code is committed to local git history
Push to Remote: Code is sent to Azure Repos in the cloud
Trigger Detection: Azure DevOps detects push to
masterbranch
Data Flow:
Your Laptop → Internet → Azure DevOps Servers
↓
Code files transferred via HTTPS/SSH
↓
Stored in Azure Repos Git repositoryPhase 3: Pipeline Trigger in Azure DevOps
Step 3.1: Automation Kick-off
In Azure DevOps Cloud:
trigger: - master # 👈 THIS LINE DETECTS THE PUSH
What Happens:
Webhook Trigger: Azure DevOps sees the push to
masterbranchQueue Build: Pipeline execution is queued
Agent Selection: Looks for available agent matching requirements
System Flow:
Azure Repos → Azure Pipelines Orchestrator
↓
"New code in master branch detected!"
↓
"Find agent that matches: name = FAITH"Phase 4: Self-Hosted Agent Execution
Step 4.1: Agent Assignment
Between Azure DevOps and Your Network:
pool: name: Default demands: agent.name -equals FAITH # 👈 TARGETS YOUR MACHINE
What Happens:
Agent Communication: Your self-hosted agent
FAITHregularly polls Azure DevOpsJob Assignment: "Hey FAITH, I have a pipeline job for you!"
Code Download: Agent downloads your repository code
Network Flow:
Azure DevOps Cloud → Internet → Your Corporate Network → Windows Machine "FAITH"
↓
Pipeline job instructions + your code files
↓
Stored in: D:\Agents\_work\1\s\ (or similar agent workspace)Step 4.2: File Verification on Your Windows Agent
- powershell: | Write-Host "Files to be deployed:" -ForegroundColor Cyan Get-ChildItem
What Happens on Your Windows Machine:
PowerShell Execution: Runs the script in agent workspace
Directory Listing: Shows all files that were downloaded
Visual Confirmation: You see in Azure DevOps logs:
Files to be deployed: app.py requirements.txt azure-pipelines.yml
Physical Location:
D:\Agents\_work\1\s\app.py D:\Agents\_work\1\s\requirements.txt D:\Agents\_work\1\s\azure-pipelines.yml
Step 4.3: ZIP Package Creation on Your Windows Agent
- task: ArchiveFiles@2 inputs: rootFolderOrFile: '$(System.DefaultWorkingDirectory)' archiveFile: '$(Build.ArtifactStagingDirectory)/app.zip'
What Happens on Your Windows Machine:
File Collection: Gathers all files from workspace directory
ZIP Creation: Uses Windows compression libraries
Output: Creates
app.zipin staging directory
File System Operations:
D:\Agents\_work\1\s\ D:\Agents\_work\1\a\
├── app.py └── app.zip (contains:)
├── requirements.txt ├── app.py
└── azure-pipelines.yml ├── requirements.txt
└── azure-pipelines.ymlStep 4.4: Artifact Storage
- task: PublishBuildArtifacts@1 inputs: PathtoPublish: '$(Build.ArtifactStagingDirectory)' ArtifactName: 'drop'
What Happens:
Upload Preparation: ZIP file read from local disk
Network Transfer: File uploaded to Azure DevOps cloud storage
Storage: Saved as build artifact for historical reference
Data Flow:
Your Windows Agent → Internet → Azure DevOps Artifact Storage
↓
app.zip uploaded and stored
↓
Available for download or rollbackPhase 5: Azure App Service Deployment
Step 5.1: Deployment Authentication
- task: AzureWebApp@1 inputs: azureSubscription: $(azureServiceConnection)
What Happens:
Authentication: Uses the service connection to get Azure access token
Authorization: Verifies permissions to deploy to the App Service
API Preparation: Sets up REST API calls to Azure
Security Flow:
Azure DevOps → Azure Active Directory
↓
Service Principal Authentication
↓
Access Token for App Service ManagementStep 5.2: ZIP Deployment to Azure
inputs: appName: $(webAppName) package: '$(Build.ArtifactStagingDirectory)/app.zip'
What Happens:
File Read: Reads
app.zipfrom local agent storageAPI Call: Makes HTTPS PUT request to Azure App Service deployment API
File Extraction: Azure automatically extracts ZIP to wwwroot
Deployment Flow:
Your Windows Agent → Internet → Azure App Service
↓
ZIP file transmitted via HTTPS
↓
Azure extracts to: D:\home\site\wwwroot\
↓
Files now available at:
D:\home\site\wwwroot\app.py
D:\home\site\wwwroot\requirements.txtPhase 6: Application Startup in Azure
Step 6.1: Python Environment Setup
In Azure App Service:
Python Detection: Azure sees
requirements.txtand Python filesDependency Installation: Automatically runs
pip install -r requirements.txtVirtual Environment: Creates isolated Python environment
Azure Internal Process:
D:\home\site\wwwroot\requirements.txt
↓
pip install Flask==2.3.3 gunicorn==21.2.0
↓
D:\home\site\wwwroot\env\Lib\site-packages\Step 6.2: Web Server Startup
In Azure App Service:
Process Startup: Azure starts Python process
Gunicorn Execution: Runs your Flask app via Gunicorn WSGI server
Port Binding: Listens on assigned HTTP port
Application Startup:
python.exe → gunicorn → app:app
↓
Listening on: http://0.0.0.0:80
↓
Ready to accept incoming requestsPhase 7: Success Notification & Live Application
Step 7.1: Final Status Update
- script: | echo "✅ Deployment successful!" echo "🌐 URL: https://$(webAppName).azurewebsites.net"
What Happens:
Script Execution: Runs on your Windows agent
Log Output: Messages appear in Azure DevOps pipeline logs
Completion: Pipeline marks as successful
User Visibility:
Azure DevOps Pipeline Logs: ✅ Deployment successful! 🌐 URL: https://webapp-flask-yaml-app-2025.azurewebsites.net
Step 7.2: Live Application Access
Internet Traffic Flow:
User's Browser → Internet → Azure Load Balancer → Your App Service → Python/Flask
↓
https://webapp-flask-yaml-app-2025.azurewebsites.net/
↓
Azure routes to your specific App Service instance
↓
Gunicorn handles request → Flask processes → JSON responseComplete Data Journey Summary
File Journey: app.py
Your Laptop (C:\)
→ Azure Repos (Git)
→ Your Windows Agent (D:\Agents\_work\1\s\)
→ ZIP Package (D:\Agents\_work\1\a\app.zip)
→ Azure App Service (D:\home\site\wwwroot\)
→ Internet Users (via HTTPS)Network Connections:
Your Laptop → Azure DevOps: Git push (HTTPS)
Azure DevOps → Your Agent: Job instructions + code (HTTPS)
Your Agent → Azure DevOps: Logs + artifacts (HTTPS)
Your Agent → Azure App Service: ZIP deployment (HTTPS)
Internet Users → Azure App Service: Web traffic (HTTPS)
Authentication Flow:
You → Azure DevOps: Personal access token or Azure AD
Azure DevOps → Azure: Service Principal (Service Connection)
App Service → Python: No authentication required (public web app)
Key Infrastructure Components
On Your Windows Machine (FAITH agent):
Azure DevOps Agent Service: Runs pipeline jobs
PowerShell: Executes scripts and commands
File System: Temporary workspace for build process
Network: Outbound internet access to Azure services
In Azure Cloud:
Azure DevOps: Pipeline orchestration, repository, artifact storage
Azure App Service: Web hosting, automatic Python environment
Azure Active Directory: Authentication and authorization
Azure Networking: Load balancing, DNS, SSL termination
Comments
Post a Comment