你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

New-AzApiManagementUserToken

为用户生成共享访问令牌。

语法

New-AzApiManagementUserToken
   -Context <PsApiManagementContext>
   -UserId <String>
   [-KeyType <PsApiManagementUserKeyType>]
   [-Expiry <DateTime>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

说明

cmdlet New-AzApiManagementUserToken 为指定的用户生成共享访问令牌

示例

示例 1:为 Git 用户生成共享访问令牌

$context = New-AzApiManagementContext -ResourceGroupName powershelltest -ServiceName powershellsdkservice
$gitAccess=Get-AzApiManagementTenantAccess -Context $context
New-AzApiManagementUserToken -Context $context -UserId $gitAccess.Id

UserId      TokenExpiry         KeyType UserToken
------      -----------         ------- ---------
integration 5/3/2019 2:02:34 PM Primary integration&201905031402&zOwopJChWAA6oaqGHMyf7Ol9wUCPcrtdmBmff8c2lcmZk9Y...

此脚本获取 ApiManagement 服务中配置的 Git 用户,并使用有效期为 8 小时的主密钥生成共享访问令牌。

示例 2

为用户生成共享访问令牌。 (自动生成)

New-AzApiManagementUserToken -Context <PsApiManagementContext> -Expiry <DateTime> -UserId <String>

参数

-Context

PsApiManagementContext 的实例。 此参数是必需的。

类型:PsApiManagementContext
Position:Named
默认值:None
必需:True
Accept pipeline input:True
Accept wildcard characters:False

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

类型:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
默认值:None
必需:False
Accept pipeline input:False
Accept wildcard characters:False

-Expiry

令牌的到期时间。 如果未指定,则会创建令牌,以在 8 小时后过期。 此参数是可选的。

类型:Nullable<T>[DateTime]
Position:Named
默认值:None
必需:False
Accept pipeline input:True
Accept wildcard characters:False

-KeyType

生成令牌时要使用的用户密钥。 此参数是可选的。

类型:PsApiManagementUserKeyType
接受的值:Primary, Secondary
Position:Named
默认值:None
必需:False
Accept pipeline input:True
Accept wildcard characters:False

-UserId

现有用户的标识符。 此参数是必需的。

类型:String
Position:Named
默认值:None
必需:True
Accept pipeline input:True
Accept wildcard characters:False

输入

PsApiManagementContext

String

PsApiManagementUserKeyType

Nullable<T>[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

输出

PsApiManagementUserToken