[英]How to get the pipeline Id of the current release in azure devops extension api
[英]How to get the tenant id with the azure-devops-extension-api and azure-devops-extension-sdk?
我有一個小問題。 我正在嘗試獲取 tanant id。 我嘗試使用下面的代碼,但只能獲取項目 ID。
import * as SDK from "azure-devops-extension-sdk";
import { CommonServiceIds, IProjectPageService } from "azure-devops-extension-api";
const projectService = await SDK.getService<IProjectPageService>(CommonServiceIds.ProjectPageService);
const project = await projectService.getProject();
有任何想法嗎?
您可以在以下關於身份的 DevOps API 呼叫響應的域屬性中找到tenant ID
:
GET https://vssps.dev.azure.com/{organization}/_apis/identities?searchFilter=General&filterValue=<Azure AD username>&queryMembership=None&api-version=7.0
我嘗試通過 Postman 在我的環境中重現相同的結果,結果如下
要創建新的個人訪問令牌 (PAT),您可以在 DevOps 門戶中找到以下步驟:
我為我的 DevOps 組織生成了一個具有完全訪問權限的PAT token
,如下所示:
當我在 Postman 中運行以下包含 PAT 令牌的查詢時,我成功獲得了tenant ID
響應,如下所示:
GET vssps.dev.azure.com/{organization}/_apis/identities?searchFilter=General&filterValue=<Azure AD user UPN>&queryMembership=None&api-version=7.0
回復:
為了確認這一點,我在 Azure DevOps 門戶中進行了檢查,並獲得了相同的租戶 ID,如下所示:
參考: IdentitySelf 接口 | 微軟
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.