Set default parameters

The Azure CLI commands az account set and az config provide the ability to retain default parameter values for Azure Sphere commands. This removes the need to continually retype common parameters. For example, subscription, resource-group, and catalog are required parameters in many commands.

When you set the default parameter values, you reduce redundancy and can significantly shorten command syntax.

Default parameters can always be overridden by explicitly entering the desired parameter.

Set the default subscription

After logging in, you see a list of subscriptions associated with your Azure account. The subscription information with isDefault: true is the currently activated subscription after logging in. To select another subscription, use the az account set command with the subscription ID you wish to switch to. For more information about subscription selection, see How to manage Azure subscriptions with the Azure CLI.

Tip

Use the az account show or az account list commands to see the subscription you're currently using or to get a list of available subscriptions.

Set the default resource group and Azure Sphere catalog

Aside from the subscription, other defaults for Azure CLI are set with the az config set command. This command takes a space-separated list of key=value pairs as an argument. The provided values are used by the Azure Sphere commands in place of required arguments.

Tip

Use the az config get command to see your current configuration.

The following table contains a list of available configuration keys.

Parameter name Description Example
defaults.group The default resource group to use for all commands.
Replaces --resource-group parameter.
az config set defaults.group=<name>
defaults.sphere.catalog The default catalog to use for all Azure Sphere commands.
Replaces --catalog parameter.
az config set defaults.sphere.catalog=<name>

As an example, here's how you would set the default resource group and catalog for all commands. Set the default resource group to MyResourceGroup and catalog to MyCatalog.

az config set defaults.group=MyResourceGroup defaults.sphere.catalog=MyCatalog

A full list of configuration settings can be found in the Azure CLI configuration documentation. Note that some configuration settings are not applicable to Azure Sphere. For example the defaults.location setting is ignored, as Azure Sphere is a global service.

Troubleshooting

An Azure Sphere catalog belongs to a resource group, which belongs to a subscription. You may see error messages indicating a resource cannot be found even when working with resources that you know exist, if the combination of default and specified parameters do not match. For example, if the default or specified resource group does not belong to the default or specified subscription, you may see the error "Resource group 'Name' could not be found.".