Skip to content

Commit 4d0ecad

Browse files
authored
Update Identity TSG with IntelliJ auth and Common Fork Join Pool. (Azure#37521)
1 parent a2faeb2 commit 4d0ecad

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

sdk/identity/azure-identity/TROUBLESHOOTING.md

+46
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ This troubleshooting guide covers failure investigation techniques, common error
2222
- [Troubleshoot AzureDeveloperCliCredential authentication issues](#troubleshoot-azuredeveloperclicredential-authentication-issues)
2323
- [Troubleshoot AzurePowerShellCredential authentication issues](#troubleshoot-azurepowershellcredential-authentication-issues)
2424
- [Troubleshoot WorkloadIdentityCredential authentication issues](#troubleshoot-workloadidentitycredential-authentication-issues)
25+
- [Troubleshoot IntelliJCredential authentication issues](#troubleshoot-intellijcredential-authentication-issues)
26+
- [Troubleshoot authentication timeout issues](#troubleshoot-authentication-timeout-issues)
2527
- [Get additional help](#get-additional-help)
2628

2729
## Handle Azure Identity exceptions
@@ -275,13 +277,57 @@ Get-AzAccessToken -ResourceUrl "https://management.core.windows.net"
275277
|---|---|---|
276278
|`CredentialUnavailableException` raised with message. "WorkloadIdentityCredential authentication unavailable. The workload options are not fully configured."|The `WorkloadIdentityCredential` requires `clientId`, `tenantId` and `tokenFilePath` to authenticate with Microsoft Entra ID.| <ul><li>If using `DefaultAzureCredential` then:</li><ul><li>Ensure client ID is specified via `workloadIdentityClientId` setter or `AZURE_CLIENT_ID` env variable.</li><li>Ensure tenant ID is specified via `AZURE_TENANT_ID` env variable.</li><li>Ensure token file path is specified via `AZURE_FEDERATED_TOKEN_FILE` env variable.</li><li>Ensure authority host is specified via `AZURE_AUTHORITY_HOST` env variable.</ul><li>If using `WorkloadIdentityCredential` then:</li><ul><li>Ensure tenant ID is specified via `tenantId` setter on credential builder or `AZURE_TENANT_ID` env variable.</li><li>Ensure client ID is specified via `clientId` setter on the credential builder or `AZURE_CLIENT_ID` env variable.</li><li>Ensure token file path is specified via `tokenFilePath` setter on the credential builder or `AZURE_FEDERATED_TOKEN_FILE` environment variable. </li></ul></li><li>Consult the [product troubleshooting guide](https://azure.github.io/azure-workload-identity/docs/troubleshooting.html) for other issues.</li></ul>
277279

280+
## Troubleshoot `IntelliJCredential` authentication issues
281+
282+
| Error |Description| Mitigation |
283+
|---|---|---|
284+
|`CredentialUnavailableException` raised with message. "IntelliJ Authentication not available. Please log in with Azure Tools for IntelliJ plugin in the IDE."| The Credential was not able to locate the cached token to use for authentication. | Ensure that you login on the Azure Tools for IntelliJ plugin, that will populate the cache for the credential to pick up.
285+
278286
## Troubleshoot multi-tenant authentication issues
279287
`ClientAuthenticationException`
280288

281289
| Error Message |Description| Mitigation |
282290
|---|---|---|
283291
|The current credential is not configured to acquire tokens for tenant <tenant ID>|The application must configure the credential to allow acquiring tokens from the requested tenant.|Add the requested tenant ID it to the `additionallyAllowedTenants` on the credential builder, or add \"*\" to `additionallyAllowedTenants` to allow acquiring tokens for any tenant.</p>This exception was added as part of a breaking change to multi tenant authentication in version `1.6.0`. Users experiencing this error after upgrading can find details on the change and migration in [BREAKING_CHANGES.md](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity/BREAKING_CHANGES.md) |
284292

293+
## Troubleshoot authentication timeout issues
294+
295+
### Using Thread pool
296+
The Azure Identity library plays a pivotal role in executing authentication requests. However, a potential concern
297+
arises when your application concurrently relies on the common fork-join pool. This concurrency scenario can lead to
298+
a deadlock situation, wherein both the Azure Identity library and your application compete for threads from the
299+
common fork-join pool. In order to prevent such a deadlock and ensure smooth authentication processes, it is
300+
strongly recommended that you configure a dedicated thread pool specifically for the credentials. By implementing
301+
this configuration, you can ensure that the Azure Identity library and your application do not clash over the
302+
allocation of threads from the common fork-join pool.
303+
304+
To effectively address this deadlock situation, follow these steps:
305+
306+
* Create a Dedicated Thread Pool: Configure a separate and dedicated thread pool for the credential processes within your application. This ensures that the Azure Identity library does not interfere with your application's use of the common fork-join pool.
307+
308+
* Isolation of Thread Pools: Ensure that the dedicated thread pool for credential operations remains isolated and distinct from the common fork-join pool, which is used by the application.
309+
310+
Here's a code sample below:
311+
312+
```java
313+
ExecutorService executorService = Executors.newCachedThreadPool();
314+
315+
try {
316+
ClientSecretCredential credential = new ClientSecretCredentialBuilder()
317+
.clientId("<Client-Id>")
318+
.tenantId("<Tenant-Id>")
319+
.clientSecret("<Client-Secret>")
320+
.executorService(executorService)
321+
.build();
322+
323+
} finally {
324+
//Shutdown the thread pool once no longer needed.
325+
executorService.shutdown();
326+
}
327+
```
328+
329+
You can find more info about Fork Join Pool [here](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ForkJoinPool.html).
330+
285331
## Get additional help
286332

287333
Additional information on ways to reach out for support can be found in the [SUPPORT.md](https://github.com/Azure/azure-sdk-for-java/blob/main/SUPPORT.md) at the root of the repo.

sdk/identity/azure-identity/src/main/java/com/azure/identity/implementation/IdentityClient.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ public Mono<MsalToken> authenticateWithIntelliJ(TokenRequestContext request) {
232232
if (authDetails == null) {
233233
return Mono.error(LoggingUtil.logCredentialUnavailableException(LOGGER, options,
234234
new CredentialUnavailableException("IntelliJ Authentication not available."
235-
+ " Please log in with Azure Tools for IntelliJ plugin in the IDE.")));
235+
+ " Please log in with Azure Tools for IntelliJ plugin in the IDE."
236+
+ " Fore more details refer to the troubleshooting guidelines here at"
237+
+ " https://aka.ms/azsdk/java/identity/intellijcredential/troubleshoot")));
236238
}
237239
String authType = authDetails.getAuthMethod();
238240
if ("SP".equalsIgnoreCase(authType)) {

0 commit comments

Comments
 (0)