Skip to content

Instantly share code, notes, and snippets.

@riosengineer
Last active September 23, 2024 13:50
Show Gist options
  • Select an option

  • Save riosengineer/6de9452fd57eed5d5e081235ef620911 to your computer and use it in GitHub Desktop.

Select an option

Save riosengineer/6de9452fd57eed5d5e081235ef620911 to your computer and use it in GitHub Desktop.
Git diff for Bicep templates with ACE (Azure Cost Estimator) run
# get the latest changed bicep files - change bicep/infra folder for your needs
$files = (git diff origin/main --name-only -- bicep/infra | Where-Object {$_.EndsWith('.bicep')})
New-Item -Name "md-reports" -ItemType Directory
if ($files.count -ge 1) {
# foreach bicep file run cost estimator ACE
foreach ($file in $files) {
# amend bicepparam name as you see fit
$params = $file | Split-Path | Get-ChildItem -Recurse -Filter *prod.bicepparam
Write-Host "##[debug] $file found with parameter file $params...running cost estimator"
./azure-cost-estimator $file YOUR_SUB_GUID bicep-estimator --parameters $params --currency GBP --outputFormat Table --generate-markdown-output --generateJsonOutput true --generateHtmlOutput true
Copy-Item -Path ".\ace_*.md" -Destination md-reports
}
Write-Host "$($files.count) Bicep files found"
Write-Host "$params"
}
else {
Write-Host "No Bicep updates"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment