This repository contains a GitHub Copilot skill for generating D2 architecture diagrams from Azure infrastructure code (Terraform/Terragrunt, with Bicep support coming), along with the Azure icon assets it depends on.
| Path | Description |
|---|---|
skills/d2-gen-azure/ |
Copilot skill for generating D2 architecture diagrams from Azure infrastructure code |
icon-index-terraform-png.json |
Mapping of ~600+ Terraform resource types (azurerm_*, azuread_*) to PNG icon paths |
icon-index-terraform-svg.json |
Same mapping but for SVG icons |
icon-index-bicep-png.json |
Mapping of ARM/Bicep resource types (Microsoft.*) to PNG icon paths |
icon-index-bicep-svg.json |
Same mapping but for SVG icons |
png/Icons/ |
Azure service icons in PNG format |
svg/Icons/ |
Azure service icons in SVG format |
icon-mapping.json |
Full icon metadata (id, display name, category, resource type mappings, tags) |
gh skill install miiitch/d2-gen d2-gen-azureCopy the skills/d2-gen-azure/ folder (including its references/ subfolder) into your repo:
<your-repo>/
.github/
copilot/
skills/
d2-gen-azure/
Copy the skills/d2-gen-azure/ folder into your user-level skills directory:
| OS | Path |
|---|---|
| Windows | %USERPROFILE%\.agents\skills\d2-gen-azure\ |
| macOS/Linux | ~/.agents/skills/d2-gen-azure/ |
Note: VS Code discovers skills via the YAML frontmatter (
name,description) inSKILL.md. No additional registration is needed.
The skill generates .d2 source files and uses the d2 CLI to render them to SVG or PNG. You must have d2 installed and available in your PATH.
- Install: https://d2lang.com
- Verify:
d2 --version
The skill fetches icon resources at runtime via raw.githubusercontent.com URLs pointing to this repository. Two types of resources are accessed:
| Resource | URL |
|---|---|
| Icon mapping index | https://raw.githubusercontent.com/miiitch/d2-gen/refs/heads/main/icon-index-terraform-png.json |
| Icon PNG files | https://raw.githubusercontent.com/miiitch/d2-gen/refs/heads/main/png/Icons/... |
How it works:
- The skill looks up a Terraform resource type (e.g.
azurerm_linux_function_app) in the mapping index JSON. - The mapping returns a relative path (e.g.
png/Icons/iot/10029-icon-service-Function-Apps.png). - The skill builds the full URL by prepending the base path and embeds it in the generated
.d2file viaicon:.
This means:
- This repository must be publicly accessible on GitHub for the icons to load when diagrams are rendered.
- If the repository is private or unreachable, icons will not render. The skill falls back to
shape: rectanglewith a text label. - No authentication token is needed as long as the repository is public.
If you want to host the icons yourself (e.g. for private/air-gapped environments):
-
Fork this repository to your own GitHub org (or mirror it to your own hosting).
-
Edit
skills/d2-gen-azure/SKILL.md— update the two URLs in the "Icon Source Requirement" section:- Mapping index: https://raw.githubusercontent.com/<YOUR-ORG>/<YOUR-REPO>/refs/heads/main/icon-index-terraform-png.json - Base path for icon files: https://raw.githubusercontent.com/<YOUR-ORG>/<YOUR-REPO>/refs/heads/main -
The rest of the skill works without changes.
- Open a project containing Terraform (
.tf), Terragrunt (.hcl), or Bicep (.bicep) files in VS Code. - Invoke the
d2-gen-azureskill via GitHub Copilot (e.g. ask Copilot to generate an architecture diagram). - Answer the 13-question mandatory questionnaire (network links, RBAC, monitoring, grouping mode, layout engine, theme, etc.).
- The skill generates a
.d2file with containers, nodes, connections, icons, and styles. - Render the diagram:
d2 --layout=elk diagram.d2 diagram.svg
MIT
