Azure / Azure/azure-sdk-for-java

[BUG] Azure AI Projects Default Credential

Open
#48,450 4 comments 0 reactions 2 assignees Claimed by @jpalvarezl View on GitHub
AI Projects Azure.Identity Client needs-team-attention
Dominant language
Java
Stars
2.6k
Forks
2.2k
Avg merge
2d 8h
Merged PRs (30d)
178

Description

**Describe the bug**
There seems to be some sort of bug when using `OpenAIClient` and the `DefaultAzureCredential`. It creates an error log for `[Managed Identity] Authentication unavailable. ` when attempting to start. At least one of the Default Azure Credential types is valid, I shouldn't be seeing this error.

***Exception or Stack Trace***
```
2026-03-17T12:42:10.151-07:00 ERROR 31448 --- [global-thread-0] c.m.a.msal4j.IMDSManagedIdentitySource : Error message: [Managed Identity] Authentication unavailable. The requested identity has not been assigned to this resource.Status: 400Content:{"error":"invalid_request","error_description":"Identity not found"}Headers:Server[IMDS/150.870.65.1854]Content-Length[68]x-ms-request-id[9ab0167a-405e-41ce-8d3d-6221a92863fb]Date[Tue, 17 Mar 2026 19:42:09 GMT]Content-Type[application/json; charset=utf-8] [Managed Identity] Error Code: invalid_request Error Message: Identity not found Http status code: 400
2026-03-17T12:42:10.154-07:00 WARN 31448 --- [global-thread-0] c.m.a.msal4j.ManagedIdentityApplication : [Correlation ID: 9b5d8539-b3be-4252-a572-e3cd8dd71564] Execution of class com.microsoft.aad.msal4j.AcquireTokenByManagedIdentitySupplier failed: [Managed Identity] Authentication unavailable. The requested identity has not been assigned to this resource.Status: 400Content:{"error":"invalid_request","error_description":"Identity not found"}Headers:Server[IMDS/150.870.65.1854]Content-Length[68]x-ms-request-id[9ab0167a-405e-41ce-8d3d-6221a92863fb]Date[Tue, 17 Mar 2026 19:42:09 GMT]Content-Type[application/json; charset=utf-8] [Managed Identity] Error Code: invalid_request Error Message: Identity not found
```

**To Reproduce**
Steps to reproduce the behavior:
See Code snippet.

***Code Snippet***
```
OpenAIClient openAIClient = new AIProjectClientBuilder()
.endpoint(endpoint)
.credential(new DefaultAzureCredentialBuilder().build())
.buildOpenAIClient();
```

**Expected behavior**
I should see error for not setup credentials if there is a valid one,.

This does seem like more than one bug.

**Setup (please complete the following information):**
- OS: Windows
- IDE: vscode
- Library/Libraries: azure-identity 1.18.0, azure-ai-projects 2.0.0-beta.2
- Java version: 17
- App Server/Environment: [e.g. Tomcat, WildFly, Azure Function, Apache Spark, Databricks, IDE plugin or anything special]
- Frameworks: Spring Boot

If you suspect a dependency version mismatch (e.g. you see `NoClassDefFoundError`, `NoSuchMethodError` or similar), please check out [Troubleshoot dependency version conflict article](https://aka.ms/azsdk/java/dependency/troubleshoot) first. If it doesn't provide solution for the problem, please provide:
- verbose dependency tree (`mvn dependency:tree -Dverbose`)
- exception message, full stack trace, and any available logs

**Additional context**
Add any other context about the problem here.

**Information Checklist**
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- [ ] Bug Description Added
- [ ] Repro Steps Added
- [ ] Setup information Added

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.