az
az
tool on LocalStack2 minute read
Introduction
The Azure CLI tool (az
) is a tool that allows you to manually create and mange Azure resources.
This guide will show you how to use it to interact with LocalStack.
Getting started
This guide is designed for users who are new to LocalStack for Azure emulator and assumes basic knowledge of how the Azure CLI works. We will demonstrate how to create, show and delete an Azure resource group.
Install the packages
Run the following command to install the required packages:
$ pip install azlocal
You now have access to the following LocalStack tools:
CLI tool | LocalStack tool | Purpose |
---|---|---|
az | azlocal | Interact with Azure resources |
azd | azdlocal | Deploy ARM/Bicep templates |
terraform | tflocal | Deploy Terraform templates |
func | funclocal | Deploy Azure Functions |
The LocalStack variants are wrappers around the existing tools, so you keep the full functionality of the original tool - it will just redirect all commands to the running LocalStack Emulator.
Setup the az CLI
To make sure the az
tool sends requests to the Azure Emulator REST API, run the following command:
$ azlocal start_interception
Create and manage the Resource Group
Run the following command to create a resource group in the Emulator:
$ az group create --name MyResourceGroup --location westeurope
To check the resource group details, run the following command:
$ az group show --name MyResourceGroup
To delete the resource group, run the following command:
$ az group delete --name MyResourceGroup --yes
Teardown
When you’re done using the Azure Emulator, you can run the following command:
$ azlocal stop_interception
The az
CLI tool will now communicate with the Azure REST API on future invocations.
Conclusion
The above examples show a very small sample of what is possible, with only a subset of the available commands and arguments. The LocalStack Azure Emulator supports much more services and features - see our API Coverage page to get a better understand of what is supported.
If you encounter a situation where the Emulator does not behave the same as Azure does, please reach out to us! We aim to provide a 100% parity across the board, but we’re not there yet - so please let us know if we’ve missed anything.
Happy coding!