@azure/identity 4.5.0-alpha.20240902.1 → 4.5.0-alpha.20240910.2

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -17,11 +17,10 @@ Key links:
17
17
  ### Currently supported environments
18
18
 
19
19
  - [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
20
- - **Note:** If your application runs on Node.js v8 or lower and you cannot upgrade your Node.js version to latest stable version, then pin your `@azure/identity` dependency to version 1.1.0.
21
20
  - Latest versions of Safari, Chrome, Edge, and Firefox.
22
- - **Note**: Among the different credentials exported in this library, `InteractiveBrowserCredential` is the only one that is supported in the browser.
21
+ - **Note**: Among the different credentials exported in this library, `InteractiveBrowserCredential` is the only one supported in the browser.
23
22
 
24
- See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
23
+ For more information, see our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md).
25
24
 
26
25
  ### Install the package
27
26
 
@@ -46,7 +45,7 @@ Most of the credential types offered by `@azure/identity` use the [Microsoft Aut
46
45
 
47
46
  #### When to use something else
48
47
 
49
- The `@azure/identity` credential types are implementations of [@azure/core-auth](https://www.npmjs.com/package/@azure/core-auth)'s `TokenCredential` class. In principle, any object with a `getToken` method that satisfies `getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>` will work as a `TokenCredential`. This means developers can write their own credential types to support authentication cases not covered by `@azure/identity`. To learn more, see [Custom Credentials](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#custom-credentials).
48
+ The `@azure/identity` credential types are implementations of [@azure/core-auth](https://www.npmjs.com/package/@azure/core-auth)'s `TokenCredential` class. In principle, any object with a `getToken` method that satisfies `getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>` works as a `TokenCredential`. This means developers can write their own credential types to support authentication cases not covered by `@azure/identity`. To learn more, see [Custom Credentials](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#custom-credentials).
50
49
 
51
50
  Though our credential types support many advanced cases, developers may want full control of the authentication protocol. For that use case, we recommend using [Microsoft Authentication Library for JavaScript (MSAL.js)](https://github.com/AzureAD/microsoft-authentication-library-for-js) directly. You can read more through the following links:
52
51
 
@@ -58,25 +57,25 @@ For advanced authentication workflows in the browser, we have a section where we
58
57
 
59
58
  ### Authenticate the client in development environment
60
59
 
61
- While we recommend using managed identity in your Azure-hosted application, it is typical for a developer to use their own account for authenticating calls to Azure services when debugging and executing code locally. There are several developer tools which can be used to perform this authentication in your development environment.
60
+ While we recommend using managed identity in your Azure-hosted application, it's typical for a developer to use their own account for authenticating calls to Azure services when debugging and executing code locally. There are several developer tools that can be used to perform this authentication in your development environment.
62
61
 
63
62
  #### Authenticate via the Azure Developer CLI
64
63
 
65
64
  Developers coding outside of an IDE can also use the [Azure Developer CLI][azure_developer_cli] to authenticate. Applications using the `DefaultAzureCredential` or the `AzureDeveloperCliCredential` can then use this account to authenticate calls in their application when running locally.
66
65
 
67
- To authenticate with the [Azure Developer CLI][azure_developer_cli], users can run the command `azd auth login`. For users running on a system with a default web browser, the Azure Developer CLI will launch the browser to authenticate the user.
66
+ To authenticate with the [Azure Developer CLI][azure_developer_cli], users can run the command `azd auth login`. For users running on a system with a default web browser, the Azure Developer CLI launches the browser to authenticate the user.
68
67
 
69
- For systems without a default web browser, the `azd auth login --use-device-code` command will use the device code authentication flow.
68
+ For systems without a default web browser, the `azd auth login --use-device-code` command uses the device code authentication flow.
70
69
 
71
70
  #### Authenticate via the Azure CLI
72
71
 
73
72
  Applications using the `AzureCliCredential`, whether directly or via the `DefaultAzureCredential`, can use the Azure CLI account to authenticate calls in the application when running locally.
74
73
 
75
- To authenticate with the [Azure CLI][azure_cli] users can run the command `az login`. For users running on a system with a default web browser the Azure cli will launch the browser to authenticate the user.
74
+ To authenticate with the [Azure CLI][azure_cli], run the command `az login`. For users running on a system with a default web browser, the Azure CLI launches the browser to authenticate the user.
76
75
 
77
76
  ![Azure CLI Account Sign In][azureclilogin_image]
78
77
 
79
- For systems without a default web browser, the `az login` command will use the device code authentication flow. The user can also force the Azure CLI to use the device code flow rather than launching a browser by specifying the `--use-device-code` argument.
78
+ For systems without a default web browser, the `az login` command uses the device code authentication flow. The user can also force the Azure CLI to use the device code flow rather than launching a browser by specifying the `--use-device-code` argument.
80
79
 
81
80
  ![Azure CLI Account Device Code Sign In][azureclilogindevicecode_image]
82
81
 
@@ -84,11 +83,11 @@ For systems without a default web browser, the `az login` command will use the d
84
83
 
85
84
  Applications using the `AzurePowerShellCredential`, whether directly or via the `DefaultAzureCredential`, can use the account connected to Azure PowerShell to authenticate calls in the application when running locally.
86
85
 
87
- To authenticate with [Azure PowerShell][azure_powershell] users can run the `Connect-AzAccount` cmdlet. By default, like the Azure CLI, `Connect-AzAccount` will launch the default web browser to authenticate a user account.
86
+ To authenticate with [Azure PowerShell][azure_powershell], run the `Connect-AzAccount` cmdlet. By default, like the Azure CLI, `Connect-AzAccount` launches the default web browser to authenticate a user account.
88
87
 
89
88
  ![Azure PowerShell Account Sign In][azurepowershelllogin_image]
90
89
 
91
- If interactive authentication cannot be supported in the session, then the `-UseDeviceAuthentication` argument will force the cmdlet to use a device code authentication flow instead, similar to the corresponding option in the Azure CLI credential.
90
+ If interactive authentication can't be supported in the session, then the `-UseDeviceAuthentication` argument forces the cmdlet to use a device code authentication flow instead, similar to the corresponding option in the Azure CLI credential.
92
91
 
93
92
  #### Authenticate via Visual Studio Code
94
93
 
@@ -110,32 +109,32 @@ If this is your first time using `@azure/identity` or Microsoft Entra ID, read [
110
109
 
111
110
  ### Credentials
112
111
 
113
- A credential is a class which contains or can obtain the data needed for a service client to authenticate requests. Service clients across the Azure SDK accept credentials when they're constructed. Service clients use those credentials to authenticate requests to the service.
112
+ A credential is a class that contains or can obtain the data needed for a service client to authenticate requests. Service clients across the Azure SDK accept credentials when they're constructed. Service clients use those credentials to authenticate requests to the service.
114
113
 
115
- The Azure Identity library focuses on OAuth authentication with Microsoft Entra ID, and it offers a variety of credential classes capable of acquiring a Microsoft Entra token to authenticate service requests. All of the credential classes in this library are implementations of the [TokenCredential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-auth/src/tokenCredential.ts) abstract class, and any of them can be used by to construct service clients capable of authenticating with a TokenCredential.
114
+ The Azure Identity library focuses on OAuth authentication with Microsoft Entra ID, and it offers various credential classes capable of acquiring a Microsoft Entra token to authenticate service requests. All of the credential classes in this library are implementations of the [TokenCredential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-auth/src/tokenCredential.ts) abstract class, and any of them can be used by to construct service clients capable of authenticating with a `TokenCredential`.
116
115
 
117
116
  See [Credential Classes](#credential-classes).
118
117
 
119
118
  ### DefaultAzureCredential
120
119
 
121
- The `DefaultAzureCredential` is appropriate for most scenarios where the application is intended to ultimately be run in Azure. This is because the `DefaultAzureCredential` combines credentials commonly used to authenticate when deployed with credentials used to authenticate in a development environment.
120
+ `DefaultAzureCredential` is appropriate for most scenarios where the application is intended to ultimately be run in Azure. This is because `DefaultAzureCredential` combines credentials commonly used to authenticate when deployed with credentials used to authenticate in a development environment.
122
121
 
123
122
  > Note: `DefaultAzureCredential` is intended to simplify getting started with the SDK by handling common scenarios with reasonable default behaviors. Developers who want more control or whose scenario isn't served by the default settings should use other credential types.
124
123
 
125
- If used from Node.js, the `DefaultAzureCredential` will attempt to authenticate via the following mechanisms in order:
124
+ If used from Node.js, `DefaultAzureCredential` attempts to authenticate via the following mechanisms in order:
126
125
 
127
126
  ![DefaultAzureCredential authentication flow][defaultauthflow_image]
128
127
 
129
- 1. **Environment** - The `DefaultAzureCredential` will read account information specified via [environment variables](#environment-variables) and use it to authenticate.
130
- 1. **Workload Identity** - If the application is deployed to Azure Kubernetes Service with Managed Identity enabled, `DefaultAzureCredential` will authenticate with it.
131
- 1. **Managed Identity** - If the application is deployed to an Azure host with Managed Identity enabled, the `DefaultAzureCredential` will authenticate with that account.
132
- 1. **Azure CLI** - If the developer has authenticated an account via the Azure CLI `az login` command, the `DefaultAzureCredential` will authenticate with that account.
133
- 1. **Azure PowerShell** - If the developer has authenticated using the Azure PowerShell module `Connect-AzAccount` command, the `DefaultAzureCredential` will authenticate with that account.
134
- 1. **Azure Developer CLI** - If the developer has authenticated an account via the Azure Developer CLI `azd auth login` command, the `DefaultAzureCredential` will authenticate with that account.
128
+ 1. **Environment** - `DefaultAzureCredential` reads account information specified via [environment variables](#environment-variables) and uses it to authenticate.
129
+ 1. **Workload Identity** - If the application is deployed to Azure Kubernetes Service with Managed Identity enabled, `DefaultAzureCredential` authenticates with it.
130
+ 1. **Managed Identity** - If the application is deployed to an Azure host with Managed Identity enabled, `DefaultAzureCredential` authenticates with that account.
131
+ 1. **Azure CLI** - If the developer authenticated an account via the Azure CLI `az login` command, `DefaultAzureCredential` authenticates with that account.
132
+ 1. **Azure PowerShell** - If the developer authenticated using the Azure PowerShell module `Connect-AzAccount` command, `DefaultAzureCredential` authenticates with that account.
133
+ 1. **Azure Developer CLI** - If the developer authenticated an account via the Azure Developer CLI `azd auth login` command, `DefaultAzureCredential` authenticates with that account.
135
134
 
136
135
  #### Continuation policy
137
136
 
138
- As of version 3.3.0, `DefaultAzureCredential` will attempt to authenticate with all developer credentials until one succeeds, regardless of any errors previous developer credentials experienced. For example, a developer credential may attempt to get a token and fail, so `DefaultAzureCredential` will continue to the next credential in the flow. Deployed service credentials will stop the flow with a thrown exception if they're able to attempt token retrieval, but don't receive one.
137
+ As of version 3.3.0, `DefaultAzureCredential` attempts to authenticate with all developer credentials until one succeeds, regardless of any errors previous developer credentials experienced. For example, a developer credential may attempt to get a token and fail, so `DefaultAzureCredential` continues to the next credential in the flow. Deployed service credentials stop the flow with a thrown exception if they're able to attempt token retrieval, but don't receive one.
139
138
 
140
139
  This allows for trying all of the developer credentials on your machine while having predictable deployed behavior.
141
140
 
@@ -148,15 +147,15 @@ Due to a [known issue](https://github.com/Azure/azure-sdk-for-js/issues/20500),
148
147
  Azure Identity for JavaScript provides a plugin API that allows us to provide certain functionality through separate _plugin packages_. The `@azure/identity` package exports a top-level function (`useIdentityPlugin`) that can be used to enable a plugin. We provide two plugin packages:
149
148
 
150
149
  - [`@azure/identity-broker`](https://www.npmjs.com/package/@azure/identity-broker), which provides brokered authentication support through a native broker, such as Web Account Manager.
151
- - [`@azure/identity-cache-persistence`](https://www.npmjs.com/package/@azure/identity-cache-persistence), which provides persistent token caching in Node.js using a native secure storage system provided by your operating system. This plugin allows cached `access_token` values to persist across sessions, meaning that an interactive login flow does not need to be repeated as long as a cached token is available.
150
+ - [`@azure/identity-cache-persistence`](https://www.npmjs.com/package/@azure/identity-cache-persistence), which provides persistent token caching in Node.js using a native secure storage system provided by your operating system. This plugin allows cached `access_token` values to persist across sessions, meaning that an interactive login flow doesn't need to be repeated as long as a cached token is available.
152
151
 
153
152
  ## Examples
154
153
 
155
154
  You can find more examples of using various credentials in [Azure Identity Examples Page](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md)
156
155
 
157
- ### Authenticate with the `DefaultAzureCredential`
156
+ ### Authenticate with `DefaultAzureCredential`
158
157
 
159
- This example demonstrates authenticating the `KeyClient` from the [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys) client library using the `DefaultAzureCredential`.
158
+ This example demonstrates authenticating the `KeyClient` from the [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys) client library using `DefaultAzureCredential`.
160
159
 
161
160
  ```javascript
162
161
  // The default credential first checks environment variables for configuration as described above.
@@ -175,13 +174,13 @@ const credential = new DefaultAzureCredential();
175
174
  const client = new KeyClient(vaultUrl, credential);
176
175
  ```
177
176
 
178
- ### Specify a user-assigned managed identity with the `DefaultAzureCredential`
177
+ ### Specify a user-assigned managed identity with `DefaultAzureCredential`
179
178
 
180
179
  A relatively common scenario involves authenticating using a user-assigned managed identity for an Azure resource. Explore the [example on Authenticating a user-assigned managed identity with DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-a-user-assigned-managed-identity-with-defaultazurecredential) to see how this is made a relatively straightforward task that can be configured using environment variables or in code.
181
180
 
182
- ### Define a custom authentication flow with the `ChainedTokenCredential`
181
+ ### Define a custom authentication flow with `ChainedTokenCredential`
183
182
 
184
- While the `DefaultAzureCredential` is generally the quickest way to get started developing applications for Azure, more advanced users may want to customize the credentials considered when authenticating. The `ChainedTokenCredential` enables users to combine multiple credential instances to define a customized chain of credentials. This example demonstrates creating a `ChainedTokenCredential` which will attempt to authenticate using two differently configured instances of `ClientSecretCredential`, to then authenticate the `KeyClient` from the [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys):
183
+ While `DefaultAzureCredential` is generally the quickest way to get started developing applications for Azure, more advanced users may want to customize the credentials considered when authenticating. The `ChainedTokenCredential` enables users to combine multiple credential instances to define a customized chain of credentials. This example demonstrates creating a `ChainedTokenCredential` that attempts to authenticate using two differently configured instances of `ClientSecretCredential`, to then authenticate the `KeyClient` from the [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys):
185
184
 
186
185
  ```typescript
187
186
  import { ClientSecretCredential, ChainedTokenCredential } from "@azure/identity";
@@ -251,12 +250,17 @@ Not all credentials require this configuration. Credentials that authenticate th
251
250
 
252
251
  ## Credential classes
253
252
 
254
- ### Authenticate Azure-hosted applications
253
+ ### Credential chains
255
254
 
256
255
  | Credential | Usage | Example |
257
256
  | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
258
257
  | [`DefaultAzureCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/defaultazurecredential?view=azure-node-latest) | Provides a simplified authentication experience to quickly start developing applications run in Azure. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-defaultazurecredential) |
259
258
  | [`ChainedTokenCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/chainedtokencredential?view=azure-node-latest) | Allows users to define custom authentication flows composing multiple credentials. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#chaining-credentials) |
259
+
260
+ ### Authenticate Azure-hosted applications
261
+
262
+ | Credential | Usage | Example |
263
+ | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
260
264
  | [`EnvironmentCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/environmentcredential?view=azure-node-latest) | Authenticates a service principal or user via credential information specified in environment variables. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-a-service-principal-with-environment-credentials) |
261
265
  | [`ManagedIdentityCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/managedidentitycredential?view=azure-node-latest) | Authenticates the managed identity of an Azure resource. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-in-azure-with-managed-identity) |
262
266
  | [`WorkloadIdentityCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/workloadidentitycredential?view=azure-node-latest) | Supports [Microsoft Entra Workload ID](https://learn.microsoft.com/azure/aks/workload-identity-overview) on Kubernetes. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-in-azure-with-workload-identity) |
@@ -305,12 +309,13 @@ Not all credentials require this configuration. Credentials that authenticate th
305
309
 
306
310
  #### Service principal with certificate
307
311
 
308
- | Variable name | Value |
309
- | ----------------------------------- | ------------------------------------------------------------ |
310
- | `AZURE_CLIENT_ID` | ID of a Microsoft Entra application |
311
- | `AZURE_TENANT_ID` | ID of the application's Microsoft Entra tenant |
312
- | `AZURE_CLIENT_CERTIFICATE_PATH` | path to a PEM-encoded certificate file including private key |
313
- | `AZURE_CLIENT_CERTIFICATE_PASSWORD` | password of the certificate file, if any |
312
+ | Variable name | Value |
313
+ |---------------------------------------|--------------------------------------------------------------|
314
+ | `AZURE_CLIENT_ID` | ID of a Microsoft Entra application |
315
+ | `AZURE_TENANT_ID` | ID of the application's Microsoft Entra tenant |
316
+ | `AZURE_CLIENT_CERTIFICATE_PATH` | path to a PEM-encoded certificate file including private key |
317
+ | `AZURE_CLIENT_CERTIFICATE_PASSWORD` | (optional) password of the certificate file, if any |
318
+ | `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN` | (optional) send certificate chain in x5c header to support subject name / issuer-based authentication |
314
319
 
315
320
  #### Username and password
316
321
 
@@ -321,7 +326,7 @@ Not all credentials require this configuration. Credentials that authenticate th
321
326
  | `AZURE_USERNAME` | a username (usually an email address) |
322
327
  | `AZURE_PASSWORD` | that user's password |
323
328
 
324
- Configuration is attempted in the above order. For example, if values for a client secret and certificate are both present, the client secret will be used.
329
+ Configuration is attempted in the preceding order. For example, if values for a client secret and certificate are both present, the client secret is used.
325
330
 
326
331
  ## Continuous Access Evaluation
327
332
 
@@ -335,7 +340,7 @@ Token caching is a feature provided by the Azure Identity library that allows ap
335
340
  - Improve resilience and performance.
336
341
  - Reduce the number of requests made to Microsoft Entra ID to obtain access tokens.
337
342
 
338
- The Azure Identity library offers both in-memory and persistent disk caching. For more details, see the [token caching documentation](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/TOKEN_CACHING.md).
343
+ The Azure Identity library offers both in-memory and persistent disk caching. For more information, see the [token caching documentation](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/TOKEN_CACHING.md).
339
344
 
340
345
  ## Brokered authentication
341
346
 
@@ -365,21 +370,12 @@ For other open issues, see the library's [GitHub repository](https://github.com/
365
370
 
366
371
  ### Provide feedback
367
372
 
368
- If you encounter bugs or have suggestions, please [open an issue](https://github.com/Azure/azure-sdk-for-js/issues).
373
+ If you encounter bugs or have suggestions, [open an issue](https://github.com/Azure/azure-sdk-for-js/issues).
369
374
 
370
375
  ## Contributing
371
376
 
372
- If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
373
-
374
- [1]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/defaultazurecredential.html
375
- [2]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/managedidentitycredential.html
376
- [3]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/environmentcredential.html
377
- [4]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/clientsecretcredential.html
378
- [5]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/clientcertificatecredential.html
379
- [6]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/devicecodecredential.html
380
- [7]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/authorizationcodecredential.html
381
- [8]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/interactivebrowsercredential.html
382
- [9]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/usernamepasswordcredential.html
377
+ To contribute to this library, read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
378
+
383
379
  [azure_cli]: https://learn.microsoft.com/cli/azure
384
380
  [azure_developer_cli]: https://learn.microsoft.com/azure/developer/azure-developer-cli
385
381
  [azure_powershell]: https://learn.microsoft.com/powershell/azure/
package/dist/index.js CHANGED
@@ -2212,7 +2212,7 @@ class MsalMsiProvider {
2212
2212
  // For JavaScript users.
2213
2213
  const providedIds = [this.clientId, this.resourceId, this.objectId].filter(Boolean);
2214
2214
  if (providedIds.length > 1) {
2215
- throw new Error(`ManagedIdentityCredential - only one of 'clientId', 'resourceId', or 'objectId' can be provided. Received values: ${JSON.stringify({ clientId: this.clientId, resourceId: this.resourceId, objectId: this.objectId })}`);
2215
+ throw new Error(`ManagedIdentityCredential: only one of 'clientId', 'resourceId', or 'objectId' can be provided. Received values: ${JSON.stringify({ clientId: this.clientId, resourceId: this.resourceId, objectId: this.objectId })}`);
2216
2216
  }
2217
2217
  // ManagedIdentity uses http for local requests
2218
2218
  _options.allowInsecureConnection = true;
@@ -2240,6 +2240,17 @@ class MsalMsiProvider {
2240
2240
  this.isAvailableIdentityClient = new IdentityClient(Object.assign(Object.assign({}, _options), { retryOptions: {
2241
2241
  maxRetries: 0,
2242
2242
  } }));
2243
+ // CloudShell MSI will ignore any user-assigned identity passed as parameters. To avoid confusion, we prevent this from happening as early as possible.
2244
+ if (this.managedIdentityApp.getManagedIdentitySource() === "CloudShell") {
2245
+ if (this.clientId || this.resourceId || this.objectId) {
2246
+ logger$e.warning(`CloudShell MSI detected with user-provided IDs - throwing. Received values: ${JSON.stringify({
2247
+ clientId: this.clientId,
2248
+ resourceId: this.resourceId,
2249
+ objectId: this.objectId,
2250
+ })}.`);
2251
+ throw new CredentialUnavailableError("ManagedIdentityCredential: Specifying a user-assigned managed identity is not supported for CloudShell at runtime. When using Managed Identity in CloudShell, omit the clientId, resourceId, and objectId parameters.");
2252
+ }
2253
+ }
2243
2254
  }
2244
2255
  /**
2245
2256
  * Authenticates with Microsoft Entra ID and returns an access token if successful.
@@ -2301,7 +2312,7 @@ class MsalMsiProvider {
2301
2312
  resourceId: this.resourceId,
2302
2313
  });
2303
2314
  if (!isAvailable) {
2304
- throw new CredentialUnavailableError(`ManagedIdentityCredential: Attempted to use the IMDS endpoint, but it is not available.`);
2315
+ throw new CredentialUnavailableError(`Attempted to use the IMDS endpoint, but it is not available.`);
2305
2316
  }
2306
2317
  }
2307
2318
  // If we got this far, it means: