Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Scaffold, build, and deploy GitHub Copilot SDK apps to Azure with optional BYOM model config
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/deploy-existing.md
1# Deploy Existing Copilot SDK App23Adapt a user's existing Copilot SDK app for Azure by scaffolding the template to a temp directory, then copying infra into the user's project.45> ⚠️ **Warning:** Do NOT run `azd init` inside the user's project — it overwrites existing files. Always scaffold to a temp dir.67## 1. Scaffold Template to Temp Dir89```bash10azd init --template azure-samples/copilot-sdk-service --cwd <temp-dir>11```1213This gives you the working infra, scripts, and Dockerfiles without touching the user's project.1415## 2. Copy Infra Into User's Project1617From the temp scaffold, copy these into the user's project root:1819| Source | Purpose |20|--------|---------|21| `infra/` | Bicep modules (AVM-based), main.bicep, resources.bicep |22| `scripts/get-github-token.mjs` | azd hook — gets `GITHUB_TOKEN` via `gh auth token` |23| `azure.yaml` | Deployment manifest (will need editing) |2425> ⚠️ Copy `scripts/get-github-token.mjs` exactly — do NOT rewrite it.2627## 3. Adapt azure.yaml2829Edit the copied `azure.yaml` to point at the user's app:3031- Set `services.api.project` to the user's API directory32- Set `services.api.language` to the detected language33- Set `services.api.ports` to the user's port34- Add a `web` service if the app has a frontend35- Keep the `hooks` section unchanged (preprovision + prerun call the token script)3637## 4. GitHub Token Flow3839The template's token flow (already in the copied files):40411. **`scripts/get-github-token.mjs`** — runs `gh auth token`, verifies `copilot` scope, stores via `azd env set`422. **`azure.yaml` hooks** — `preprovision` and `prerun` call the token script433. **Bicep `@secure() param githubToken`** — azd auto-maps the env var444. **Key Vault** — stores secret; Managed Identity gets `Key Vault Secrets User` role4546## 5. Dockerfile4748If the user has no Dockerfile, copy the template's Dockerfile for the detected language from the temp dir and adapt entry point, build steps, and port.4950## 6. BYOM Infrastructure (Azure Model)5152If the user wants Azure BYOM, add to the copied Bicep:5354| Resource | Purpose |55|----------|---------|56| Azure OpenAI / AI Services account | Hosts model deployments |57| Role assignment | `Cognitive Services OpenAI User` for Managed Identity |5859Add env vars to Container App: `AZURE_OPENAI_ENDPOINT`, `MODEL_PROVIDER=azure`, `MODEL_NAME=<deployment>`, `AZURE_CLIENT_ID=<managed-identity-client-id>`.6061> ⚠️ **Warning:** The template's `main.parameters.json` defaults to `gpt-4o` which does NOT support BYOM (encrypted content). Change the default to an o-series or gpt-5 family model.6263See [Azure Model Configuration](azure-model-config.md) for provider config and auth pattern.6465## 7. Errors6667| Error | Fix |68|-------|-----|69| `gh` not installed | User must install GitHub CLI |70| Missing `copilot` scope | Run `gh auth refresh --scopes copilot` |71| Key Vault soft-delete conflict | Use a unique vault name or purge the old one |72| Token not injected | Verify `azure.yaml` hooks and `scripts/get-github-token.mjs` exist |73