Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/instructions/docs-style.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,67 @@ Body text here.

* [Link text](./relative-path.md): short description
```

## Multi-language code examples

When showing the same concept in multiple programming languages, use consecutive `<details>` blocks. The docs-internal normalization pipeline converts these into tabbed language switchers on docs.github.com.

### Rules

* **Only code inside `<details>` blocks.** Shared prose, headings, and explanations must go outside the blocks. Each block should contain only a code fence (and optionally a `<!-- docs-validate: skip -->` comment).
* **Blocks must be consecutive.** No content (headings, paragraphs) between `<details>` blocks in the same group. Blank lines between blocks are fine.
* **Use the exact `<summary>` format:** `<summary><strong>LANGUAGE</strong></summary>`. Supported labels: `.NET`, `Python`, `TypeScript`, `Go`, `Java`, `Rust`, `Node.js`, `Shell`.
* **Need 2+ blocks to form a group.** A single `<details>` block won't be converted and renders as raw HTML on docs.github.com.
* **Equal content across tabs.** Each tab should show the same concept in a different language. Language-specific extras should be a separate section outside the tabs.

### Correct

Shared prose goes above the group, then each `<details>` block contains only code:

```markdown
Install the SDK:

<details open>
<summary><strong>.NET</strong></summary>

<!-- docs-validate: skip -->

```bash
dotnet add package GitHub.Copilot.SDK
```

</details>
<details>
<summary><strong>Python</strong></summary>

<!-- docs-validate: skip -->

```bash
pip install github-copilot-sdk
```

</details>
```

### Incorrect

Do not put headings, prose, or multiple sections inside a `<details>` block:

```markdown
<details>
<summary><strong>Python</strong></summary>

### Prerequisites ← breaks TOC/anchors
Install the packages: ← prose belongs outside

```bash
pip install github-copilot-sdk
```

### Basic usage ← multiple sections in one tab
```python
[code]
```

</details>
```
133 changes: 70 additions & 63 deletions docs/setup/azure-managed-identity.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,49 @@ sequenceDiagram

## Code samples

### Prerequisites

Install the Azure Identity and Copilot SDK packages for your language:

<details open>
<summary><strong>.NET</strong></summary>

### Prerequisites

Install the required packages:
<!-- docs-validate: skip -->

```bash
dotnet add package GitHub.Copilot.SDK
dotnet add package Azure.Core
Comment thread
scottaddie marked this conversation as resolved.
```

</details>
<details>
<summary><strong>Python</strong></summary>

<!-- docs-validate: skip -->

```bash
pip install github-copilot-sdk azure-identity
```

</details>
<details>
<summary><strong>TypeScript</strong></summary>

<!-- docs-validate: skip -->

```bash
npm install @github/copilot-sdk @azure/identity
```

</details>

### Basic usage

Get a token using `DefaultAzureCredential` and pass it as the bearer token in your provider configuration:

<details open>
<summary><strong>.NET</strong></summary>

<!-- docs-validate: skip -->

```csharp
Expand Down Expand Up @@ -76,20 +105,9 @@ Console.WriteLine(response?.Data.Content);
```

</details>

<details>
<summary><strong>Python</strong></summary>

### Prerequisites

Install the required packages:

```bash
pip install github-copilot-sdk azure-identity
```

### Basic usage

<!-- docs-validate: skip -->

```python
Expand Down Expand Up @@ -133,9 +151,46 @@ async def main():
asyncio.run(main())
```

</details>
<details>
<summary><strong>TypeScript</strong></summary>

<!-- docs-validate: skip -->

```typescript
import { DefaultAzureCredential } from "@azure/identity";
import { CopilotClient } from "@github/copilot-sdk";

const credential = new DefaultAzureCredential({
requiredEnvVars: ["AZURE_TOKEN_CREDENTIALS"],
});
const tokenResponse = await credential.getToken(
"https://ai.azure.com/.default"
);

const client = new CopilotClient();

const session = await client.createSession({
model: "gpt-5.5",
provider: {
type: "openai",
baseUrl: `${process.env.FOUNDRY_RESOURCE_URL}/openai/v1/`,
bearerToken: tokenResponse.token,
wireApi: "responses",
},
});

const response = await session.sendAndWait({ prompt: "Hello!" });
console.log(response?.data.content);

await client.stop();
```

</details>

### Token refresh for long-running applications

Bearer tokens expire (typically after ~1 hour). For servers or long-running agents, refresh the token before creating each session:
Bearer tokens expire (typically after ~1 hour). For servers or long-running agents, refresh the token before creating each session. The following Python example demonstrates this pattern:

<!-- docs-validate: skip -->

Expand Down Expand Up @@ -181,54 +236,6 @@ class ManagedIdentityCopilotAgent:
return response.data.content if response else ""
```

</details>

<details>
<summary><strong>TypeScript</strong></summary>

### Prerequisites

Install the required packages:

```bash
npm install @github/copilot-sdk @azure/identity
```

### Basic usage

<!-- docs-validate: skip -->

```typescript
import { DefaultAzureCredential } from "@azure/identity";
import { CopilotClient } from "@github/copilot-sdk";

const credential = new DefaultAzureCredential({
requiredEnvVars: ["AZURE_TOKEN_CREDENTIALS"],
});
const tokenResponse = await credential.getToken(
"https://ai.azure.com/.default"
);

const client = new CopilotClient();

const session = await client.createSession({
model: "gpt-5.5",
provider: {
type: "openai",
baseUrl: `${process.env.FOUNDRY_RESOURCE_URL}/openai/v1/`,
bearerToken: tokenResponse.token,
wireApi: "responses",
},
});

const response = await session.sendAndWait({ prompt: "Hello!" });
console.log(response?.data.content);

await client.stop();
```

</details>

## Environment configuration

| Variable | Description | Example |
Expand Down
Loading