如何显示 Azure 的 UserID?

How can I show UserID of Azure?

我想尝试以下API。

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

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

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

1.Use 电源外壳:Get-AzApiManagementUser

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

该命令会列出所有用户,找到你想要的,结果中的UserId就是那个。

2.Use 休息 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就是你想要的

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

订阅 -> 你的订阅 -> 资源组 -> 你的资源组 -> 提供商 -> Microsoft.ApiManagement -> 服务 -> 你的 ApiManagement 服务 -> 用户

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