ManagedIdentityCredential class

嘗試使用部署環境中可用的受控識別進行驗證。 此認證類型可在 Azure VM、App Service instances、Azure Functions 應用程式、Azure Kubernetes Services、Azure Service Fabric instances 以及 Azure Cloud Shell 內部運作。

如需設定受控識別的詳細資訊,請參閱這裡:https://learn.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview

建構函式

ManagedIdentityCredential(ManagedIdentityCredentialClientIdOptions)

使用用戶端標識碼建立ManagedIdentityCredential的實例

ManagedIdentityCredential(ManagedIdentityCredentialObjectIdOptions)

使用物件標識碼建立ManagedIdentityCredential的實例

ManagedIdentityCredential(ManagedIdentityCredentialResourceIdOptions)

使用資源標識碼建立ManagedIdentityCredential的實例

ManagedIdentityCredential(string, TokenCredentialOptions)

使用使用者指派身分識別的用戶端標識碼或應用程式註冊建立 ManagedIdentityCredential 實例(使用 AKS pod-identity 時)。

方法

getToken(string | string[], GetTokenOptions)

使用 Microsoft Entra ID 驗證,成功時回傳存取權杖。 如果驗證失敗,CredentialUnavailableError 將會擲回失敗的詳細數據。 如果發生非預期的錯誤,將會擲回 AuthenticationError,並顯示失敗的詳細數據。

建構函式詳細資料

ManagedIdentityCredential(ManagedIdentityCredentialClientIdOptions)

使用用戶端標識碼建立ManagedIdentityCredential的實例

new ManagedIdentityCredential(options?: ManagedIdentityCredentialClientIdOptions)

參數

options
ManagedIdentityCredentialClientIdOptions

設定進行存取令牌要求之客戶端的選項。

ManagedIdentityCredential(ManagedIdentityCredentialObjectIdOptions)

使用物件標識碼建立ManagedIdentityCredential的實例

new ManagedIdentityCredential(options?: ManagedIdentityCredentialObjectIdOptions)

參數

options
ManagedIdentityCredentialObjectIdOptions

設定進行存取令牌要求之資源的選項。

ManagedIdentityCredential(ManagedIdentityCredentialResourceIdOptions)

使用資源標識碼建立ManagedIdentityCredential的實例

new ManagedIdentityCredential(options?: ManagedIdentityCredentialResourceIdOptions)

參數

options
ManagedIdentityCredentialResourceIdOptions

設定進行存取令牌要求之資源的選項。

ManagedIdentityCredential(string, TokenCredentialOptions)

使用使用者指派身分識別的用戶端標識碼或應用程式註冊建立 ManagedIdentityCredential 實例(使用 AKS pod-identity 時)。

new ManagedIdentityCredential(clientId: string, options?: TokenCredentialOptions)

參數

clientId

string

使用者指派身分識別或應用程式註冊的用戶端標識碼(使用 AKS Pod-identity 時)。

options
TokenCredentialOptions

設定進行存取令牌要求之客戶端的選項。

方法詳細資料

getToken(string | string[], GetTokenOptions)

使用 Microsoft Entra ID 驗證,成功時回傳存取權杖。 如果驗證失敗,CredentialUnavailableError 將會擲回失敗的詳細數據。 如果發生非預期的錯誤,將會擲回 AuthenticationError,並顯示失敗的詳細數據。

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

參數

scopes

string | string[]

令牌將具有存取權的範圍清單。

options
GetTokenOptions

用來設定此 TokenCredential 實作可能提出的任何要求的選項。

傳回

Promise<AccessToken>