# Preflight Report Template

Use this template structure when generating `preflight-report.md` in the project root.

---

## Template

```markdown
# Azure Deployment Preflight Report

**Generated:** {timestamp}
**Status:** {overall-status}

---

## Summary

| Property | Value |
|----------|-------|
| **Template File(s)** | {bicep-files} |
| **Parameter File(s)** | {param-files-or-none} |
| **Project Type** | {azd-project | standalone-bicep} |
| **Deployment Scope** | {resourceGroup | subscription | managementGroup | tenant} |
| **Target** | {resource-group-name | subscription-name | mg-id} |
| **Validation Level** | {Provider | ProviderNoRbac} |

### Validation Results

| Check | Status | Details |
|-------|--------|---------|
| Bicep Syntax | {✅ Pass | ❌ Fail | ⚠️ Warnings | ⏭️ Skipped} | {details} |
| What-If Analysis | {✅ Pass | ❌ Fail | ⏭️ Skipped} | {details} |
| Permission Check | {✅ Pass | ⚠️ Limited | ❌ Fail} | {details} |

---

## Tools Executed

### Commands Run

| Step | Command | Exit Code | Duration |
|------|---------|-----------|----------|
| 1 | `{command}` | {0 | non-zero} | {duration} |
| 2 | `{command}` | {0 | non-zero} | {duration} |

### Tool Versions

| Tool | Version |
|------|---------|
| Azure CLI | {version} |
| Bicep CLI | {version} |
| Azure Developer CLI | {version-or-n/a} |

---

## Issues

{if-no-issues}
✅ **No issues found.** The deployment is ready to proceed.
{end-if}

{if-issues-exist}
### Errors

{for-each-error}
#### ❌ {error-title}

- **Severity:** Error
- **Source:** {bicep-build | what-if | permissions}
- **Location:** {file-path}:{line}:{column} (if applicable)
- **Message:** {error-message}
- **Remediation:** {suggested-fix}
- **Documentation:** {link-if-available}

{end-for-each}

### Warnings

{for-each-warning}
#### ⚠️ {warning-title}

- **Severity:** Warning
- **Source:** {source}
- **Message:** {warning-message}
- **Recommendation:** {suggested-action}

{end-for-each}
{end-if}

---

## What-If Results

{if-what-if-succeeded}

### Change Summary

| Change Type | Count |
|-------------|-------|
| 🆕 Create | {count} |
| 📝 Modify | {count} |
| 🗑️ Delete | {count} |
| ✓ No Change | {count} |
| ⚠️ Ignore | {count} |

### Resources to Create

{if-resources-to-create}
| Resource Type | Resource Name |
|---------------|---------------|
| {type} | {name} |
{end-if}

{if-no-resources-to-create}
*No resources will be created.*
{end-if}

### Resources to Modify

{if-resources-to-modify}
#### {resource-type}/{resource-name}

| Property | Current Value | New Value |
|----------|---------------|-----------|
| {property-path} | {current} | {new} |

{end-if}

{if-no-resources-to-modify}
*No resources will be modified.*
{end-if}

### Resources to Delete

{if-resources-to-delete}
| Resource Type | Resource Name |
|---------------|---------------|
| {type} | {name} |

> ⚠️ **Warning:** Resources listed for deletion will be permanently removed.
{end-if}

{if-no-resources-to-delete}
*No resources will be deleted.*
{end-if}

{end-if-what-if-succeeded}

{if-what-if-failed}
### What-If Analysis Failed

The what-if operation could not complete. See the Issues section for details.
{end-if}

---

## Recommendations

{generate-based-on-findings}

1. {recommendation-1}
2. {recommendation-2}
3. {recommendation-3}

---

## Next Steps

{if-all-passed}
The preflight validation passed. You can proceed with deployment:

**For azd projects:**
```bash
azd provision
# or
azd up
```

**For standalone Bicep:**
```bash
az deployment group create \
  --resource-group {rg-name} \
  --template-file {bicep-file} \
  --parameters {param-file}
```
{end-if}

{if-issues-exist}
Please resolve the issues listed above before deploying. After fixes:

1. Re-run preflight validation to verify fixes
2. Proceed with deployment once all checks pass
{end-if}

---

*Report generated by Azure Deployment Preflight Skill*
```

---

## Status Values

### Overall Status

| Status | Meaning | Visual |
|--------|---------|--------|
| **Pass** | All checks succeeded, safe to deploy | ✅ |
| **Pass with Warnings** | Checks succeeded but review warnings | ⚠️ |
| **Fail** | One or more checks failed | ❌ |

### Individual Check Status

| Status | Meaning |
|--------|---------|
| ✅ Pass | Check completed successfully |
| ❌ Fail | Check found errors |
| ⚠️ Warnings | Check passed with warnings |
| ⏭️ Skipped | Check was skipped (tool unavailable, etc.) |

---

## Example Report

```markdown
# Azure Deployment Preflight Report

**Generated:** 2026-01-16T14:32:00Z
**Status:** ⚠️ Pass with Warnings

---

## Summary

| Property | Value |
|----------|-------|
| **Template File(s)** | `infra/main.bicep` |
| **Parameter File(s)** | `infra/main.bicepparam` |
| **Project Type** | azd project |
| **Deployment Scope** | subscription |
| **Target** | my-subscription |
| **Validation Level** | Provider |

### Validation Results

| Check | Status | Details |
|-------|--------|---------|
| Bicep Syntax | ✅ Pass | No errors found |
| What-If Analysis | ⚠️ Warnings | 1 resource ignored due to nested template limits |
| Permission Check | ✅ Pass | Full deployment permissions verified |

---

## Tools Executed

### Commands Run

| Step | Command | Exit Code | Duration |
|------|---------|-----------|----------|
| 1 | `bicep build infra/main.bicep --stdout` | 0 | 1.2s |
| 2 | `azd provision --preview --environment dev` | 0 | 8.4s |

### Tool Versions

| Tool | Version |
|------|---------|
| Azure CLI | 2.76.0 |
| Bicep CLI | 0.25.3 |
| Azure Developer CLI | 1.9.0 |

---

## Issues

### Warnings

#### ⚠️ Nested Template Limit Reached

- **Severity:** Warning
- **Source:** what-if
- **Message:** 1 resource was ignored because nested template expansion limits were reached
- **Recommendation:** Review the ignored resource manually after deployment

---

## What-If Results

### Change Summary

| Change Type | Count |
|-------------|-------|
| 🆕 Create | 3 |
| 📝 Modify | 1 |
| 🗑️ Delete | 0 |
| ✓ No Change | 2 |
| ⚠️ Ignore | 1 |

### Resources to Create

| Resource Type | Resource Name |
|---------------|---------------|
| Microsoft.Resources/resourceGroups | rg-myapp-dev |
| Microsoft.Storage/storageAccounts | stmyappdev |
| Microsoft.Web/sites | app-myapp-dev |

### Resources to Modify

#### Microsoft.KeyVault/vaults/kv-myapp-dev

| Property | Current Value | New Value |
|----------|---------------|-----------|
| properties.sku.name | standard | premium |
| tags.environment | staging | dev |

### Resources to Delete

*No resources will be deleted.*

---

## Recommendations

1. Review the storage account name `stmyappdev` to ensure it meets naming requirements
2. Confirm the Key Vault SKU upgrade from standard to premium is intentional
3. The ignored nested template resource should be verified after deployment

---

## Next Steps

The preflight validation passed with warnings. Review the warnings above, then proceed:

```bash
azd provision --environment dev
```

---

*Report generated by Azure Deployment Preflight Skill*
```

---

## Formatting Guidelines

1. **Use consistent emoji** for visual scanning
2. **Include line numbers** when referencing Bicep errors
3. **Provide actionable remediation** for each issue
4. **Link to documentation** when available
5. **Order issues by severity** (errors first, then warnings)
6. **Include command examples** in Next Steps
