What are Azure CLI Extensions?
Azure Command-Line Interface (CLI) extensions add commands that are not part of the core Azure CLI. Extensions allow you to develop and share new commands that can be installed and used just like built-in commands.
Extensions are useful for:
- Providing access to new or preview Azure services.
- Creating custom commands to automate complex or repetitive tasks.
- Extending existing commands with new functionality.
Finding Extensions
You can find available Azure CLI extensions in the official Azure CLI extension repository. The az extension list-available
command can list extensions that are available for installation.
az extension list-available --output table
You can also search for specific extensions using keywords:
az extension list-available --query "[?contains(name, 'kubernetes')]" --output table
Installing Extensions
To install an extension, use the az extension add
command followed by the name of the extension.
az extension add --name <extension-name>
For example, to install the aks-preview
extension:
az extension add --name aks-preview
Note: Some extensions might require preview versions of the Azure CLI. Always check the extension's documentation for any prerequisites.
Managing Extensions
The Azure CLI provides commands to manage your installed extensions:
- List installed extensions:
az extension list
- Show details about an extension:
az extension show --name <extension-name>
- Update an extension:
az extension update --name <extension-name>
- Remove an extension:
az extension remove --name <extension-name>
# List all installed extensions
az extension list --output table
# Remove the aks-preview extension
az extension remove --name aks-preview
Developing Extensions
Developing your own Azure CLI extension is a powerful way to tailor the CLI to your specific needs. Extensions are typically developed in Python.
Key steps involved in development:
- Set up your development environment: Ensure you have Python and the Azure CLI installed.
- Create the extension structure: Follow the recommended project layout.
- Write your command logic: Implement your commands using Python.
- Define command metadata: Use YAML files to describe your commands, arguments, and help text.
- Package and test: Package your extension and test it thoroughly.
Important: For detailed guidance on developing Azure CLI extensions, please refer to the official Azure CLI extension development documentation.
You can find the official development guide here.
Extension Examples
Here are a few popular Azure CLI extensions:
aks-preview
: Provides access to the latest preview features for Azure Kubernetes Service.azure-iot
: Commands for managing Azure IoT Hub and Device Provisioning Service.connectedk8s
: Manages Azure Arc enabled Kubernetes clusters.
Explore the Azure CLI Extensions GitHub repository for more examples and contributions.