Azure-Samples / acme-fitness-store

Sample - how to deploy Spring Boot apps to Azure?
https://docs.microsoft.com/en-us/azure/spring-cloud/overview
MIT License
84 stars 157 forks source link

deploy.sh script should not change default az cli settings #44

Open asaikali opened 2 years ago

asaikali commented 2 years ago

Currently the ./deploy.sh script makes a call to the function

function configure_defaults() {
  echo "Configure azure defaults resource group: $RESOURCE_GROUP and spring $SPRING_APPS_SERVICE"
  az configure --defaults group=$RESOURCE_GROUP spring=$SPRING_APPS_SERVICE location=${REGION}
}

It is surprising that the script changes the defaults settings for the az cli, it is better if the script uses the passed in args -r, -s, -g without changing defaults

https://github.com/Azure-Samples/acme-fitness-store/blob/dd52c7f8fd3d76b074a6cf49340e9437b3e26d88/azure/deploy.sh#L30

clarenceb commented 2 years ago

Also, in the Create Azure Spring Apps service instance section of the README, it says to configure global defaults:

az configure --defaults \
    group=${RESOURCE_GROUP} \
    location=${REGION} \
    spring=${SPRING_APPS_SERVICE}

Personally, I think this is a bad idea and worse in the configure_defaults function mentioned above.

I prefer using a local scope for defaults with configure this file .azure/config without changing global defaults:

az configure --scope local --defaults \
    group=${RESOURCE_GROUP} \
    location=${REGION} \
    spring=${SPRING_APPS_SERVICE}

However, this is more useful for interactive use. For scripting, as @asaikali suggested above, it's probably better to just pass in args -r, -s, -g without changing defaults.