Skip to content

Instantly share code, notes, and snippets.

@rick-roche
Created July 11, 2021 12:25
Show Gist options
  • Save rick-roche/57c90abae06630060afce1e76372b13b to your computer and use it in GitHub Desktop.
Save rick-roche/57c90abae06630060afce1e76372b13b to your computer and use it in GitHub Desktop.
Azure - Lint, validate, create infra in Azure from Bicep templates
#!/bin/bash
RG=replace-with-your-rg
SUB=replace-with-your-sub
op=$1 # lint, validate, create
main_shared=$2
if [ "$main_shared" == 'main' ]; then path='./infra' && filename='main.bicep'; fi
if [ "$main_shared" == 'shared' ]; then path='./shared-infra' && filename='*.bicep'; fi
lint () {
az bicep build --file "$f" --stdout
}
validate () {
az deployment group validate --resource-group "$RG" --subscription "$SUB" -f "$1" -p env=dev
}
create () {
az deployment group create --resource-group "$RG" --subscription "$SUB" -f "$1" -p env=dev
}
for f in $(find "$path" -name "$filename") ; do
echo "$f"
$op "$f"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment