AzurePowerShellCredential class

This credential will use the currently logged-in user information from the Azure PowerShell module. To do so, it will read the user access token and expire time with Azure PowerShell command Get-AzAccessToken -ResourceUrl {ResourceScope}

Constructors

AzurePowerShellCredential(AzurePowerShellCredentialOptions)

Creates an instance of the AzurePowerShellCredential.

To use this credential:

  • Install the Azure Az PowerShell module with: Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force.
  • You have already logged in to Azure PowerShell using the command Connect-AzAccount from the command line.

Methods

getToken(string | string[], GetTokenOptions)

Authenticates with Microsoft Entra ID and returns an access token if successful. If the authentication cannot be performed through PowerShell, a CredentialUnavailableError will be thrown.

Constructor Details

AzurePowerShellCredential(AzurePowerShellCredentialOptions)

Creates an instance of the AzurePowerShellCredential.

To use this credential:

  • Install the Azure Az PowerShell module with: Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force.
  • You have already logged in to Azure PowerShell using the command Connect-AzAccount from the command line.
new AzurePowerShellCredential(options?: AzurePowerShellCredentialOptions)

Parameters

options
AzurePowerShellCredentialOptions

Options, to optionally allow multi-tenant requests.

Method Details

getToken(string | string[], GetTokenOptions)

Authenticates with Microsoft Entra ID and returns an access token if successful. If the authentication cannot be performed through PowerShell, a CredentialUnavailableError will be thrown.

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

Parameters

scopes

string | string[]

The list of scopes for which the token will have access.

options
GetTokenOptions

The options used to configure any requests this TokenCredential implementation might make.

Returns

Promise<AccessToken>