generate-azure-bicep

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Skill: generate-azure-bicep

技能:generate-azure-bicep

Version: 0.3.0-alpha Purpose: Generate Azure Bicep infrastructure modules using Azure Verified Modules (AVM) and bicepparams Author: The Forge Last Updated: 2025-11-18

版本: 0.3.0-alpha 用途: 使用Azure验证模块(AVM)和bicepparams生成Azure Bicep基础设施模块 作者: The Forge 最后更新: 2025-11-18

Title

标题

Generate Azure Bicep - Create production-ready Bicep infrastructure modules using Azure Verified Modules with environment-specific parameters

Generate Azure Bicep - 使用Azure验证模块创建可用于生产环境的Bicep基础设施模块,并支持环境特定参数

File Structure

文件结构

forge-plugin/skills/generate-azure-bicep/
├── SKILL.md                  # This file - mandatory workflow
├── examples.md               # Usage scenarios and examples
├── scripts/
│   └── bicep_generator.py    # Helper script for Bicep generation
└── templates/
    ├── main-bicep-avm-template.bicep          # Main Bicep using AVM
    ├── bicepparams-template.bicep             # Parameters file template
    ├── wrapper-module-template.bicep          # Custom wrapper for AVM module
    └── README-template.md                     # Documentation template

forge-plugin/skills/generate-azure-bicep/
├── SKILL.md                  # 本文件 - 强制工作流
├── examples.md               # 使用场景和示例
├── scripts/
│   └── bicep_generator.py    # Bicep生成辅助脚本
└── templates/
    ├── main-bicep-avm-template.bicep          # 基于AVM的主Bicep模板
    ├── bicepparams-template.bicep             # 参数文件模板
    ├── wrapper-module-template.bicep          # AVM模块自定义包装器
    └── README-template.md                     # 文档模板

Interface References

接口引用

  • ContextProvider
    getDomainIndex("azure")
    ,
    getConditionalContext("azure", topic)
  • MemoryStore
    getSkillMemory("generate-azure-bicep", project)
    ,
    update()
Context (via ContextProvider):
  • contextProvider.getDomainIndex("azure")
    — Azure context navigation
  • contextProvider.getConditionalContext("azure", "azure_verified_modules")
    — AVM concepts, usage patterns, best practices
  • contextProvider.getConditionalContext("azure", "azure_bicep_overview")
    — Bicep syntax and structure
Memory (via MemoryStore):
  • memoryStore.getSkillMemory("generate-azure-bicep", project)
    returns per-project files:
    • bicep_config.md
      — Previous Bicep configurations
    • avm_modules.md
      — AVM modules used and versions
    • resource_naming.md
      — Naming conventions
    • customizations.md
      — Custom wrapper modules

  • ContextProvider
    getDomainIndex("azure")
    ,
    getConditionalContext("azure", topic)
  • MemoryStore
    getSkillMemory("generate-azure-bicep", project)
    ,
    update()
上下文(通过ContextProvider):
  • contextProvider.getDomainIndex("azure")
    — Azure上下文导航
  • contextProvider.getConditionalContext("azure", "azure_verified_modules")
    — AVM概念、使用模式、最佳实践
  • contextProvider.getConditionalContext("azure", "azure_bicep_overview")
    — Bicep语法和结构
内存存储(通过MemoryStore):
  • memoryStore.getSkillMemory("generate-azure-bicep", project)
    返回每个项目的文件:
    • bicep_config.md
      — 之前的Bicep配置
    • avm_modules.md
      — 使用的AVM模块及其版本
    • resource_naming.md
      — 命名规范
    • customizations.md
      — 自定义包装器模块

Design Requirements

设计要求

Core Functionality

核心功能

This skill must:
  1. Use Azure Verified Modules as the foundation for all resource deployments
  2. Generate main.bicep that composes AVM modules
  3. Create bicepparams files for each environment (development, staging, production)
  4. Generate custom wrapper modules when needed for project-specific requirements
  5. Create
    .azure/bicep/
    directory structure
    with modules subdirectory
  6. Apply consistent naming and tagging across all resources
  7. Store Bicep configuration in memory for future updates
本技能必须:
  1. 使用Azure验证模块作为所有资源部署的基础
  2. 生成main.bicep来组合AVM模块
  3. 为每个环境创建bicepparams文件(开发、测试、生产)
  4. 在需要时生成自定义包装器模块以满足项目特定需求
  5. 创建
    .azure/bicep/
    目录结构
    ,包含modules子目录
  6. 在所有资源上应用一致的命名和标签
  7. 将Bicep配置存储在内存中以便未来更新

Output Requirements

输出要求

Generate a complete
.azure/bicep/
directory
with:
  • main.bicep using AVM module references
  • Environment-specific .bicepparams files
  • Custom wrapper modules (if needed)
  • Documentation explaining module usage
  • Consistent resource naming strategy
生成完整的
.azure/bicep/
目录,包含:
  • 引用AVM模块的main.bicep
  • 环境特定的.bicepparams文件
  • 自定义包装器模块(如有需要)
  • 说明模块用法的文档
  • 一致的资源命名策略

Quality Requirements

质量要求

Generated Bicep must:
  • Use latest stable AVM versions from public registry
  • Follow Azure Well-Architected Framework principles
  • Pin module versions for reproducibility
  • Include diagnostic settings where applicable
  • Apply tags consistently across all resources
  • Be well-documented with parameter descriptions

生成的Bicep必须:
  • 使用公共注册表中的最新稳定AVM版本
  • 遵循Azure良好架构框架原则
  • 固定模块版本以确保可复现性
  • 在适用的地方包含诊断设置
  • 在所有资源上一致地应用标签
  • 具备完善的文档,包含参数说明

Prompting Guidelines

提示指南

User Questions Framework

用户问题框架

Use Socratic method to gather requirements. Ask questions in this order:
使用苏格拉底方法收集需求。按以下顺序提问:

1. Infrastructure Scope

1. 基础设施范围

Question: "What Azure resources does your application need?"
Options (can select multiple):
  • Storage Account (Blob, Queue, Table)
  • Function App / App Service
  • Key Vault (secrets management)
  • Application Insights (monitoring)
  • SQL Database / Cosmos DB
  • Virtual Network (VNet, subnets, NSG)
  • Container Registry
  • Service Bus / Event Hub
  • Other resources
Follow-up: "This determines which AVM modules to use."
问题:“你的应用需要哪些Azure资源?”
选项(可多选):
  • 存储账户(Blob、队列、表)
  • 函数应用/应用服务
  • 密钥保管库(机密管理)
  • 应用洞察(监控)
  • SQL数据库/Cosmos DB
  • 虚拟网络(VNet、子网、NSG)
  • 容器注册表
  • 服务总线/事件中心
  • 其他资源
跟进:“这将决定使用哪些AVM模块。”

2. Environments

2. 环境

Question: "Which environments do you need?"
Options:
  • Development only
  • Development + Production
  • Development + Staging + Production
  • Custom environments
Follow-up: "This creates environment-specific bicepparams files."
问题:“你需要哪些环境?”
选项
  • 仅开发环境
  • 开发 + 生产
  • 开发 + 测试 + 生产
  • 自定义环境
跟进:“这将创建环境特定的bicepparams文件。”

3. Resource Naming Convention

3. 资源命名规范

Question: "What naming convention should we use for resources?"
Options:
  • Standard Azure naming (
    {resource-abbr}-{environment}-{region}
    )
  • Custom prefix (e.g.,
    myapp-{resource}-{environment}
    )
  • Project-specific pattern
  • Use Azure naming tool recommendations
Follow-up: "This ensures consistent resource names across environments."
问题:“我们应该为资源使用什么命名规范?”
选项
  • 标准Azure命名(
    {resource-abbr}-{environment}-{region}
  • 自定义前缀(例如:
    myapp-{resource}-{environment}
  • 项目特定模式
  • 使用Azure命名工具的建议
跟进:“这确保跨环境的资源名称一致。”

4. Azure Region

4. Azure区域

Question: "Which Azure region(s) for deployments?"
Options:
  • Single region for all environments
  • Different regions per environment
  • Multi-region deployment
Follow-up: "This sets location parameters in bicepparams files."
问题:“部署使用哪个/哪些Azure区域?”
选项
  • 所有环境使用单个区域
  • 每个环境使用不同区域
  • 多区域部署
跟进:“这将在bicepparams文件中设置位置参数。”

5. Deployment Scope

5. 部署范围

Question: "What deployment scope do you need?"
Options:
  • Resource Group (most common)
  • Subscription (for creating resource groups)
  • Management Group
  • Tenant
Follow-up: "This sets the targetScope in main.bicep."
问题:“你需要什么部署范围?”
选项
  • 资源组(最常见)
  • 订阅(用于创建资源组)
  • 管理组
  • 租户
跟进:“这将在main.bicep中设置targetScope。”

6. Custom Requirements

6. 自定义需求

Question: "Do you have any custom requirements?"
Options:
  • Private endpoints for resources
  • Managed identities
  • VNet integration
  • Custom RBAC roles
  • Bring your own keys (BYOK)
  • Compliance requirements
Follow-up: "This determines which optional AVM parameters to configure."

问题:“你有任何自定义需求吗?”
选项
  • 资源的专用终结点
  • 托管标识
  • VNet集成
  • 自定义RBAC角色
  • 自带密钥(BYOK)
  • 合规性要求
跟进:“这将决定配置哪些可选的AVM参数。”

Instructions

操作说明

Mandatory Workflow

强制工作流

IMPORTANT: Follow these steps in order. Do not skip steps.

重要提示:按顺序执行以下步骤,不要跳过任何步骤。

Step 1: Initial Analysis

步骤1:初始分析

Objective: Understand current project context
Actions:
  1. Identify current working directory
  2. Check if
    .azure/bicep/
    directory already exists
  3. Check for existing Bicep files or AVM module usage
  4. Identify project type and deployment target
Verification: Project context understood before proceeding

目标:了解当前项目上下文
操作
  1. 识别当前工作目录
  2. 检查
    .azure/bicep/
    目录是否已存在
  3. 检查是否有现有的Bicep文件或AVM模块使用情况
  4. 识别项目类型和部署目标
验证:在继续之前已理解项目上下文

Step 2: Load Index Files

步骤2:加载索引文件

Objective: Understand available context and memory structure
Actions:
  1. Load Azure domain index via
    contextProvider.getDomainIndex("azure")
  2. Identify which context topics will be needed based on requirements
Verification: Domain index loaded, know which context topics to load next

目标:了解可用的上下文和内存结构
操作
  1. 通过
    contextProvider.getDomainIndex("azure")
    加载Azure域索引
  2. 根据需求确定需要哪些上下文主题
验证:域索引已加载,明确接下来要加载哪些上下文主题

Step 3: Load Project Memory

步骤3:加载项目内存

Objective: Check for existing project-specific Bicep configurations
Actions:
  1. Determine project name from current directory or user input
  2. Load project memory via
    memoryStore.getSkillMemory("generate-azure-bicep", project)
  3. If memory exists, review all memory files:
    • bicep_config.md
      - Previous infrastructure setup
    • avm_modules.md
      - AVM modules used and versions
    • resource_naming.md
      - Naming conventions
    • customizations.md
      - Custom wrapper modules
Verification: Memory loaded if exists; ready to use previous configurations

目标:检查是否存在项目特定的Bicep配置
操作
  1. 从当前目录或用户输入确定项目名称
  2. 通过
    memoryStore.getSkillMemory("generate-azure-bicep", project)
    加载项目内存
  3. 如果内存存在,查看所有内存文件:
    • bicep_config.md
      - 之前的基础设施设置
    • avm_modules.md
      - 使用的AVM模块及其版本
    • resource_naming.md
      - 命名规范
    • customizations.md
      - 自定义包装器模块
验证:如果内存存在则已加载;准备好使用之前的配置

Step 4: Load Bicep Context

步骤4:加载Bicep上下文

Objective: Load Azure Verified Modules and Bicep knowledge
Actions:
  1. Load AVM context via
    contextProvider.getConditionalContext("azure", "azure_verified_modules")
  2. Load Bicep overview via
    contextProvider.getConditionalContext("azure", "azure_bicep_overview")
Verification: Context loaded, understand AVM patterns and Bicep syntax

目标:加载Azure验证模块和Bicep相关知识
操作
  1. 通过
    contextProvider.getConditionalContext("azure", "azure_verified_modules")
    加载AVM上下文
  2. 通过
    contextProvider.getConditionalContext("azure", "azure_bicep_overview")
    加载Bicep概述
验证:上下文已加载,理解AVM模式和Bicep语法

Step 5: Gather Requirements

步骤5:收集需求

Objective: Ask user Socratic questions to gather all requirements
Actions:
  1. Ask about infrastructure scope (which Azure resources)
  2. Ask about environments (dev, staging, prod)
  3. Ask about resource naming convention
  4. Ask about Azure region(s)
  5. Ask about deployment scope (resource group, subscription, etc.)
  6. Ask about custom requirements (private endpoints, managed identities, etc.)
Verification: All requirements gathered, user confirmed ready to proceed

目标:向用户提问以收集所有需求
操作
  1. 询问基础设施范围(需要哪些Azure资源)
  2. 询问环境(开发、测试、生产等)
  3. 询问资源命名规范
  4. 询问Azure区域
  5. 询问部署范围(资源组、订阅等)
  6. 询问自定义需求(专用终结点、托管标识等)
验证:已收集所有需求,用户确认可以继续

Step 6: Design Module Structure

步骤6:设计模块结构

Objective: Plan which AVM modules to use and how to compose them
Actions:
  1. Map requirements to AVM modules:
    • Storage Account →
      avm/res/storage/storage-account
    • Function App →
      avm/res/web/site
    • Key Vault →
      avm/res/key-vault/vault
    • (etc. for all required resources)
  2. Determine module dependencies:
    • Identify which modules depend on others
    • Plan output sharing between modules
    • Design proper ordering
  3. Plan custom wrapper modules:
    • Identify if any resources need custom wrappers
    • Design wrapper module parameters
    • Document wrapper purpose
Verification: Module structure designed, dependencies mapped

目标:规划使用哪些AVM模块以及如何组合它们
操作
  1. 将需求映射到AVM模块
    • 存储账户 →
      avm/res/storage/storage-account
    • 函数应用 →
      avm/res/web/site
    • 密钥保管库 →
      avm/res/key-vault/vault
    • (其他所需资源依此类推)
  2. 确定模块依赖关系
    • 识别哪些模块依赖于其他模块
    • 规划模块之间的输出共享
    • 设计正确的顺序
  3. 规划自定义包装器模块
    • 识别是否有资源需要自定义包装器
    • 设计包装器模块参数
    • 记录包装器的用途
验证:模块结构已设计,依赖关系已映射

Step 7: Generate Bicep Structure

步骤7:生成Bicep结构

Objective: Create
.azure/bicep/
directory with all files
Actions:
  1. Create directory structure:
    bash
    mkdir -p .azure/bicep/modules
    mkdir -p .azure/docs
  2. Generate main.bicep:
    • Set targetScope (subscription, resourceGroup, etc.)
    • Define parameters for environment-agnostic values
    • Reference AVM modules with pinned versions
    • Pass parameters to modules
    • Define outputs for resource IDs and names
  3. Generate bicepparams files for each environment:
    • main.development.bicepparams
    • main.staging.bicepparams
    • main.production.bicepparams
    • Set environment-specific SKUs, regions, names
  4. Generate custom wrapper modules (if needed):
    • Create modules in
      .azure/bicep/modules/
    • Wrap AVM modules with project-specific defaults
    • Document wrapper purpose and parameters
  5. Generate documentation:
    • .azure/docs/infrastructure.md
      - Explains infrastructure setup
    • Parameter descriptions
    • Deployment instructions
Verification: All files created, no errors during generation

目标:创建包含所有文件的
.azure/bicep/
目录
操作
  1. 创建目录结构
    bash
    mkdir -p .azure/bicep/modules
    mkdir -p .azure/docs
  2. 生成main.bicep
    • 设置targetScope(订阅、resourceGroup等)
    • 定义与环境无关的参数
    • 引用固定版本的AVM模块
    • 向模块传递参数
    • 定义资源ID和名称的输出
  3. 为每个环境生成bicepparams文件
    • main.development.bicepparams
    • main.staging.bicepparams
    • main.production.bicepparams
    • 设置环境特定的SKU、区域、名称
  4. 生成自定义包装器模块(如有需要):
    • .azure/bicep/modules/
      中创建模块
    • 用项目特定的默认值包装AVM模块
    • 记录包装器的用途和参数
  5. 生成文档
    • .azure/docs/infrastructure.md
      - 说明基础设施设置
    • 参数说明
    • 部署说明
验证:所有文件已创建,生成过程中无错误

Step 8: Customize Templates

步骤8:自定义模板

Objective: Populate templates with project-specific values
Actions:
  1. Replace placeholders in main.bicep:
    • {{PROJECT_NAME}}
      - Project name
    • {{RESOURCE_PREFIX}}
      - Resource naming prefix
    • {{DEFAULT_LOCATION}}
      - Default Azure region
  2. Replace placeholders in bicepparams:
    • {{ENVIRONMENT}}
      - Environment name
    • {{LOCATION}}
      - Azure region
    • {{SKU}}
      - Resource SKU for environment
  3. Configure AVM module versions:
    • Use latest stable versions from registry
    • Pin to specific versions for reproducibility
    • Document version choices
Verification: Templates customized with correct values

目标:用项目特定的值填充模板
操作
  1. 替换main.bicep中的占位符:
    • {{PROJECT_NAME}}
      - 项目名称
    • {{RESOURCE_PREFIX}}
      - 资源命名前缀
    • {{DEFAULT_LOCATION}}
      - 默认Azure区域
  2. 替换bicepparams中的占位符:
    • {{ENVIRONMENT}}
      - 环境名称
    • {{LOCATION}}
      - Azure区域
    • {{SKU}}
      - 环境的资源SKU
  3. 配置AVM模块版本:
    • 使用注册表中的最新稳定版本
    • 固定到特定版本以确保可复现性
    • 记录版本选择
验证:模板已用正确的值自定义

Step 9: Validate Bicep Files

步骤9:验证Bicep文件

Objective: Ensure generated Bicep is syntactically correct
Actions:
  1. Validate Bicep syntax:
    bash
    az bicep build --file .azure/bicep/main.bicep
  2. Validate deployment (if Azure CLI available):
    bash
    az deployment sub validate \
      --location <location> \
      --template-file .azure/bicep/main.bicep \
      --parameters .azure/bicep/main.development.bicepparams
  3. Check AVM module versions exist:
    bash
    az bicep list-versions --module-path "br/public:avm/res/..."
Verification: No syntax errors, all modules accessible

目标:确保生成的Bicep语法正确
操作
  1. 验证Bicep语法:
    bash
    az bicep build --file .azure/bicep/main.bicep
  2. 验证部署(如果Azure CLI可用):
    bash
    az deployment sub validate \
      --location <location> \
      --template-file .azure/bicep/main.bicep \
      --parameters .azure/bicep/main.development.bicepparams
  3. 检查AVM模块版本是否存在:
    bash
    az bicep list-versions --module-path "br/public:avm/res/..."
验证:无语法错误,所有模块均可访问

Step 10: Present Results

步骤10:呈现结果

Objective: Show user what was generated and next steps
Actions:
  1. Display generated directory structure
  2. List all created files with their purposes
  3. Provide deployment instructions:
    bash
    # Deploy to subscription
    az deployment sub create \
      --location <location> \
      --template-file .azure/bicep/main.bicep \
      --parameters .azure/bicep/main.development.bicepparams
    
    # Or deploy to resource group
    az deployment group create \
      --resource-group <rg-name> \
      --template-file .azure/bicep/main.bicep \
      --parameters .azure/bicep/main.development.bicepparams
  4. Explain how to update:
    • Change parameters in .bicepparams files
    • Update AVM module versions
    • Add new resources to main.bicep
Verification: User understands what was generated and how to deploy

目标:向用户展示生成的内容和后续步骤
操作
  1. 显示生成的目录结构
  2. 列出所有创建的文件及其用途
  3. 提供部署说明:
    bash
    # 部署到订阅
    az deployment sub create \
      --location <location> \
      --template-file .azure/bicep/main.bicep \
      --parameters .azure/bicep/main.development.bicepparams
    
    # 或部署到资源组
    az deployment group create \
      --resource-group <rg-name> \
      --template-file .azure/bicep/main.bicep \
      --parameters .azure/bicep/main.development.bicepparams
  4. 说明如何更新:
    • 修改.bicepparams文件中的参数
    • 更新AVM模块版本
    • 向main.bicep添加新资源
验证:用户理解生成的内容以及如何部署

Step 11: Update Project Memory

步骤11:更新项目内存

Objective: Store configuration for future reference
Actions:
  1. Use
    memoryStore.update("generate-azure-bicep", project, "bicep_config.md", content)
    with:
    • Deployment scope (subscription, resource group)
    • Resource naming convention
    • Environments configured
    • Azure regions used
  2. Use
    memoryStore.update("generate-azure-bicep", project, "avm_modules.md", content)
    with:
    • List all AVM modules used
    • Module versions and purposes
    • Module dependencies
  3. Use
    memoryStore.update("generate-azure-bicep", project, "resource_naming.md", content)
    with:
    • Naming patterns for each resource type
    • Examples of generated names
  4. Use
    memoryStore.update("generate-azure-bicep", project, "customizations.md", content)
    with:
    • Custom wrapper modules created
    • Deviations from standard AVM usage
    • Special configurations
Verification: Memory files created/updated with all relevant information

目标:存储配置以供未来参考
操作
  1. 使用
    memoryStore.update("generate-azure-bicep", project, "bicep_config.md", content)
    存储:
    • 部署范围(订阅、资源组)
    • 资源命名规范
    • 已配置的环境
    • 使用的Azure区域
  2. 使用
    memoryStore.update("generate-azure-bicep", project, "avm_modules.md", content)
    存储:
    • 使用的所有AVM模块列表
    • 模块版本和用途
    • 模块依赖关系
  3. 使用
    memoryStore.update("generate-azure-bicep", project, "resource_naming.md", content)
    存储:
    • 每种资源类型的命名模式
    • 生成的名称示例
  4. 使用
    memoryStore.update("generate-azure-bicep", project, "customizations.md", content)
    存储:
    • 创建的自定义包装器模块
    • 与标准AVM用法的偏差
    • 特殊配置
验证:内存文件已创建/更新,包含所有相关信息

Compliance Checklist

合规性检查清单

Before completing this skill, verify:
  • User questions asked and answered (Step 5)
  • AVM modules identified and mapped to requirements (Step 6)
  • .azure/bicep/
    directory created with correct structure (Step 7)
  • main.bicep generated using AVM module references (Step 7)
  • bicepparams files created for all environments (Step 7)
  • Custom wrapper modules created if needed (Step 7)
  • Documentation generated (Step 7)
  • Templates customized with project-specific values (Step 8)
  • Bicep files validated (syntax and deployment) (Step 9)
  • Results presented to user with deployment instructions (Step 10)
  • Project memory updated (Step 11)

完成本技能之前,请验证:
  • 已向用户提问并得到回答(步骤5)
  • 已识别AVM模块并映射到需求(步骤6)
  • 已创建结构正确的
    .azure/bicep/
    目录(步骤7)
  • 已使用AVM模块引用生成main.bicep(步骤7)
  • 已为所有环境创建bicepparams文件(步骤7)
  • 已在需要时创建自定义包装器模块(步骤7)
  • 已生成文档(步骤7)
  • 已用项目特定的值自定义模板(步骤8)
  • 已验证Bicep文件(语法和部署)(步骤9)
  • 已向用户呈现结果并提供部署说明(步骤10)
  • 已更新项目内存(步骤11)

Best Practices

最佳实践

Azure Verified Modules

Azure验证模块

  1. Always use AVM modules - Don't rewrite what Microsoft provides
  2. Pin module versions - Use specific versions, not
    latest
  3. Use public registry -
    br/public:avm/...
    for stable, tested modules
  4. Check module documentation - Review parameters and examples before use
  5. Leverage module outputs - Pass resource IDs between modules
  6. Apply consistent tags - Use AVM's built-in tagging support
  1. 始终使用AVM模块 - 不要重复编写Microsoft已提供的内容
  2. 固定模块版本 - 使用特定版本,而非
    latest
  3. 使用公共注册表 -
    br/public:avm/...
    用于稳定、经过测试的模块
  4. 查看模块文档 - 在使用前查看参数和示例
  5. 利用模块输出 - 在模块之间传递资源ID
  6. 应用一致的标签 - 使用AVM内置的标签支持

Bicep Structure

Bicep结构

  1. One main.bicep - Single entry point for all environments
  2. Separate bicepparams - Environment-specific configurations
  3. Use modules directory - For custom wrapper modules only
  4. Document parameters - Clear descriptions for all params
  5. Define outputs - Make resource IDs available to callers
  6. Set deployment scope - Explicit
    targetScope
    declaration
  1. 一个main.bicep - 所有环境的单一入口点
  2. 分离的bicepparams - 环境特定的配置
  3. 使用modules目录 - 仅用于自定义包装器模块
  4. 记录参数 - 所有参数都有清晰的说明
  5. 定义输出 - 向调用者提供资源ID
  6. 设置部署范围 - 显式声明
    targetScope

Resource Naming

资源命名

  1. Follow Azure conventions - Use resource type abbreviations
  2. Include environment - Clear distinction between dev/staging/prod
  3. Use unique suffixes -
    uniqueString()
    for globally unique names
  4. Be consistent - Same pattern across all resources
  5. Document convention - Explain naming in README
  1. 遵循Azure规范 - 使用资源类型缩写
  2. 包含环境信息 - 清晰区分开发/测试/生产
  3. 使用唯一后缀 -
    uniqueString()
    用于全局唯一名称
  4. 保持一致 - 所有资源使用相同的模式
  5. 记录规范 - 在README中说明命名规则

Security

安全

  1. Use managed identities - Avoid storing credentials
  2. Enable diagnostic logging - Configure in AVM modules
  3. Apply least privilege - RBAC via AVM parameters
  4. Use private endpoints - Where applicable
  5. Enable encryption - Use AVM's security defaults

  1. 使用托管标识 - 避免存储凭据
  2. 启用诊断日志 - 在AVM模块中配置
  3. 应用最小权限原则 - 通过AVM参数配置RBAC
  4. 使用专用终结点 - 在适用的场景
  5. 启用加密 - 使用AVM的安全默认值

Additional Notes

附加说明

AVM Module Registry

AVM模块注册表

Modules are referenced using:
bicep
module resource 'br/public:avm/res/{provider}/{type}:{version}' = {
  // ...
}
模块引用格式:
bicep
module resource 'br/public:avm/res/{provider}/{type}:{version}' = {
  // ...
}

Finding Modules

查找模块

  • Browse: https://aka.ms/avm
  • Search: Use resource type (e.g., "storage account")
  • CLI:
    az bicep list-versions --module-path "br/public:avm/..."
  • 浏览:https://aka.ms/avm
  • 搜索:使用资源类型(例如“storage account”)
  • CLI:
    az bicep list-versions --module-path "br/public:avm/..."

Updating Modules

更新模块

  1. Check new versions:
    az bicep list-versions ...
  2. Review changelog for breaking changes
  3. Update version in main.bicep
  4. Test deployment in dev environment
  5. Promote to staging/production
  1. 检查新版本:
    az bicep list-versions ...
  2. 查看变更日志以了解破坏性变更
  3. 在main.bicep中更新版本
  4. 在开发环境中测试部署
  5. 推广到测试/生产环境

Custom Wrappers

自定义包装器

Create wrappers only when:
  • Need project-specific defaults
  • Combining multiple AVM modules
  • Adding custom logic on top of AVM
Otherwise, use AVM modules directly.

仅在以下情况创建包装器:
  • 需要项目特定的默认值
  • 组合多个AVM模块
  • 在AVM之上添加自定义逻辑
否则,请直接使用AVM模块。

Version History

版本历史

v1.1.0 (2025-07-15)

v1.1.0 (2025-07-15)

  • Phase 4 Migration: Replaced hardcoded
    ../../context/
    and
    ../../memory/
    paths with ContextProvider and MemoryStore interface calls
  • Added YAML frontmatter with context/memory declarations
  • Added Interface References section
  • 第4阶段迁移:将硬编码的
    ../../context/
    ../../memory/
    路径替换为ContextProvider和MemoryStore接口调用
  • 添加了包含上下文/内存声明的YAML前置元数据
  • 添加了接口引用部分

v1.0.0 (2025-11-18)

v1.0.0 (2025-11-18)

Initial Release
  • Complete Bicep generation using Azure Verified Modules
  • Support for all common Azure resources
  • Multi-environment support with bicepparams
  • Custom wrapper module generation
  • Resource naming convention support
  • Memory system for configuration tracking
  • Comprehensive context for AVM usage
初始发布
  • 使用Azure验证模块完成Bicep生成
  • 支持所有常见的Azure资源
  • 支持多环境,使用bicepparams
  • 自定义包装器模块生成
  • 资源命名规范支持
  • 用于配置跟踪的内存系统
  • 关于AVM使用的全面上下文