AzurePowerShellCredential class
此認證將使用 Azure PowerShell 模組中目前登入的用戶資訊。 若要這樣做,它會讀取使用者存取令牌,並使用 Azure PowerShell 命令過期時間 Get-AzAccessToken -ResourceUrl {ResourceScope}
建構函式
Azure |
建立 AzurePowerShellCredential實例。 若要使用此認證:
|
方法
get |
使用 Microsoft Entra 識別碼進行驗證,並在成功時傳回存取令牌。 如果無法透過PowerShell執行驗證,則會擲回 CredentialUnavailableError。 |
建構函式詳細資料
AzurePowerShellCredential(AzurePowerShellCredentialOptions)
建立 AzurePowerShellCredential實例。
若要使用此認證:
- 使用下列項目安裝 Azure Az PowerShell 模組:
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
。 - 您已使用命令列中的命令
Connect-AzAccount
登入 Azure PowerShell。
new AzurePowerShellCredential(options?: AzurePowerShellCredentialOptions)
參數
- options
- AzurePowerShellCredentialOptions
選項,選擇性地允許多租使用者要求。
方法詳細資料
getToken(string | string[], GetTokenOptions)
使用 Microsoft Entra 識別碼進行驗證,並在成功時傳回存取令牌。 如果無法透過PowerShell執行驗證,則會擲回 CredentialUnavailableError。
function getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>
參數
- scopes
-
string | string[]
令牌將具有存取權的範圍清單。
- options
- GetTokenOptions
用來設定此 TokenCredential 實作可能提出的任何要求的選項。
傳回
Promise<AccessToken>