Skip to main content
Version: Next

Scripting Standards

Canonical reference: Scripting Standards (full)
Applies to: All AzureLocal repositories
Last Updated: 2026-03-17


Script Naming

Script TypePatternExample
PowerShell CoreVerb-Noun.ps1Deploy-Solution.ps1
Azure PowerShellVerb-AzResource.ps1New-AzKeyVault.ps1
Azure CLI (PowerShell)az-verb-resource.ps1az-deploy-resource.ps1
Azure CLI (Bash)az-verb-resource.shaz-deploy-resource.sh
Standalone (no config)Verb-Noun-Standalone.ps1Deploy-Solution-Standalone.ps1
Remote/orchestrationInvoke-<Task>.ps1Invoke-Deployment.ps1

Config-Driven vs Standalone

ModeConfig FileDependenciesUse Case
Config-driven (Options 2-4)config/variables.ymlConfig loader, helpers, Key VaultMulti-environment automation, CI/CD
Standalone (Option 5)Inline #region CONFIGURATIONNoneDemos, single-use, external sharing

Config-Driven Rules

  • Read all values from config/variables.yml — never hardcode
  • Accept -ConfigPath parameter (auto-discover if not provided)
  • Use helper functions: ConvertFrom-Yaml, Resolve-KeyVaultRef, logging

Standalone Rules

  • All variables in #region CONFIGURATION block at top
  • Variable names match variables.yml paths (e.g., $subscription_id)
  • Zero external dependencies — copy, paste, run

Invoke- Script Requirements

Required Parameters

ParameterTypeDefaultPurpose
-ConfigPath[string]""Path to variables.yml
-Credential[PSCredential]$nullOverride credential resolution
-TargetNode[string[]]@() (all)Limit to specific node(s)
-WhatIf[switch]$falseDry-run mode
-LogPath[string]"" (auto)Override log file path

All Invoke- scripts must use [CmdletBinding()] to enable -Verbose and -Debug.

Credential Resolution Order

  1. -Credential parameter — if passed, use immediately
  2. Key Vault — read from config; try Az.KeyVault, fall back to az CLI
  3. Interactive promptGet-Credential with username pre-filled

Logging

  • Log to ./logs/<task-name>/<timestamp>.log
  • Use Write-Verbose for detailed output
  • Log format: [YYYY-MM-DD HH:MM:SS] [LEVEL] Message

Solution Script Conventions

ConventionRule
IaC toolsTerraform, Bicep, ARM, PowerShell, Ansible
Config sourceconfig/variables.yml (single source of truth)
Parameter derivationAll tool-specific param files derived from central config
IdempotencyAll scripts must be safe to re-run