如何显示Azure的UserID?

时间:2019-03-27 06:53:48

标签: azure azure-api-management

我想尝试以下API。

用户-获取共享访问令牌(API管理) https://docs.microsoft.com/en-us/rest/api/apimanagement/user/getsharedaccesstoken

但是我找不到我的用户ID。它可能是24个字符的字符串。 我该怎么证明?

2 个答案:

答案 0 :(得分:2)

您可以通过powershell或rest api获取userId

1。使用powershell:Get-AzApiManagementUser

$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName "<ResourceGroupName >" -ServiceName "<API Management service name>"
Get-AzApiManagementUser -Context $ApiMgmtContext

该命令将列出所有用户,找到所需的用户,结果就是UserId

enter image description here

2。使用rest api:User - List By Service

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users?api-version=2018-06-01-preview

结果中的name是您想要的。

enter image description here

答案 1 :(得分:1)

您可以使用Resource Explorer来查找用户ID。

订阅->您的订阅-> resourceGroups->您的资源组->提供程序-> Microsoft.ApiManagement->服务->您的ApiManagement服务->用户

enter image description here

名称标签是您的用户ID,1是默认的管理员用户ID。