Skip to content

feat(opencode): support Azure CLI authentication - #45079

Open
opencode-agent[bot] wants to merge 6 commits into
devfrom
azure-cli-refresh
Open

feat(opencode): support Azure CLI authentication#45079
opencode-agent[bot] wants to merge 6 commits into
devfrom
azure-cli-refresh

Conversation

@opencode-agent

Copy link
Copy Markdown
Contributor

Issue for this PR

N/A

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds Microsoft Entra ID authentication through an existing Azure CLI session to the Azure provider while preserving the current API-key flow.

  • Uses az login credentials and cached, automatically refreshed bearer tokens with the correct Azure OpenAI and Microsoft Foundry audiences.
  • Discovers successful Azure model deployments, preserves custom deployment names, and exposes multiple deployments of the same underlying model separately.
  • Allows AZURE_RESOURCE_GROUP to bypass subscription-wide account enumeration when the resource group is already known.
  • Keeps configured/catalog models available and logs an actionable warning when deployment discovery is unavailable, so inference-only Azure roles can still use explicitly configured deployments.
  • Supports both current Azure CLI expires_on timestamps and the legacy expiresOn format.
  • Documents tenant/subscription selection, resource-group configuration, control-plane versus inference permissions, and custom deployment mappings.

The authentication and fallback approach follows documented patterns from Claude Code on Microsoft Foundry, the GitHub Copilot SDK Azure managed identity integration, and the AI SDK Azure provider: renewable bearer credentials, explicit deployment names, and no requirement for model-discovery permissions to perform inference.

How did you verify your code works?

  • bun test test/plugin/azure.test.ts test/provider/provider.test.ts --test-name-pattern 'plugin.azure|Azure' — 12 passing tests covering authentication, token audiences, legacy token expiration, direct resource-group lookup, duplicate deployments, discovery fallback, and existing Azure provider behavior.
  • Scoped bun typecheck covering the changed provider/plugin files and Azure tests.
  • bun x prettier --check packages/opencode/src/plugin/azure.ts packages/opencode/src/provider/provider.ts packages/opencode/test/plugin/azure.test.ts packages/web/src/content/docs/providers.mdx
  • git diff --check origin/dev

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Requested by: @neriousy (Filip via Slack)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant