The easiest way to pass variables to any CLI command is by using environment variables
An environment variable is a variable whose value is set outside the program, typically through a functionality built into the operating system or microservice. An environment variable is made up of a name/value pair, and any number may be created and available for reference at a point in time.
ExampleBelow you can find examples in bashBash and CMD:
Set new environment variable-Bash-
Set new environment variable-
export LOCATION=westeurope
Print the environment variable- Print the environment variable-
echo ${LOCATION}
AZ CLI example- AZ CLI example-
az group create --name foo --location ${LOCATION}
Example in CMD:CMD-
Set new environment variable-
set LOCATION=westeurope
Print the environment variable-
echo %LOCATION%
AZ CLI example-
az group create --name foo --location %LOCATION%