SlideShare a Scribd company logo
https://mvc.tw
歡迎參加我們的每週四固定聚會
1
Azure DevOps Service
Pipeline設計與非正常應用
講者:Edward Kuo
https://mvc.tw
About Me
▪ Edward Kuo
▪ Microsoft Regional Director
▪ Microsoft Azure MVP
▪ Kingston IT Manager
▪ DevOps 研討會 講師
▪ 企業 DevOps 講師
▪ 微軟技術社群 講師
2
https://profile.edwardkuo.dev/
https://www.facebook.com/Edward
Kuo.Teched
我們就是用
Azure DevOps Service
3
https://mvc.tw
為什麼~
▪ 時間要花在創造(完成)商業價值(需求),降低整合異質平台的不便性
▪ 從需求、開發到發佈,採用同一個工作平台
▪ 技術的不斷推進、版本不斷更新,平台要能自動升級和擴充
▪ Server版還是會有維護成本,Service版則能降低平台維護成本
▪ Cloud DevOps Platform將會是一個趨勢
4
https://mvc.tw
Azure DevOps 版本
▪ Azure DevOps Server是基於SQL Server的地端產品
▪ Azure DevOps Service是基於Azure的SaaS級的雲端服務平台
▪ Service無法透過SSRS產生DevOps數據報表
▪ 兩者的迭代速度不同
5
https://mvc.tw
Architect On
Azure DevOps
Our Azure DevOps Ecosystem
6
https://mvc.tw
DevOps對應Azure DevOps服務應用
7
https://mvc.tw
我們的應用場景
▪ 80%系統是佈署在企業內部
▪ 20%系統是佈署在Azure
▪ 整體需要兼顧地與雲的混合應用模式,且還是→製造業
8
Azure DevOps 我們的生態架構
9
https://mvc.tw
DevOps進化-解耦系統
▪ 系統拆解
▪ 拆解系統讓內部耦合性能最小,增加重複使用與被測試的可能性
▪ 降低CI時間
▪ 系統程式碼越多,每次編譯需要的時間就會越長
▪ 元件化
▪ 在分散式開發與快速迭代下,避免影響他人且加速持續整合和釐清問題
10
https://mvc.tw
Artifacts Service
▪ Artifacts Service管理編譯組件
▪ 建立團隊/企業的Feed
▪ 第三方元件的.nupkg檔案
▪ CI/CD建立.nupkg、.NPM元件
▪ 避免使用過期元件
▪ 強制設定Package保留週期
11
https://mvc.tw
Agent Pool
Practice
Azure DevOps Agent Design
12
https://mvc.tw
Agent Pool
▪ Microsoft Agent Pool
▪ Azure Pipeline
▪ Hosted macOS
▪ Hosted Windows Container
▪ Custom Agent Pool
13
13
Custom Azure Pipeline
Microsoft托管代理
自托管代理
本地環境
https://mvc.tw
Agent & Azure DevOps Service 關係
14
Msg
Msg Msg Msg
Agent Pool
Pooling
Azure DevOps Queue
Msg
https://mvc.tw
Agent Pool & Agent 關係
▪ Agent Pool
▪ Agent
▪ Host
▪ Agent Pool可以匯集各種不同地的Agent
▪ 一個Host可以掛載多個Agent
▪ Pipeline能指定Pool,但不能指定運作的Agent
▪ Agents被啟動”基本”是隨機
15
https://mvc.tw
我們的Agent Pool
▪ 我們區分這些Agent Pool
▪ Azure Pipeline
▪ Private Cloud Build Pool
▪ Private Cloud Release Pool
▪ Private Premise Build Pool
▪ Private Premise Release Pool
▪ Private Premise Docker 1803 Pool
▪ Private Premise Docker 2004 Pool
16
https://mvc.tw
使用Custom Agent理由
▪ 省錢(只能免費用1800分鐘,現在要申請制)
▪ Microsoft Agent啟動速度有時太慢 (有時真的很難用)
▪ 加快Pull Code速度
▪ 加快Build Container速度(用過Microsoft Host Agent,會有想不
開的感覺)
▪ 避免.NET Core / .NET Framework更新問題,導致舊系統無法Build
▪ Release的環境在地端
17
https://mvc.tw
我們Agent配置與設計
▪ Build和Release Agent要分開不同Pool
▪ 地端Build和Release Agent的啟動服務帳號要不同
▪ 如果資源允許,Build和Release Agent最好能放在不同Host
▪ Build Container與Non-Build Container Agent Pool需要分開
▪ 雲端Build Agent Pool內的Agent最好設置在不同Region
18
https://mvc.tw
我們Agent配置與設計
▪ Build Container使用Private Premise的Build Agent
▪ 裝載Container Host版本不同,Build Agent也要放在對應的Host版本
▪ Release到Azure環境,使用Private Cloud Release Agent
▪ Release到On-Premise,使用Private Premise Release Agent
▪ 優先選擇Private Cloud Build Agent
19
https://mvc.tw
Agent特殊現象
▪ Agent的版本最好能自動更新
▪ 無法自動更新時,務必要定期手動離線更新Agent
▪ Build Agent不更新,會導致新版本.NET或是相關套件無法進行編譯
▪ 若發生Azure DevOps Service找不到Agent,很大機會是Agent版本
過舊
20
https://mvc.tw
Pipeline Design
Practice
我們的Pipeline設計
21
https://mvc.tw
你以為Pipeline很好設計嗎?
▪ 企業每個系統應用情境不同,Pipeline設計都不太可能相同
▪ 因為自動化的好處,人人都希望什麼都可以在Pipeline內做到
▪ 企業的場景與文化往往決定Pipeline設計複雜度
▪ 開發者總愛提出各種"創意",挑戰Pipeline設計
▪ 後面的講者都是挖這個坑的人
22
https://mvc.tw
Build Pipeline設計理念
▪ Pipeline不是建立後讓它會跑就好
▪ CI 僅處理Build & Unit Test Process
▪ CI 編譯時間能越短越好
▪ CI 設計盡量與Agent的Host相依性低
▪ CI 設計要能隨時可以切換Agent Pool
▪ 用Azure Library管理Application內變數或共用參數
23
https://mvc.tw
Release Pipeline設計理念
▪ Release僅處理應用程式佈署或是進行環境佈署
▪ 敏感性參數的安全性,用Azure Library管理
▪ 假使用一個PowerShell Script能完成,也要區分Task處理
24
https://mvc.tw
Pipeline Design Flow
25
Menu 手動執行模擬
Process 建立 Flow
Test 測試CI
Review 觀察執行時間
Pipeline Design Flow
26
https://mvc.tw
Build Pipeline Common Rule
▪ Library做DEV、UAT和PRD參數置換
▪ Build後的結果,必須上傳到Pipeline Artifacts
▪ Container
▪ 先Build Application,再Build Container
▪ 不同版本Host編譯的Container Image不能共用
▪ 不同Branch都要有Build Pipeline
27
https://mvc.tw
Build Pipeline
Task Flow
https://github.com/edwardku
o/AzureDevOpsPipelineSample
28
https://mvc.tw
Build .NET Core & Container
▪ 設計順序,Fist Agent
▪ .NET Core : 還原Package
▪ Replace Parameter : 更換
appsettings.json的設定參數
▪ SonarQube: Scan Code
▪ .NET Core : 編譯
▪ Publish Artifact :上傳編譯後
的檔案
29
https://mvc.tw
Build .NET Core & Container
▪ 設計順序,Second Agent
▪ Download build artifacts :
下載編譯檔案和Dockerfile
▪ Build Docker : 檔案Copy到
Container並編譯Docker
▪ Push Docker : Push Container
到ACR
30
https://mvc.tw
Build .NET Core & Container
▪ 分批建置Container Application
▪ Application Agent
▪ Docker Agent
▪ 不需要Container時,可以單獨發布
▪ 能單獨對編譯的Application除錯
▪ Container編譯一定要帶入版本號
31
https://mvc.tw
Build SQL Project
▪ 設計順序
▪ SQL Enlight Code Analysis : Scan SQL
▪ Publish Test Results : 上傳Test Result
▪ MS Build : 編譯
▪ Copy File : Copy .DACPAC到Artifact
▪ Publish Artifact :上傳編譯後的檔案
▪ 前提必須用SQL Project,對資料庫程式
進行版控
32
https://mvc.tw
Release Pipeline Common Rule
▪ 所有編譯的檔案,一律從Build
Artifact取得
▪ 正式環境部署皆需要人員Approve
▪ 非Container的系統佈署,大多用Copy
File方式處理
▪ 佈署用的參數存放在Library
▪ Release Agent不放在目的端的Host
▪ Docker Compose File用額外的Repos
管理
33
https://mvc.tw
Release Container
▪ 設計順序
▪ 從IaC Repos下載該Container的Compose.yml
▪ 置換Compose file的Docker版號
▪ docker-compose Pull : 下載 Container
▪ docker-compose Down : 停掉Container
▪ docker-compose Up : 啟動Container
▪ 從UAT到PRD,僅Container轉移Host,並用
不同IaC File啟動Container
34
https://mvc.tw
Release Container
▪ Release的Container必須要有版號,才能進行管理與快速復原
▪ $(Release.Artifacts.PipelineName.BuildNumber) 取得CI版本
▪ 置換Compose內的Image版本參數
▪ Compose的image版本號碼是用Buildnumber
35
https://mvc.tw
Release Windows Service
▪ 設計順序
▪ PowerShell : 停止WS在遠距Host
▪ Command Line : 卸載WS
▪ Copy File : 複製新的Application
▪ PowerShell : 安裝WS到遠距Host
▪ Command Line : 啟動WS
▪ 無專門Task,必須透過Command處理
36
https://mvc.tw
Release Database
▪ 設計順序
▪ Download Build Artifacts : 下載需要佈署DB相關的Script
▪ Deploy PowerShell Script
▪ SQL Publish XML File
▪ PowerShell : 執行佈署Script
▪ Delete files : 刪除佈署DB相關的Script
▪ Send email : 差異化檔案用Mail寄出
▪ Agent Host要安裝sqlpackage.exe
37
https://mvc.tw
Release Database
▪ 差異化比較用的參數,用DB.Publish.xml管理
▪ 執行差異化比較的Script,用PowerShell執行
38
https://mvc.tw
常用的Marketplace套件
▪ SQL Enlight Code Quality Task
▪ 掃描SQL語法是否有符合SQL撰寫規範
▪ SonarQube Task
▪ 整合SonarQube服務,進行Code掃描
▪ Trigger Build Task
▪ 現有Pipeline流程,驅動其他CI Pipeline流程
39
https://mvc.tw
常用的Marketplace套件
▪ Regex Replace Task
▪ Regular Expression替換掉Code資訊,如: AssemblyInfo.cs
▪ Replace Token Task
▪ 透過 #{變數名稱}#,將資訊注入到File,常搭配Azure DevOps Library使用
▪ Send Mail Task
▪ 發送信件通知,也可以在信件內夾帶附件
40
https://mvc.tw
官方未說的應用方式
使用模式僅參考,使用前要深思
41
https://mvc.tw
Schedule Controller
▪ 把Release當作系統 / 維運的定時排程器
▪ 不需要使用Windows Task Schedule
▪ 可以有很完整歷程記錄
▪ 可以設定執行排程的流程
▪ 用Azure DevOps Service,還可以透過雲端去手動啟動地端排程
42
https://mvc.tw
Backup All Repos File
▪ 基於ISO 27000的規範
▪ 需要將雲端Repos File 備份到地端的三個步驟
▪ PowerShell & Git 指令
▪ Azure DevOps API
▪ Release排程功能
▪ GitHub Code
43
https://mvc.tw
Trigger CI on Release Stage
▪ 當Package被Release後,必須自動驅動某系統的CI,讓系統立即取得
最新的Package版本使用
▪ 該系統在CI要在NuGet Package添加必須取得最新版本Package指令
44
Use NuGet Task
Command : Custom
Command and arguments:
update “Project.sln" -Id “NuGet Package Name" -ConfigFile
"nuget.config"
https://mvc.tw
Trigger CI on Release Stage
45
Build
Application
Component
Release
Package to
Artifacts
Trigger
Application
Build
Build
Application
Get New
Package
Release
Application
Release 2
Application
https://mvc.tw
Summary
46
https://mvc.tw
Our Challenge
▪ 你以為看到就是真的
▪ 不容易明白的錯誤訊息
▪ 介面與功能常常改變
▪ 不一定支援全部的開發語言,但.NET世界,99.8%都具備
▪ 有大量的Pipeline需要被管理
▪ Pipeline失敗不一定是Application問題
47
https://mvc.tw
Use YAML?
▪ 好處
▪ CI 用YAML讓有相同流程能快速建立Pipeline
▪ Pipeline能進入版控世界
▪ 支援CD,但功能尚不完善不建議使用
▪ 挑戰
▪ 語法需要熟悉,遇到第三方Task的YAML,不容易撰寫
▪ 入門門檻較高
48
https://mvc.tw
Azure DevOps CLI & API
▪ CLI
▪ 使用CLI可以擴展Azure DevOps,從命令行管理許多Azure DevOps服務
▪ API
▪ 透過REST API提供對服務的創建,檢索,更新或刪除
49
https://mvc.tw
Pipeline是該誰設計
▪ 企業很少有專屬設計(開發)Pipeline人員
▪ 流程相同盡量用Task Group取代
▪ Pipeline使用還需一些額外技能
▪ Command Line / PowerShell
▪ YAML
▪ SQL Command
50
https://mvc.tw
是DevOps工具
也是一個應用平台
https://github.com/edwardku
o/AzureDevOpsPipelineSample
51
Blog 是記錄知識的最佳平台
52
https://dotblogs.com.tw
53
SkillTree 為了確保內容與實務不會脫節,我們都是聘請企業顧問等級
並且目前依然在職場的業界講師,我們不把時間浪費在述說歷史與沿革,
我們並不是教您考取證照,而是教您如何上場殺敵,拳拳到肉的內容才
是您花錢想要聽到的,而這也剛好是我們擅長的。
https://skilltree.my
54
天瓏資訊圖書

More Related Content

PDF
twMVC#42 Windows容器導入由0到1
PDF
twMVC#36讓 Exceptionless 存管你的 Log
PDF
twMVC#33聊聊如何自建 Facebook {廣告} 服務 with API
PDF
twMVC#33玩轉 Azure 彈性部署
PPTX
twMVC#31網站上線了然後呢
PDF
twMVC#42 Azure IoT Hub for Smart Factory
PDF
twMVC#36.NetCore 3快速看一波
PPTX
twMVC#31沒有 hdd 的網站重構 webform to mvc
twMVC#42 Windows容器導入由0到1
twMVC#36讓 Exceptionless 存管你的 Log
twMVC#33聊聊如何自建 Facebook {廣告} 服務 with API
twMVC#33玩轉 Azure 彈性部署
twMVC#31網站上線了然後呢
twMVC#42 Azure IoT Hub for Smart Factory
twMVC#36.NetCore 3快速看一波
twMVC#31沒有 hdd 的網站重構 webform to mvc

What's hot (20)

PDF
twMVC#41 hololens2 MR
PDF
twMVC#23 | 快速上手 Azure Functions
PDF
twMVC#38 How we migrate tfs to git(using azure dev ops)
PDF
twMVC#32應用 ASP.NET WebAPI2 Odata 建置高互動性 APIS
PDF
twMVC#42 讓我們用一種方式來開發吧
PDF
twMVC#21 | 以實例說明ASP.NET Web API 服務的開發與測試過程
PDF
twMVC#43 Visual Studio 2022 新功能拆解
PPTX
twMVC#41 The journey of source generator
PDF
twMVC#29 | 當.Net Core 遇到AWS Lambda
PDF
twMVC#26 | Redis資料型別與場景的連結
PDF
twMVC#44 讓我們用 k6 來進行壓測吧
PDF
twMVC#28 | visual studio 2017 新功能介紹
PDF
twMVC#19 | opserver監控服務的解決
PDF
twMVC#21 | 你所不知道的 Visual Studio
PDF
twMVC#25 | ASP.NET MVC A/B Testing 的眉眉角角
PPTX
開發人員不可不知的 Windows Container 容器技術預覽
PDF
twMVC#23 | 一個Mobile App開發、維護與改版的愛恨之路
PPTX
快速上手 Windows Containers 容器技術 (Docker Taipei)
PDF
twMVC#30 | 你應該瞭解的 container-on-azure-二三事
PDF
動手打造 application framework-twMVC#15
twMVC#41 hololens2 MR
twMVC#23 | 快速上手 Azure Functions
twMVC#38 How we migrate tfs to git(using azure dev ops)
twMVC#32應用 ASP.NET WebAPI2 Odata 建置高互動性 APIS
twMVC#42 讓我們用一種方式來開發吧
twMVC#21 | 以實例說明ASP.NET Web API 服務的開發與測試過程
twMVC#43 Visual Studio 2022 新功能拆解
twMVC#41 The journey of source generator
twMVC#29 | 當.Net Core 遇到AWS Lambda
twMVC#26 | Redis資料型別與場景的連結
twMVC#44 讓我們用 k6 來進行壓測吧
twMVC#28 | visual studio 2017 新功能介紹
twMVC#19 | opserver監控服務的解決
twMVC#21 | 你所不知道的 Visual Studio
twMVC#25 | ASP.NET MVC A/B Testing 的眉眉角角
開發人員不可不知的 Windows Container 容器技術預覽
twMVC#23 | 一個Mobile App開發、維護與改版的愛恨之路
快速上手 Windows Containers 容器技術 (Docker Taipei)
twMVC#30 | 你應該瞭解的 container-on-azure-二三事
動手打造 application framework-twMVC#15
Ad

Similar to twMVC#42 Azure DevOps Service Pipeline設計與非正常應用 (20)

PPTX
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
PPTX
[2019 DevOpsDays Taipei]Azure DevOps 建立 DevOps 團隊
PDF
02 azure devops pipeline - build
PDF
01 DevOps and Azure DevOps overview
PDF
twMVC#50 微服務上線後的救贖
PDF
03 azure devops pipeline - release
PDF
災難演練 @ AWS 實戰分享 (Using AWS for Disaster Recovery)
PPTX
2024 Hello World Dev Conference 從觀察到實踐 打造符合公司需求的GitLab DevOps流水線
PDF
架構這件事 - Azure 可以幫助什麼 - 如何選擇使用什麼 Azure 服務
PDF
企業導入微服務實戰 - updated
PDF
.NET Conf 2024 :利用 Azure 實現平台工程,從概念到實踐,如何完成導入企業內部
PPTX
在B2B硬體產業運用 Agile 與 DevOps 的實務與心法
PDF
[DevOpsDays] 硬體產業的DevOps導入與實踐 - 以工控產業為例
PPTX
2024/11/29 DevOps Taiwan #64 : 從初建到進階:打造符合公司需求的混合雲端 GitLab DevOps 流水線
PDF
[2021 DevDays]Microsoft Teams 整合 Azure DevOps之實務應用
PPTX
DevOps的神鬼奇航
PPTX
Windows Azure Virtual Machine Services for Developers
PDF
twMVC#05 |開發與移轉 ASP.NET MVC 4.0 應用程式到 Windows Azure Platform
PDF
DevOps Tool Chain - Image Registry Troubleshooting and Best practices
PDF
企業導入微服務實戰 - updated
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
[2019 DevOpsDays Taipei]Azure DevOps 建立 DevOps 團隊
02 azure devops pipeline - build
01 DevOps and Azure DevOps overview
twMVC#50 微服務上線後的救贖
03 azure devops pipeline - release
災難演練 @ AWS 實戰分享 (Using AWS for Disaster Recovery)
2024 Hello World Dev Conference 從觀察到實踐 打造符合公司需求的GitLab DevOps流水線
架構這件事 - Azure 可以幫助什麼 - 如何選擇使用什麼 Azure 服務
企業導入微服務實戰 - updated
.NET Conf 2024 :利用 Azure 實現平台工程,從概念到實踐,如何完成導入企業內部
在B2B硬體產業運用 Agile 與 DevOps 的實務與心法
[DevOpsDays] 硬體產業的DevOps導入與實踐 - 以工控產業為例
2024/11/29 DevOps Taiwan #64 : 從初建到進階:打造符合公司需求的混合雲端 GitLab DevOps 流水線
[2021 DevDays]Microsoft Teams 整合 Azure DevOps之實務應用
DevOps的神鬼奇航
Windows Azure Virtual Machine Services for Developers
twMVC#05 |開發與移轉 ASP.NET MVC 4.0 應用程式到 Windows Azure Platform
DevOps Tool Chain - Image Registry Troubleshooting and Best practices
企業導入微服務實戰 - updated
Ad

More from twMVC (12)

PDF
twMVC#51 以平台工程重新思考系統設計 - 以 Batch System 為例封面
PDF
twMVC#51-GitHub Copilot 徹底改變開發模式,探索 AI 驅動的智慧程式碼協作
PDF
twMVC 47_Elastic APM 的兩三事
PDF
twMVC#46_SQL Server 資料分析大躍進 Machine Learning Services
PDF
.NET 7 家族新成員: Microsoft Orleans v7
PDF
twMVC#46 一探 C# 11 與 .NET 7 的神奇
PDF
twMVC#44 如何測試與保護你的 web application with playwright
PDF
twMVC#43 YARP
PDF
twMVC#43 C#10 新功能介紹
PDF
twMVC#36C#的美麗與哀愁
PDF
twMVC#30 | Bootstrap 搶先玩
PDF
twMvc#30 | 技術人員與業務團隊的無礙的溝通法則
twMVC#51 以平台工程重新思考系統設計 - 以 Batch System 為例封面
twMVC#51-GitHub Copilot 徹底改變開發模式,探索 AI 驅動的智慧程式碼協作
twMVC 47_Elastic APM 的兩三事
twMVC#46_SQL Server 資料分析大躍進 Machine Learning Services
.NET 7 家族新成員: Microsoft Orleans v7
twMVC#46 一探 C# 11 與 .NET 7 的神奇
twMVC#44 如何測試與保護你的 web application with playwright
twMVC#43 YARP
twMVC#43 C#10 新功能介紹
twMVC#36C#的美麗與哀愁
twMVC#30 | Bootstrap 搶先玩
twMvc#30 | 技術人員與業務團隊的無礙的溝通法則

twMVC#42 Azure DevOps Service Pipeline設計與非正常應用