如何获取Azure AD tenant的tenant Id?

      通常状况下,Azure AD用户知道本身tenant域名,由于域名是帐户的后缀,例如:contoso.onMicrosoft.com。若是你还不了解什么是Azure AD tenant,能够参考 What is Azure AD tenant?。那么如何由tenant域名获得用户的tenant id呢?(注意这是tenant id而不是user id)这是在实际工做中常常遇到的问题,特别是在调用API和提供帮助服务,常常须要tenant id。 其实,Azure提供了Powershell (Restful API)和UI两种方式帮助你获取查找 tenant id。
 

Restful API或者Powershellshell

https://login.windows.net/[YOURDIRECTORYNAME].onmicrosoft.com/.well-known/openid-configuration。例如:https://login.windows.net/contoso.onmicrosoft.com/.well-known/openid-configuration 返回的信息中包含了contoso的tenant id。其实,直接访问上面的URL也能够获得tenant id,下面的Powershell在这里只是帮助你快速找到返回信息中的tenant id。windows

(Invoke-WebRequesthttps://login.windows.net/[YOURDIRECTORYNAME].onmicrosoft.com/.well-known/openid-configuration|ConvertFrom-Json).token_endpoint.Split('/')[3]api

 

Azure Portalapp

Azure Portal的Azure Active Directory扩展中也能够直接找到tenant id.运维

 

Azure China

        上面提供查询tenant id 方法是针对Azure全球云服务( https:// www.azure.com)。Azure China (https://www.azure.cn)则是部署在中国境内由世纪互联运维的、单独的Azure云服务,其不少操做与Azure全球云服务小有不一样,能够参见 中国区 Azure 应用程序开发说明。例如, 上面针对tenant id查询,其登录地址须要改成login.chinacloudapp.cn:
相关文章
相关标签/搜索