Skip to content

Instantly share code, notes, and snippets.

@caseywatson
Last active February 21, 2023 15:46
Show Gist options
  • Select an option

  • Save caseywatson/fe3cb797ae2b022d20fd44f8d6b99e7f to your computer and use it in GitHub Desktop.

Select an option

Save caseywatson/fe3cb797ae2b022d20fd44f8d6b99e7f to your computer and use it in GitHub Desktop.
Gets functionapp settings as an environment variable JSON object
#!/bin/bash
app_name=$1
resource_group=$2
settings=$(az functionapp config appsettings list \
--resource-group "$resource_group" \
--name "$app_name")
if [[ $? == 0 ]]; then # az command succeeded
printf "{ "
echo $settings | jq -rc '.[]' | while read setting; do
name=$(echo "$setting" | jq -r ".name")
value=$(echo "$setting" | jq -r ".value")
[[ -z $setting_written ]] || printf ", "
printf "\"$name\": \"$value\""
setting_written=1
done
printf " }\n"
else
echo "Unable to get app settings."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment