Get subscription ID with Azure CLI
Use this Azure CLI command if you don't want to access the Azure portal every time you need a subscription ID.
az account show \
--query id \
--output tsv
Or, assign the subscription ID to a variable to use later in another CLI command.
SUBSCRIPTION_ID=$(az account show \
--query id \
--output tsv)
echo $SUBSCRIPTION_ID
For more details, click on the link below to access the official documentation
Member discussion