azure-deployment-preflight by github/awesome-copilot
npx skills add https://github.com/github/awesome-copilot --skill azure-deployment-preflight此技能在执行前验证 Bicep 部署,支持 Azure CLI (az) 和 Azure Developer CLI (azd) 工作流。
azd up、azd provision 或 az deployment 命令之前按顺序执行以下步骤。即使前一步骤失败,也继续下一步——将所有问题记录在最终报告中。
通过检查项目指示器来确定部署工作流:
检查 azd 项目 :在项目根目录中查找 azure.yaml
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
定位 Bicep 文件 :查找所有要验证的 .bicep 文件
infra/ 目录,然后是项目根目录infra/、deploy/、项目根目录)自动检测参数文件 :对于每个 Bicep 文件,查找匹配的参数文件:
<filename>.bicepparam (Bicep 参数 - 首选)<filename>.parameters.json (JSON 参数)parameters.json 或 parameters/<env>.json在尝试部署验证之前,运行 Bicep CLI 来检查模板语法:
bicep build <bicep-file> --stdout
需要捕获的内容:
如果 Bicep CLI 未安装:
根据步骤 1 中检测到的项目类型选择适当的验证。
使用 azd provision --preview 来验证部署:
azd provision --preview
如果指定了环境或多个环境存在:
azd provision --preview --environment <env-name>
根据 Bicep 文件的 targetScope 声明确定部署范围:
| 目标范围 | 命令 |
|---|---|
resourceGroup (默认) | az deployment group what-if |
subscription | az deployment sub what-if |
managementGroup | az deployment mg what-if |
tenant | az deployment tenant what-if |
首先使用 Provider 验证级别运行:
# 资源组范围 (最常见)
az deployment group what-if \
--resource-group <rg-name> \
--template-file <bicep-file> \
--parameters <param-file> \
--validation-level Provider
# 订阅范围
az deployment sub what-if \
--location <location> \
--template-file <bicep-file> \
--parameters <param-file> \
--validation-level Provider
# 管理组范围
az deployment mg what-if \
--location <location> \
--management-group-id <mg-id> \
--template-file <bicep-file> \
--parameters <param-file> \
--validation-level Provider
# 租户范围
az deployment tenant what-if \
--location <location> \
--template-file <bicep-file> \
--parameters <param-file> \
--validation-level Provider
回退策略:
如果 --validation-level Provider 因权限错误 (RBAC) 而失败,请使用 ProviderNoRbac 重试:
az deployment group what-if \
--resource-group <rg-name> \
--template-file <bicep-file> \
--validation-level ProviderNoRbac
在报告中记录回退情况——用户可能缺乏完整的部署权限。
解析 what-if 输出以对资源更改进行分类:
| 更改类型 | 符号 | 含义 |
|---|---|---|
| 创建 | + | 将创建新资源 |
| 删除 | - | 资源将被删除 |
| 修改 | ~ | 资源属性将更改 |
| 无变化 | = | 资源未更改 |
| 忽略 | * | 资源未分析 (达到限制) |
| 部署 | ! | 资源将被部署 (更改未知) |
对于修改的资源,捕获具体的属性更改。
在项目根目录中创建一个 Markdown 报告文件,命名为:
preflight-report.md使用 references/REPORT-TEMPLATE.md 中的模板结构。
报告部分:
在运行验证之前,收集:
| 信息 | 所需场景 | 如何获取 |
|---|---|---|
| 资源组 | az deployment group | 询问用户或检查现有的 .azure/ 配置 |
| 订阅 | 所有部署 | az account show 或询问用户 |
| 位置 | 订阅/管理组/租户范围 | 询问用户或使用配置中的默认值 |
| 环境 | azd 项目 | azd env list 或询问用户 |
如果缺少必需信息,请在继续之前提示用户。
有关详细的错误处理指南,请参阅 references/ERROR-HANDLING.md。
关键原则: 即使发生错误也继续验证。将所有问题记录在最终报告中。
| 错误类型 | 操作 |
|---|---|
| 未登录 | 在报告中记录,建议 az login 或 azd auth login |
| 权限被拒绝 | 回退到 ProviderNoRbac,在报告中记录 |
| Bicep 语法错误 | 包含所有错误,继续处理其他文件 |
| 工具未安装 | 在报告中记录,跳过该验证步骤 |
| 资源组未找到 | 在报告中记录,建议创建它 |
此技能使用以下工具:
az) - 建议使用 2.76.0+ 版本以支持 --validation-levelazd) - 用于具有 azure.yaml 的项目bicep) - 用于语法验证在开始前检查工具的可用性:
az --version
azd version
bicep --version
azure.yaml → azd 项目infra/main.bicep 和 infra/main.bicepparambicep build infra/main.bicep --stdoutazd provision --previewpreflight-report.md每周安装量
7.8K
代码仓库
GitHub 星标数
26.7K
首次出现
Jan 23, 2026
安全审计
安装于
codex7.7K
claude-code7.6K
gemini-cli7.3K
opencode7.3K
github-copilot7.3K
cursor7.3K
This skill validates Bicep deployments before execution, supporting both Azure CLI (az) and Azure Developer CLI (azd) workflows.
azd up, azd provision, or az deployment commandsFollow these steps in order. Continue to the next step even if a previous step fails—capture all issues in the final report.
Determine the deployment workflow by checking for project indicators:
Check for azd project : Look for azure.yaml in the project root
Locate Bicep files : Find all .bicep files to validate
infra/ directory first, then project rootinfra/, deploy/, project root)Auto-detect parameter files : For each Bicep file, look for matching parameter files:
<filename>.bicepparam (Bicep parameters - preferred)<filename>.parameters.json (JSON parameters)parameters.json or parameters/<env>.json in same directoryRun Bicep CLI to check template syntax before attempting deployment validation:
bicep build <bicep-file> --stdout
What to capture:
If Bicep CLI is not installed:
Choose the appropriate validation based on project type detected in Step 1.
Use azd provision --preview to validate the deployment:
azd provision --preview
If an environment is specified or multiple environments exist:
azd provision --preview --environment <env-name>
Determine the deployment scope from the Bicep file's targetScope declaration:
| Target Scope | Command |
|---|---|
resourceGroup (default) | az deployment group what-if |
subscription | az deployment sub what-if |
managementGroup | az deployment mg what-if |
tenant | az deployment tenant what-if |
Run with Provider validation level first:
# Resource Group scope (most common)
az deployment group what-if \
--resource-group <rg-name> \
--template-file <bicep-file> \
--parameters <param-file> \
--validation-level Provider
# Subscription scope
az deployment sub what-if \
--location <location> \
--template-file <bicep-file> \
--parameters <param-file> \
--validation-level Provider
# Management Group scope
az deployment mg what-if \
--location <location> \
--management-group-id <mg-id> \
--template-file <bicep-file> \
--parameters <param-file> \
--validation-level Provider
# Tenant scope
az deployment tenant what-if \
--location <location> \
--template-file <bicep-file> \
--parameters <param-file> \
--validation-level Provider
Fallback Strategy:
If --validation-level Provider fails with permission errors (RBAC), retry with ProviderNoRbac:
az deployment group what-if \
--resource-group <rg-name> \
--template-file <bicep-file> \
--validation-level ProviderNoRbac
Note the fallback in the report—the user may lack full deployment permissions.
Parse the what-if output to categorize resource changes:
| Change Type | Symbol | Meaning |
|---|---|---|
| Create | + | New resource will be created |
| Delete | - | Resource will be deleted |
| Modify | ~ | Resource properties will change |
| NoChange | = | Resource unchanged |
| Ignore | * | Resource not analyzed (limits reached) |
For modified resources, capture the specific property changes.
Create a Markdown report file in the project root named:
preflight-report.mdUse the template structure from references/REPORT-TEMPLATE.md.
Report sections:
Before running validation, gather:
| Information | Required For | How to Obtain |
|---|---|---|
| Resource Group | az deployment group | Ask user or check existing .azure/ config |
| Subscription | All deployments | az account show or ask user |
| Location | Sub/MG/Tenant scope | Ask user or use default from config |
| Environment | azd projects | azd env list or ask user |
If required information is missing, prompt the user before proceeding.
See references/ERROR-HANDLING.md for detailed error handling guidance.
Key principle: Continue validation even when errors occur. Capture all issues in the final report.
| Error Type | Action |
|---|---|
| Not logged in | Note in report, suggest az login or azd auth login |
| Permission denied | Fall back to ProviderNoRbac, note in report |
| Bicep syntax error | Include all errors, continue to other files |
| Tool not installed | Note in report, skip that validation step |
| Resource group not found | Note in report, suggest creating it |
This skill uses the following tools:
az) - Version 2.76.0+ recommended for --validation-levelazd) - For projects with azure.yamlbicep) - For syntax validationCheck tool availability before starting:
az --version
azd version
bicep --version
azure.yaml → azd projectinfra/main.bicep and infra/main.bicepparambicep build infra/main.bicep --stdoutazd provision --previewpreflight-report.md in project rootWeekly Installs
7.8K
Repository
GitHub Stars
26.7K
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex7.7K
claude-code7.6K
gemini-cli7.3K
opencode7.3K
github-copilot7.3K
cursor7.3K
97,600 周安装
| Deploy | ! | Resource will be deployed (changes unknown) |