`azure.ai.toolboxes` uses home tenant when deploying a toolbox for guest users
- Dominant language
- Go
- Stars
- 569
- Forks
- 364
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 136
Description
### Description
In guest or cross-tenant scenarios, `azd deploy` can create the Foundry toolbox client with a token from the user's home tenant instead of the selected environment's tenant.
The request then fails even when the target-tenant identity has the required Foundry roles:
```text
403 Forbidden
Identity(object id: ) does not have permissions for
Microsoft.CognitiveServices/accounts/AIServices/agents/write actions.
```
The token's `oid` matches the home-tenant identity, not the guest identity that has Foundry User and Foundry Owner in the target tenant.
### Reproduction
1. Sign in with an account that accesses the target subscription as a guest.
2. Initialize the `langgraph-toolbox` sample from microsoft-foundry/foundry-samples#813.
3. Select an azd environment containing the target `AZURE_SUBSCRIPTION_ID` and `AZURE_TENANT_ID`.
4. Run `azd up`.
Reported with `azure.ai.toolboxes` `1.0.0-beta.5` and `azure.ai.agents` beta.9 or beta.10.
### Likely cause
The toolbox service target calls `foundry.NewCredential()`, which creates `AzureDeveloperCLICredential` without a `TenantID`. The equivalent service-target paths in `azure.ai.agents` and `azure.ai.projects` resolve the subscription through `Account().LookupTenant` and pass the returned user-access tenant to the credential.
Setting `AZURE_TENANT_ID` does not reliably work around this because the unscoped credential invokes `azd auth token` without `--tenant-id`.
### Expected behaviour
Toolbox deployment should resolve `AZURE_SUBSCRIPTION_ID` from the active azd environment, call `Account().LookupTenant`, and create the credential with that tenant.
Related to #7563.
Contributor guide
Assessment
This issue has not been assessed yet.