microsoft/power-platform-skills / plugins/power-pages/skills/add-server-logic
add-server-logic
VerifiedCreates, edits, and manages Power Pages Server Logic files — server-side JavaScript that runs securely on the Power Pages runtime. Orchestrates the full lifecycle: gathering requirements, fetching documentation, implementing code, configuring site settings, and deploying. Use when the user wants to add server-side code, create API endpoints, or move logic from the browser to the server in their Power Pages site.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 75.3 KB |
| assets/serverlogic-plan.html | other | 26.6 KB |
| references/frontend-integration-reference.md | markdown | 19.3 KB |
| references/server-logic-docs.md | markdown | 5.0 KB |
| references/server-logic-plan-data-format.md | markdown | 5.7 KB |
| scripts/create-serverlogic-metadata.js | script | 3.7 KB |
| scripts/validate-serverlogic.js | script | 14.7 KB |
references/server-logic-plan-data-format.md
View on GitHub# Server Logic Plan Data Format
Reference document for generating the HTML server logic plan using `render-serverlogic-plan.js`.
## Determine Output Location
- **If working in the context of a website** (a project root with `powerpages.config.json` exists): write the file to `<PROJECT_ROOT>/docs/serverlogic-plan.html`
- **Otherwise**: write to the system temp directory (`[System.IO.Path]::GetTempPath()`)
## Prepare Data
Write a temporary JSON data file with these keys:
```json
{
"SITE_NAME": "The site name from powerpages.config.json or the project folder",
"PLAN_TITLE": "A short plan title such as 'Server Logic Plan'",
"SUMMARY": "A 1-2 sentence summary of what this endpoint will do and why",
"WEB_ROLES_DATA": [],
"SERVER_LOGICS_DATA": [],
"RATIONALE_DATA": [],
"SECRETS_DATA": null
}
```
### WEB_ROLES_DATA Format
```json
[
{
"id": "role-authenticated",
"name": "Authenticated Users",
"desc": "Built-in role for signed-in users.",
"builtin": true,
"isNew": false,
"color": "#8890a4"
}
]
```
### SERVER_LOGICS_DATA Format
```json
[
{
"id": "ticket-dashboard",
"name": "ticket-dashboard",
"displayName": "Ticket Dashboard",
"status": "create",
"apiUrl": "https://<site-url>/_api/serverlogics/ticket-dashboard",
"webRoles": [
{
"id": "role-authenticated",
"reasoning": "Authenticated users need access because the dashboard is part of the signed-in support workspace."
}
],
"rationale": "Keeps Dataverse queries and shaping logic off the client while enforcing role-scoped access.",
"functions": [
{
"name": "get",
"purpose": "Return dashboard metrics",
"reasoning": "The dashboard is read-heavy, so GET keeps the endpoint simple and cache-friendly."
}
]
}
]
```
Use `status` values like `create`, `update`, or `reuse`.
Each `webRoles` entry should explain **why that specific role is assigned to that specific server logic**.
Each `functions` entry should explain **why that specific function is being implemented for that specific server logic**.
When a server logic item wraps a Dataverse custom action (mapped in Phase 2.1.2), include a `customAction` object:
```json
{
"id": "calculate-discount",
"name": "calculate-discount",
"displayName": "Calculate Discount",
"status": "create",
"customAction": {
"name": "new_CalculateDiscount",
"displayName": "Calculate Discount",
"type": "action",
"binding": "entity",
"boundEntity": "salesorder"
},
"...": "other fields as above"
}
```
| Field | Description |
|-------|-------------|
| `customAction` | *(Optional)* Present only when the server logic wraps a Dataverse custom action |
| `customAction.name` | The unique name of the custom action (used in `InvokeCustomApi`) |
| `customAction.displayName` | Human-readable display name |
| `customAction.type` | `action` (POST) or `function` (GET) |
| `customAction.binding` | `unbound`, `entity`, or `entityCollection` |
| `customAction.boundEntity` | *(Optional)* Logical name of the bound entity, if applicable |
When `customAction` is present, the plan HTML renders a badge on the server logic card indicating that it wraps an existing Dataverse custom action. When `customAction` is absent or `null`, no badge is shown.
### RATIONALE_DATA Format
```json
[
{
"icon": "🛡️",
"title": "Why this structure",
"desc": "Separate server logic files keep responsibilities focused and make role assignment clearer."
}
]
```
The overview tab renders these rationale items in the same style as the other Power Pages plan documents.
### SECRETS_DATA Format
Set to `null` when the server logic does not require any secrets. When the user has chosen to use Azure Key Vault, provide an object:
```json
{
"useKeyVault": true,
"vaultName": "contoso-keyvault",
"secrets": [
{
"name": "ExchangeRateApiKey",
"purpose": "API key for the exchange rate service",
"siteSetting": "ExternalApi/ExchangeRateApiKey",
"serverLogicId": "exchange-rate"
}
]
}
```
| Field | Description |
|-------|-------------|
| `useKeyVault` | `true` if the user chose Azure Key Vault; omit or set `false` for direct env vars |
| `vaultName` | *(Optional)* Name of the selected/created Key Vault — shown in the plan if known |
| `secrets[].name` | Descriptive name for the secret (e.g., `ExchangeRateApiKey`) |
| `secrets[].purpose` | Why the secret is needed |
| `secrets[].siteSetting` | The site setting name the server logic reads via `Server.Sitesetting.Get()` |
| `secrets[].serverLogicId` | The `id` (or `name`) of the server logic item that uses this secret — links the secret to the correct card in the plan |
When `useKeyVault` is `true`, the plan HTML renders a prominent banner in the Overview tab explaining that secrets are stored in Azure Key Vault and why it matters (centralized access control, audit logging, rotation support, secrets never in code). Each server logic card also shows the secrets it depends on.
When `SECRETS_DATA` is `null` or `useKeyVault` is `false`, the banner and per-card secrets sections are hidden.
## Render the HTML File
Do **not** write the HTML manually. Use the render script:
```bash
node "${PLUGIN_ROOT}/scripts/render-serverlogic-plan.js" --output "<OUTPUT_PATH>" --data "<DATA_JSON_PATH>"
```
The render script refuses to overwrite existing files. Before calling it, check if the default output path (`<PROJECT_ROOT>/docs/serverlogic-plan.html`) already exists. If it does, choose a new descriptive filename based on context — e.g., `serverlogic-plan-exchange-rate.html`, `serverlogic-plan-apr-2026.html`. Pass the chosen name via `--output`.
Delete the temporary data JSON file after the script succeeds.
## Open in Browser
Open the generated HTML file in the user's default browser.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |