bicep-diagrams
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBicep Diagram Generator
Bicep架构图生成器
Generates architecture diagrams directly from Azure Bicep files. Bicep is a domain-specific language (DSL) for deploying Azure resources declaratively.
直接从Azure Bicep文件生成架构图。Bicep是一种用于声明式部署Azure资源的领域特定语言(DSL)。
When to Use
使用场景
Activate this skill when:
- User has Bicep files () and wants to visualize the infrastructure
.bicep - User asks to "diagram my Bicep" or "visualize this Bicep infrastructure"
- User mentions Bicep or Azure Bicep
- User wants to see the architecture of their Bicep-deployed resources
在以下情况激活此技能:
- 用户拥有Bicep文件()并希望可视化其基础设施
.bicep - 用户要求“为我的Bicep生成架构图”或“可视化此Bicep基础设施”
- 用户提及Bicep或Azure Bicep
- 用户希望查看其通过Bicep部署的资源的架构
How It Works
工作原理
This skill generates Bicep-specific diagrams by parsing Bicep code and calling the Eraser API directly:
- Parse Bicep Files: Identify resource declarations, modules, parameters, and outputs
- Extract Relationships: Map dependencies, resource references, and module hierarchies
- Generate Eraser DSL: Create Eraser DSL code from Bicep resources
- Call Eraser API: Use with
/api/render/elementsdiagramType: "cloud-architecture-diagram"
此技能通过解析Bicep代码并直接调用Eraser API来生成特定于Bicep的架构图:
- 解析Bicep文件:识别资源声明、模块、参数和输出
- 提取关系:映射依赖项、资源引用和模块层次结构
- 生成Eraser DSL:根据Bicep资源创建Eraser DSL代码
- 调用Eraser API:使用接口,指定
/api/render/elementsdiagramType: "cloud-architecture-diagram"
Instructions
操作步骤
When the user provides Bicep code:
-
Parse the Bicep
- Identify all declarations (Microsoft.Compute/virtualMachines, etc.)
resource - Extract declarations and their configurations
module - Note and
paramdefinitionsoutput - Identify variables and their usage
var
- Identify all
-
Map Relationships
- Track resource dependencies (e.g., or implicit dependencies)
dependsOn - Group resources by type (compute, networking, storage, etc.)
- Identify VNets as containers for subnets and resources
- Note Network Security Groups, Key Vaults, and other security resources
- Track resource dependencies (e.g.,
-
Generate Eraser DSL Convert Bicep resources to Eraser DSL:
- CRITICAL: Label Formatting Rules
- Labels MUST be on a single line - NEVER use newlines inside label attributes
- Keep labels simple and readable - prefer separate labels over concatenating too much metadata
- Format DSL with proper line breaks (one node/group per line, but labels stay on single lines)
- If including metadata like CIDR blocks or VM sizes, include them in the same quoted label string:
[label: "VNet 10.0.0.0/16"]
Example:myVNet [label: "VNet 10.0.0.0/16"] { subnet1 [label: "Subnet 1"] { myVM [icon: azure-vm, label: "Virtual Machine"] gateway [icon: azure-app-gateway] } subnet2 [label: "Subnet 2"] { database [icon: azure-sql] } } storage [icon: azure-storage] myVNet -> myVM myVM -> database - CRITICAL: Label Formatting Rules
-
Make the HTTP RequestIMPORTANT: You MUST execute this curl command after generating the DSL. Never stop after generating DSL without making the API call.CRITICAL: In theheader below, you MUST replace the value with your AI agent name:
X-Skill-Source- If you are Claude (Anthropic), use:
claude - If you are running in Cursor, use:
cursor - If you are ChatGPT (OpenAI), use:
chatgpt - If you are Gemini (Google), use:
gemini - Otherwise, use your model/agent name in lowercase
bashcurl -X POST https://app.eraser.io/api/render/elements \ -H "Content-Type: application/json" \ -H "X-Skill-Source: eraser-skill" \ -H "Authorization: Bearer ${ERASER_API_KEY}" \ -d '{ "elements": [{ "type": "diagram", "id": "diagram-1", "code": "<your generated DSL>", "diagramType": "cloud-architecture-diagram" }], "scale": 2, "theme": "${ERASER_THEME:-dark}", "background": true }' - If you are Claude (Anthropic), use:
-
Track Sources During AnalysisAs you analyze Bicep files and resources to generate the diagram, track:
- Internal files: Record each Bicep file path you read and what resources were extracted (e.g., - VNet and subnet definitions,
infra/main.bicep- SQL Database configuration)infra/sql.bicep - External references: Note any documentation, examples, or URLs consulted (e.g., Azure Bicep documentation, Azure architecture best practices)
- Annotations: For each source, note what it contributed to the diagram
- Internal files: Record each Bicep file path you read and what resources were extracted (e.g.,
-
Handle the ResponseCRITICAL: Minimal Output FormatYour response MUST always include these elements with clear headers:
-
Diagram Preview: Display with a header
## Diagram Use the ACTUALfrom the API response.imageUrl -
Editor Link: Display with a header
## Open in Eraser [Edit this diagram in the Eraser editor]({createEraserFileUrl})Use the ACTUAL URL from the API response. -
Sources section: Brief list of files/resources analyzed (if applicable)
## Sources - `path/to/file` - What was extracted -
Diagram Code section: The Eraser DSL in a code block withlanguage tag
eraser## Diagram Code ```eraser {DSL code here}undefined -
Learn More link:
You can learn more about Eraser at https://docs.eraser.io/docs/using-ai-agent-integrations
Additional content rules:- If the user ONLY asked for a diagram, include NOTHING beyond the 5 elements above
- If the user explicitly asked for more (e.g., "explain the architecture", "suggest improvements"), you may include that additional content
- Never add unrequested sections like Overview, Security Considerations, Testing, etc.
The default output should be SHORT. The diagram image speaks for itself. -
-
Handle Modules
- If modules are used, show module boundaries
- Include module parameters and outputs
- Show how modules connect to main resources
当用户提供Bicep代码时:
-
解析Bicep代码
- 识别所有声明(如Microsoft.Compute/virtualMachines等)
resource - 提取声明及其配置
module - 记录和
param定义output - 识别变量及其使用情况
var
- 识别所有
-
映射关系
- 跟踪资源依赖项(如或隐式依赖)
dependsOn - 按类型对资源进行分组(计算、网络、存储等)
- 将虚拟网络(VNet)识别为子网和资源的容器
- 记录网络安全组、密钥保管库和其他安全资源
- 跟踪资源依赖项(如
-
生成Eraser DSL 将Bicep资源转换为Eraser DSL:
- 关键:标签格式规则
- 标签必须在单行内 - 绝对不要在标签属性内使用换行符
- 保持标签简洁易读 - 优先使用单独的标签,而不是拼接过多元数据
- 为DSL添加适当的换行符(每个节点/组占一行,但标签保持在单行)
- 如果要包含CIDR块或VM大小等元数据,请将其包含在同一个带引号的标签字符串中:
[label: "VNet 10.0.0.0/16"]
示例:myVNet [label: "VNet 10.0.0.0/16"] { subnet1 [label: "Subnet 1"] { myVM [icon: azure-vm, label: "Virtual Machine"] gateway [icon: azure-app-gateway] } subnet2 [label: "Subnet 2"] { database [icon: azure-sql] } } storage [icon: azure-storage] myVNet -> myVM myVM -> database - 关键:标签格式规则
-
发起HTTP请求重要提示:生成DSL后,必须执行此curl命令。绝对不要在生成DSL后停止而不调用API。关键要求:在下面的请求头中,必须将值替换为你的AI代理名称:
X-Skill-Source- 如果你是Claude(Anthropic),请使用:
claude - 如果你在Cursor中运行,请使用:
cursor - 如果你是ChatGPT(OpenAI),请使用:
chatgpt - 如果你是Gemini(Google),请使用:
gemini - 否则,请使用你的模型/代理名称的小写形式
bashcurl -X POST https://app.eraser.io/api/render/elements \ -H "Content-Type: application/json" \ -H "X-Skill-Source: eraser-skill" \ -H "Authorization: Bearer ${ERASER_API_KEY}" \ -d '{ "elements": [{ "type": "diagram", "id": "diagram-1", "code": "<your generated DSL>", "diagramType": "cloud-architecture-diagram" }], "scale": 2, "theme": "${ERASER_THEME:-dark}", "background": true }' - 如果你是Claude(Anthropic),请使用:
-
分析过程中跟踪来源在分析Bicep文件和资源以生成架构图时,请跟踪:
- 内部文件:记录你读取的每个Bicep文件路径以及提取的资源(例如,- VNet和子网定义,
infra/main.bicep- SQL数据库配置)infra/sql.bicep - 外部引用:记录查阅的任何文档、示例或URL(例如,Azure Bicep文档、Azure架构最佳实践)
- 注释:为每个来源记录其对架构图的贡献
- 内部文件:记录你读取的每个Bicep文件路径以及提取的资源(例如,
-
处理响应关键:最小输出格式你的响应必须始终包含以下元素,并带有清晰的标题:
-
架构图预览:带标题显示
## 架构图 使用API响应中的实际。imageUrl -
编辑器链接:带标题显示
## 在Eraser中打开 [在Eraser编辑器中编辑此架构图]({createEraserFileUrl})使用API响应中的实际URL。 -
来源部分:简要列出分析的文件/资源(如适用)
## 来源 - `path/to/file` - 提取的内容 -
架构图代码部分:将Eraser DSL放在带有语言标签的代码块中
eraser## 架构图代码 ```eraser {DSL代码}undefined -
了解更多链接:
你可以访问https://docs.eraser.io/docs/using-ai-agent-integrations了解更多关于Eraser的信息
额外内容规则:- 如果用户只要求生成架构图,除上述5个元素外,请勿添加任何其他内容
- 如果用户明确要求更多内容(例如,“解释架构”、“建议改进”),你可以添加额外内容
- 绝对不要添加未请求的部分,如概述、安全注意事项、测试等
默认输出应简洁。架构图图片本身即可说明问题。 -
-
处理模块
- 如果使用了模块,请显示模块边界
- 包含模块参数和输出
- 显示模块如何与主资源连接
Bicep-Specific Tips
Bicep特定提示
- Show Resource Groups: Bicep deployments target resource groups
- VNets as Containers: Show VNets containing subnets and resources
- Include Dependencies: Show relationships
dependsOn - Module Structure: If modules are used, show their boundaries
- Parameters: Note key parameters that affect resource configuration
- Use Azure Icons: Request Azure-specific styling
- 显示资源组:Bicep部署以资源组为目标
- 将VNet作为容器:显示VNet包含子网和资源
- 包含依赖项:显示关系
dependsOn - 模块结构:如果使用了模块,请显示其边界
- 参数:记录影响资源配置的关键参数
- 使用Azure图标:请求使用Azure特定样式
Example: Bicep with Parameters and Modules
示例:带参数和模块的Bicep代码
User Input
用户输入
bicep
@description('The name of the Virtual Network')
param vnetName string = 'myVNet'
@description('The address prefix for the VNet')
param vnetAddressPrefix string = '10.0.0.0/16'
@description('The address prefix for the subnet')
param subnetAddressPrefix string = '10.0.1.0/24'
@description('VM size')
param vmSize string = 'Standard_B1s'
// Main VNet resource
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2021-05-01' = {
name: vnetName
location: resourceGroup().location
properties: {
addressSpace: {
addressPrefixes: [vnetAddressPrefix]
}
subnets: [
{
name: 'subnet1'
properties: {
addressPrefix: subnetAddressPrefix
}
}
]
}
}
// VM resource with dependsOn
resource virtualMachine 'Microsoft.Compute/virtualMachines@2021-11-01' = {
name: 'myVM'
location: resourceGroup().location
properties: {
hardwareProfile: {
vmSize: vmSize
}
}
dependsOn: [virtualNetwork]
}
// Module usage
module storageModule './modules/storage.bicep' = {
name: 'storage'
params: {
location: resourceGroup().location
}
}bicep
@description('The name of the Virtual Network')
param vnetName string = 'myVNet'
@description('The address prefix for the VNet')
param vnetAddressPrefix string = '10.0.0.0/16'
@description('The address prefix for the subnet')
param subnetAddressPrefix string = '10.0.1.0/24'
@description('VM size')
param vmSize string = 'Standard_B1s'
// Main VNet resource
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2021-05-01' = {
name: vnetName
location: resourceGroup().location
properties: {
addressSpace: {
addressPrefixes: [vnetAddressPrefix]
}
subnets: [
{
name: 'subnet1'
properties: {
addressPrefix: subnetAddressPrefix
}
}
]
}
}
// VM resource with dependsOn
resource virtualMachine 'Microsoft.Compute/virtualMachines@2021-11-01' = {
name: 'myVM'
location: resourceGroup().location
properties: {
hardwareProfile: {
vmSize: vmSize
}
}
dependsOn: [virtualNetwork]
}
// Module usage
module storageModule './modules/storage.bicep' = {
name: 'storage'
params: {
location: resourceGroup().location
}
}Expected Behavior
预期行为
-
Parses Bicep:
- Parameters: vnetName, vnetAddressPrefix, subnetAddressPrefix, vmSize
- Resources: VNet with subnet, VM with dependsOn relationship
- Module: Storage module with parameters
-
Generates DSL showing Bicep-specific features:
myVNet [label: "VNet 10.0.0.0/16"] { subnet1 [label: "Subnet 1 10.0.1.0/24"] { myVM [icon: azure-vm, label: "VM Standard_B1s"] } } storage-module [label: "Storage Module"] { storage-account [icon: azure-storage] } myVNet -> myVMImportant: All label text must be on a single line within quotes. Bicep-specific: Show modules as containers, includerelationships, note parameter usage in resource configuration.dependsOn -
Callswith
/api/render/elementsdiagramType: "cloud-architecture-diagram" -
Callswith
/api/render/elementsdiagramType: "cloud-architecture-diagram"
-
解析Bicep代码:
- 参数:vnetName、vnetAddressPrefix、subnetAddressPrefix、vmSize
- 资源:带子网的VNet、带有dependsOn关系的VM
- 模块:带参数的存储模块
-
生成显示Bicep特定功能的DSL:
myVNet [label: "VNet 10.0.0.0/16"] { subnet1 [label: "Subnet 1 10.0.1.0/24"] { myVM [icon: azure-vm, label: "VM Standard_B1s"] } } storage-module [label: "Storage Module"] { storage-account [icon: azure-storage] } myVNet -> myVM重要提示:所有标签文本必须在引号内的单行中。Bicep特定要求:将模块显示为容器,包含关系,在资源配置中记录参数使用情况。dependsOn -
调用接口,指定
/api/render/elementsdiagramType: "cloud-architecture-diagram" -
调用接口,指定
/api/render/elementsdiagramType: "cloud-architecture-diagram"
Result
结果
User receives a diagram showing:
- VNet as a container
- Subnet nested inside VNet
- VM in the subnet
- Dependency relationship shown
- Proper Azure styling
用户将收到显示以下内容的架构图:
- VNet作为容器
- 子网嵌套在VNet内
- VM位于子网中
- 显示依赖关系
- 使用正确的Azure样式