|
| 1 | +# Azure Cosmos DB Samples — Copilot Instructions |
| 2 | + |
| 3 | +## Product naming |
| 4 | + |
| 5 | +- Always say **Azure Cosmos DB** — never "Azure Cosmos DB for NoSQL" |
| 6 | +- The NoSQL API is the only API in this repository and is always inferred |
| 7 | +- Do not generate samples for MongoDB, Cassandra, Gremlin, or Table APIs |
| 8 | + |
| 9 | +## Repository structure |
| 10 | + |
| 11 | +- Root folders by language: `dotnet/`, `python/`, `go/`, `typescript/` |
| 12 | +- Sample folders use the pattern `NNN-kebab-case-name/` (regex: `^[0-9]{3}-[a-z0-9]+(-[a-z0-9]+)*$`) |
| 13 | +- Every sample folder **must** contain a `readme.md` |
| 14 | +- Each sample is self-contained and independently runnable |
| 15 | + |
| 16 | +## Numbering standard |
| 17 | + |
| 18 | +Sample numbers are **shared across languages** — the same number means the same concept in every language. |
| 19 | + |
| 20 | +| Range | Category | Description | |
| 21 | +|-------|----------|-------------| |
| 22 | +| `000–099` | Connectivity | Client setup, authentication, emulator | |
| 23 | +| `100–199` | Quickstart | Hello-world style getting-started scenarios | |
| 24 | +| `200–299` | Features | Change feed, bulk, batch, patch, indexing | |
| 25 | +| `300–399` | Patterns | Multi-tenancy, pagination, retry, hierarchical partition keys | |
| 26 | +| `400–499` | Advanced | Vector search, AI integration, semantic cache | |
| 27 | +| `500–599` | Vertical | End-to-end apps (todo, IoT, e-commerce) | |
| 28 | + |
| 29 | +## Shared data model |
| 30 | + |
| 31 | +All samples use the same database, container, and item shape: |
| 32 | + |
| 33 | +- **Database:** `cosmicworks` |
| 34 | +- **Container:** `products` |
| 35 | +- **Partition key:** `/category` |
| 36 | +- **Product shape:** `{ id, category, name, quantity, sale }` |
| 37 | +- **Canonical item:** id `70b63682-b93a-4c77-aad2-65501347265f`, category `gear-surf-surfboards`, name `Yamba Surfboard`, quantity `12`, sale `false` |
| 38 | + |
| 39 | +## Authentication |
| 40 | + |
| 41 | +- **00x range only** (connect samples): passwordless via `DefaultAzureCredential` |
| 42 | +- **All other samples**: key-based via `COSMOS_ENDPOINT` + `COSMOS_KEY` environment variables |
| 43 | + |
| 44 | +## Package versions |
| 45 | + |
| 46 | +Do **not** pin specific package versions. Use floating or major-version ranges: |
| 47 | + |
| 48 | +- .NET: `Version="3.*"` in `Directory.Packages.props` or `#:package Foo@3.*` in script files |
| 49 | +- Python: `azure-cosmos>=4.9` in `requirements.txt` |
| 50 | +- Go: standard `go get` versioning |
| 51 | +- TypeScript: caret ranges (`^`) in `package.json` |
| 52 | + |
| 53 | +## README conventions |
| 54 | + |
| 55 | +- **Title pattern:** `{Operation} with Azure Cosmos DB ({Language})` |
| 56 | +- **Sections:** Prerequisites, Run (with macOS/Linux + Windows PowerShell blocks), What this sample does |
| 57 | +- **Environment variable callout:** use `> [!IMPORTANT]` note |
| 58 | +- **Connect samples (00x):** only read account metadata — no CRUD operations |
| 59 | +- Do not include `.env.example` files — put env var instructions inline in the readme |
| 60 | + |
| 61 | +## Testing and CI |
| 62 | + |
| 63 | +- Samples are validated on **every push to `main`** and on **every pull request** |
| 64 | +- Samples should be runnable against the **Azure Cosmos DB emulator** |
| 65 | +- The CI workflow (`.github/workflows/validate.yml`) runs per-language build jobs independently |
| 66 | +- Structure validation enforces the naming regex and readme presence |
| 67 | + |
| 68 | +## Anti-patterns |
| 69 | + |
| 70 | +- Do not say "for NoSQL" — just "Azure Cosmos DB" |
| 71 | +- Do not add `.env.example` files |
| 72 | +- Do not use `python-dotenv` — use `os.environ` directly |
| 73 | +- Do not pin exact package versions |
| 74 | +- Do not mix CRUD operations into connect samples |
| 75 | +- Do not use `matrix` strategy in CI with single versions (causes version-suffixed check names) |
0 commit comments