Share via


AzurePowerShellCredential class

此認證將使用目前從 Azure PowerShell 模組登入的用戶資訊。 若要這樣做,它會使用 Azure PowerShell 命令讀取使用者存取令牌並到期時間Get-AzAccessToken -ResourceUrl {ResourceScope}

建構函式

AzurePowerShellCredential(AzurePowerShellCredentialOptions)

建立 AzurePowerShellCredential 的實例。

若要使用此認證:

  • 使用下列項目安裝 Azure Az PowerShell 模組: Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
  • 您已經使用命令列中的 命令Connect-AzAccount登入 Azure PowerShell。

方法

getToken(string | string[], GetTokenOptions)

使用 Microsoft Entra ID 進行驗證,並在成功時傳回存取令牌。 如果無法透過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 ID 進行驗證,並在成功時傳回存取令牌。 如果無法透過PowerShell執行驗證,則會擲回 CredentialUnavailableError

function getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>

參數

scopes

string | string[]

令牌可存取的範圍清單。

options
GetTokenOptions

用來設定此 TokenCredential 實作之任何要求的選項。

傳回

Promise<AccessToken>