使用 Azure CLI 快速新增使用者到 Azure DevOps 組織並授予專案權限
source link: https://blog.miniasp.com/post/2021/07/13/Azure-DevOps-CLI-Add-User-and-Project-Security-Group
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
最近公司正在急速的成長,經常需要新增 Azure DevOps Services 使用者帳號並設定專案權限,我今天特別將這些步驟全部寫成指令碼,之後直接複製貼上就可以單鍵完成設定。
安裝 Azure CLI 並安裝 Azure DevOps Services 擴充命令
-
安裝 Azure CLI 工具
choco install azure-cli -y
-
登入 Azure
az login
-
安裝 Azure DevOps Services 擴充命令
az extension add --name azure-devops
-
設定組織預設值
az devops configure --defaults organization=https://dev.azure.com/YourOrgName
新增使用者到 Azure DevOps Services 組織
新增到使用者,最主要有兩個設定:
常見的 AccountLicenseType
只有四種:
我們假設
$UserPrincipalName
是 PowerShell 變數,並指向類似[email protected]
的電子郵件地址。
-
Stakeholder
az devops user add --email-id $UserPrincipalName --license-type "stakeholder"
-
Basic
az devops user add --email-id $UserPrincipalName --license-type "express"
-
Basic + Test Plans
az devops user add --email-id $UserPrincipalName --license-type "advanced"
-
Visual Studio subscriber
az devops user add --email-id $UserPrincipalName --license-type "none"
新增使用者到特定專案下的特定群組
-
首先,我們要先確定你要把使用者加入到哪個專案
$AzDO_Project = "TDCC_Futures"
-
取得 Azure DevOps Services 特定專案的群組清單
# 取得 Azure DevOps Services 特定專案的群組清單 $AzDO_Groups = $(az devops security group list -p $AzDO_Project -o json | ConvertFrom-Json)
-
將成員加入 Contributors 群組
$AzDO_GroupName = "Contributors" $AzDO_GroupId = ($AzDO_Groups.graphGroups | Where-Object "displayName" -in "$AzDO_GroupName").descriptor az devops security group membership add --group-id $AzDO_GroupId --member-id $UserPrincipalName
如果要加入專案管理員群組,可以改成:
$AzDO_GroupName = "Project Administrators" $AzDO_GroupId = ($AzDO_Groups.graphGroups | Where-Object "displayName" -in "$AzDO_GroupName").descriptor az devops security group membership add --group-id $AzDO_GroupId --member-id $UserPrincipalName
目前預設的專案群組有:
- Contributors
- Project Administrators
- Build Administrators
- Project Valid Users
- Readers
- Release Administrators
- TeamName Team
-
列出使用者目前擁有權限的專案清單
$AzDO_Projects = $(az devops user show --user $UserPrincipalName -o json | ConvertFrom-Json) $AzDO_Projects.projectEntitlements | ForEach-Object -Process { # $_.projectRef.id $_.projectRef.name }
- 使用 Azure CLI 管理 Azure DevOps Services 服務
Azure DevOps Services 提供相當完整的 CLI 命令列介面支援,早期你可以使用 VSTS CLI 來操作 Azure DevOps Services 與 Team Foundati
- 使用 Azure CLI 快速新增使用者到 Azure DevOps 組織並授予專案權限
最近公司正在急速的成長,經常需要新增 Azure DevOps Services 使用者帳號並設定專案權限,我今天特別將這些步驟全部寫成指令碼,之後直接複製貼上就可以單鍵完成設定。 安裝 Azure
- 如何建立與刪除 Azure DevOps 上面的 Project Wiki 文件庫
在 Azure DevOps Service 上面的 Wiki 有兩種類型,一種是隨著專案一起建立的 Project Wiki 文件庫,另一種是隨著 Git Repo 特定分支的 Code Wiki
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK