Created
July 11, 2021 12:25
-
-
Save rick-roche/57c90abae06630060afce1e76372b13b to your computer and use it in GitHub Desktop.
Azure - Lint, validate, create infra in Azure from Bicep templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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