azure - 从 azure CLI 获取租户名称
问题描述
我想THIS-THING-HERE.onmicrosoft.com
使用 Azure CLI 检索租户名称。我真的无法在文档中找到。
编辑:当我调用 azure account list 时,我没有在提供的域中获得用户名,因为我使用公司电子邮件登录:
[
{
"cloudName": "AzureCloud",
"id": "46ee2f65-7112-4c96-ad0a-3ff6ca22a615",
"isDefault": true,
"name": "Visual Studio Professional",
"state": "Enabled",
"tenantId": "1caf5d6b-58cb-40e6-88b3-eb9ab9c0c010",
"user": {
"name": "a.krajniak@avanade.com",
"type": "user"
}
},
{
"cloudName": "AzureCloud",
"id": "1efd84d6-173f-42cc-80db-7b2c17eb0edd",
"isDefault": false,
"name": "Microsoft Azure Enterprise",
"state": "Enabled",
"tenantId": "c48d02ad-7efd-4910-9b51-ebb7a4b75379",
"user": {
"name": "a.krajniak@avanade.com",
"type": "user"
}
}
]
解决方案
你可以使用这个命令:
az ad signed-in-user show --query 'userPrincipalName' | cut -d '@' -f 2 | sed 's/\"//'
这将占用用户 upn 并完成最后一部分
推荐阅读
- windows - 在 Windows 上将 linux 项目签出到工作区
- css - 在 Vue Bootstrap 中更改汉堡包图标颜色
- r - 冠状病毒包最新数据
- django - 反应和 django-rest-framework 的 CORS 问题
- ios - 如何更改表单中的 NavigationLink 箭头颜色
- python - tkinter Canvas 窗口未从 Powershell 打开
- ios - 如何在任何特殊字符之前添加额外的空格
- vue.js - 超过最大调用堆栈大小 Vuetify
- hystrix - org.springframework.cloud.netflix.hystrix.dashboard.HystrixDashboardConfiguration$ProxyStreamServlet.doGet - Spring Cloud Turbine Streams
- c# - mongodb-C# - 尝试读取流的末尾?