Skip to content

Commit 0d563bd

Browse files
scottaddieCopilotCopilot
authored
docs: expand Azure Managed Identity BYOK guidance (#1995)
* docs: expand managed identity BYOK guidance Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c19bbd67-bd50-4f54-93e1-8c6961012916 * docs: add Managed Identity to proper noun list Co-authored-by: scottaddie <10702007+scottaddie@users.noreply.github.com> * docs: remove Azure AD branding from style guide Co-authored-by: scottaddie <10702007+scottaddie@users.noreply.github.com> * docs: clarify managed identity token refresh flow Co-authored-by: scottaddie <10702007+scottaddie@users.noreply.github.com> * docs: clarify Azure Identity token caching behavior Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c19bbd67-bd50-4f54-93e1-8c6961012916 * docs: refine AZURE_CLIENT_ID environment guidance Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c19bbd67-bd50-4f54-93e1-8c6961012916 * docs: update BYOK TypeScript Foundry base URL placeholder Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c19bbd67-bd50-4f54-93e1-8c6961012916 * docs: align BYOK bearer token provider base URL placeholder Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c19bbd67-bd50-4f54-93e1-8c6961012916 * docs: normalize Foundry URL placeholders in BYOK samples Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c19bbd67-bd50-4f54-93e1-8c6961012916 --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 85946f2 commit 0d563bd

3 files changed

Lines changed: 311 additions & 93 deletions

File tree

.github/instructions/docs-style.instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Do not use `**bold**` or `*italic*` markers inside headings. The heading level p
2626
* Acronyms: MCP, BYOK, MAF, SDK, CLI, API, HMAC, CI/CD, SaaS, ISV, FAQ, LLM, AI, EMU, ID, UI, PNG
2727
* Tools (keep canonical casing): npm, npx, stdio
2828
* Code identifiers in headings: SessionConfig, MessageOptions, TelemetryConfig, ProviderConfig, CopilotClient
29-
* Multi-word proper names: GitHub App, GitHub Actions, GitHub OAuth, Foundry Local, Azure AD, Container Instances
29+
* Multi-word proper names: GitHub App, GitHub Actions, GitHub OAuth, Foundry Local, Managed Identity, Container Instances
3030

3131
## Callouts
3232

docs/auth/byok.md

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import os
2626
from copilot import CopilotClient
2727
from copilot.session import PermissionHandler
2828

29-
FOUNDRY_MODEL_URL = "https://your-resource.openai.azure.com/openai/v1/"
29+
FOUNDRY_MODEL_URL = "https://<resource-name>.openai.azure.com/openai/v1/"
3030
# Set FOUNDRY_API_KEY environment variable
3131

3232
async def main():
@@ -66,7 +66,7 @@ asyncio.run(main())
6666
```typescript
6767
import { CopilotClient } from "@github/copilot-sdk";
6868

69-
const FOUNDRY_MODEL_URL = "https://your-resource.openai.azure.com/openai/v1/";
69+
const FOUNDRY_MODEL_URL = "https://<resource-name>.openai.azure.com/openai/v1/";
7070

7171
const client = new CopilotClient();
7272
const session = await client.createSession({
@@ -114,7 +114,7 @@ func main() {
114114
Model: "gpt-5.2-codex", // Your deployment name
115115
Provider: &copilot.ProviderConfig{
116116
Type: "openai",
117-
BaseURL: "https://your-resource.openai.azure.com/openai/v1/",
117+
BaseURL: "https://<resource-name>.openai.azure.com/openai/v1/",
118118
WireAPI: "responses", // Use "completions" for older models
119119
APIKey: os.Getenv("FOUNDRY_API_KEY"),
120120
},
@@ -151,7 +151,7 @@ await using var session = await client.CreateSessionAsync(new SessionConfig
151151
Provider = new ProviderConfig
152152
{
153153
Type = "openai",
154-
BaseUrl = "https://your-resource.openai.azure.com/openai/v1/",
154+
BaseUrl = "https://<resource-name>.openai.azure.com/openai/v1/",
155155
WireApi = "responses", // Use "completions" for older models
156156
ApiKey = Environment.GetEnvironmentVariable("FOUNDRY_API_KEY"),
157157
},
@@ -181,7 +181,7 @@ var session = client.createSession(new SessionConfig()
181181
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
182182
.setProvider(new ProviderConfig()
183183
.setType("openai")
184-
.setBaseUrl("https://your-resource.openai.azure.com/openai/v1/")
184+
.setBaseUrl("https://<resource-name>.openai.azure.com/openai/v1/")
185185
.setWireApi("responses") // Use "completions" for older models
186186
.setApiKey(System.getenv("FOUNDRY_API_KEY")))
187187
).get();
@@ -205,6 +205,7 @@ client.stop().get();
205205
| `baseUrl` / `base_url` | string | **Required.** API endpoint URL |
206206
| `apiKey` / `api_key` | string | API key (optional for local providers like Ollama) |
207207
| `bearerToken` / `bearer_token` | string | Bearer token auth (takes precedence over apiKey) |
208+
| `bearerTokenProvider` / `bearer_token_provider` | callback | Returns a bearer token on demand (takes precedence over `apiKey` and `bearerToken`) |
208209
| `wireApi` / `wire_api` | `"completions"` \| `"responses"` | Select `"completions"` for broad model compatibility (the Chat Completions API); select `"responses"` for multi-turn state management, tool namespacing, and reasoning support (the Responses API). Anthropic models always use the Messages API regardless of this setting. |
209210
| `azure.apiVersion` / `azure.api_version` | string | Azure API version (default: `"2024-10-21"`) |
210211

@@ -266,7 +267,7 @@ For Azure AI Foundry deployments with `/openai/v1/` endpoints, use `type: "opena
266267
```typescript
267268
provider: {
268269
type: "openai",
269-
baseUrl: "https://your-resource.openai.azure.com/openai/v1/",
270+
baseUrl: "https://<resource-name>.openai.azure.com/openai/v1/",
270271
apiKey: process.env.FOUNDRY_API_KEY,
271272
wireApi: "responses", // For GPT-5 series models
272273
}
@@ -326,19 +327,37 @@ provider: {
326327

327328
### Bearer token authentication
328329

329-
Some providers require bearer token authentication instead of API keys:
330+
Some providers require bearer token authentication instead of API keys. Supply a static token with `bearerToken`, or supply a `bearerTokenProvider` callback that the GitHub Copilot SDK runtime invokes before outbound provider requests. The callback or identity library it wraps manages token caching and refresh.
331+
332+
Use `bearerToken` when your application already has a token:
330333

331334
```typescript
332335
provider: {
333336
type: "openai",
334-
baseUrl: "https://my-custom-endpoint.example.com/v1",
337+
baseUrl: "https://<resource-name>.openai.azure.com/openai/v1/",
335338
bearerToken: process.env.MY_BEARER_TOKEN, // Sets Authorization header
336339
}
337340
```
338341

339342
> [!NOTE]
340343
> The `bearerToken` option accepts a **static token string** only. The SDK does not refresh this token automatically. If your token expires, requests will fail and you'll need to create a new session with a fresh token.
341344
345+
Use `bearerTokenProvider` to acquire tokens on demand:
346+
347+
<!-- docs-validate: skip -->
348+
349+
```typescript
350+
provider: {
351+
type: "openai",
352+
baseUrl: "https://my-custom-endpoint.example.com/v1",
353+
bearerTokenProvider: async () => {
354+
return await acquireBearerToken();
355+
},
356+
}
357+
```
358+
359+
For more details about acquiring and refreshing Microsoft Entra bearer tokens, see [Azure Managed Identity with BYOK](../setup/azure-managed-identity.md).
360+
342361
## Custom model listing
343362

344363
When using BYOK, the CLI server may not know which models your provider supports. You can supply a custom `onListModels` handler at the client level so that `client.listModels()` returns your provider's models in the standard `ModelInfo` format. This lets downstream consumers discover available models without querying the CLI.

0 commit comments

Comments
 (0)