Aide-mémoire Azure CLI

Référence consultable des commandes Azure CLI : connexion, groupes de ressources, VM, stockage, applications web et AKS, avec chaque paramètre expliqué.

S’exécute dans votre navigateur · rien n’est envoyéNouveau

31 commandes

Login & subscriptions

az loginSign in to Azure interactively, opening a browser window for authentication.

On a machine without a browser (a server or container), use "az login --use-device-code" instead: it prints a short code to enter on a second device.

Options

--use-device-codeSign in using a code entered on another device, for machines without a browser.
--tenant <id>Sign in to a specific Microsoft Entra tenant instead of the default one.
--service-principal -u <id> -p <secret-or-cert> --tenant <id>Sign in as a service principal, for scripts and CI/CD instead of a human.
az account listList every subscription the signed-in account has access to, and show which one is currently active.

Exemple

az account list --output table
az account set --subscription <name-or-id>Switch the active subscription that subsequent commands operate on.

Needed whenever a sign-in has access to more than one subscription and the default one is not the right target.

az account showShow the currently active subscription, tenant ID and signed-in account.

The quickest way to confirm which subscription a command would run against before doing something that matters.

az configure --defaults group=<name> location=<region>Set default values (resource group, location, and more) so later commands can omit those flags.

Exemple

az configure --defaults group=my-rg location=westeurope
az <command> --output <format>Set the output format for a single command.

Options

jsonThe default. Full structured output.
jsoncColorized JSON, for an interactive terminal.
tableA human-readable ASCII table, using a fixed set of columns per command.
tsvTab-separated values, convenient for shell scripting.
yamlYAML output.
noneSuppress output entirely.
az <command> --query "<JMESPath>"Filter and reshape the JSON response using a JMESPath expression before it is formatted for output.

Exemple

az vm list --query "[].{Name:name, Size:hardwareProfile.vmSize}" --output table

Resource groups

az group create --name <name> --location <region>Create a new resource group, the container that holds related resources in one region and lifecycle.

Exemple

az group create --name my-rg --location westeurope

Options

--name -n <name>Name of the resource group.
--location -l <region>Azure region, for example westeurope, eastus. See "az account list-locations" for the full list.
--tags <key=value> [...]Tags to apply to the resource group.
az group list --output tableList every resource group in the active subscription.

Does not show resources inside each group; use "az resource list --resource-group <name>" for that.

az group delete --name <name>Delete a resource group and every resource inside it.

Options

--yes -ySkip the interactive confirmation prompt.
--no-waitReturn immediately instead of waiting for the deletion to finish.
Attention: This deletes every resource in the group, including VMs, disks, storage accounts and their data. There is no undo.
az resource list --resource-group <name>List every resource inside a resource group, across all resource types.

Omit --resource-group to list every resource in the whole subscription instead.

Virtual machines

az vm create --resource-group <name> --name <vm-name> --image <image>Create a virtual machine, and by default also a virtual network, public IP, network security group and NIC if none are specified.

Exemple

az vm create --resource-group my-rg --name my-vm --image Ubuntu2404 --size Standard_B2s --admin-username azureuser --generate-ssh-keys

Options

--resource-group -g <name>Resource group to create the VM in. Required.
--name -n <name>Name of the virtual machine. Required.
--image <urn-or-alias>OS image, as an alias (for example Ubuntu2404), a full URN "Publisher:Offer:Sku:Version", or the ID of a custom/shared image. Required unless --attach-os-disk is used.
--size <vm-size>VM size (SKU), for example Standard_B2s, Standard_D2s_v5. Defaults to Standard_DS1_v2 if omitted.
--admin-username <name>Username for the VM. Defaults to the current OS username, falling back to azureuser if that name is reserved.
--admin-password <password>Password for the VM, when --authentication-type is password. Must meet Azure's complexity requirements.
--authentication-type <all|password|ssh>Defaults to ssh for Linux and password for Windows.
--generate-ssh-keysGenerate a new SSH key pair if none exists yet in ~/.ssh, and use it for the VM. Reuses an existing key pair if one is already there.
--vnet-name / --subnet <name>Existing virtual network and subnet to place the VM in. Creates new ones with default settings if omitted.
--nsg <name>Network security group to create (default) or attach by name/ID. Use --nsg "" for none.
--nsg-rule <RDP|SSH|NONE>Inbound rule to open on a newly created NSG. Defaults to SSH on Linux, RDP on Windows.
--public-ip-sku <Basic|Standard>SKU of the public IP created for the VM. Standard is required for availability zones.
--data-disk-sizes-gb <size> [...]Create one or more empty managed data disks of the given sizes in GB.
--no-waitReturn immediately instead of waiting for the VM to finish provisioning.
Attention: Without --nsg-rule NONE, the default NSG rule opens SSH (22) or RDP (3389) to the internet. Restrict the source address range for anything beyond a quick test.
az vm list --output tableList VMs in the active subscription (or a resource group, with --resource-group), without their live power state.

For the current running/stopped state of each VM, use "az vm list --show-details" (slower, since it queries each VM individually) or "az vm get-instance-view".

az vm list-ip-addresses --resource-group <name> --output tableShow the private and public IP addresses of VMs in a resource group.

Faster than reading IPs out of the full "az vm show" output when all you need is the addresses.

az vm start --resource-group <name> --name <vm-name>Start a stopped VM. Use "az vm stop" to shut it down (still billed for allocated compute), or "az vm deallocate" to also release the compute allocation and stop that billing.

A VM stopped with "az vm stop" keeps its reserved hardware and is still billed. "az vm deallocate" releases the hardware, stops compute billing, but can change the public IP unless it is a Standard SKU static IP.

az vm delete --resource-group <name> --name <vm-name>Delete a VM. By default this does not delete its disks, NIC or public IP; those become orphaned resources still being billed.

Options

--yes -ySkip the confirmation prompt.
--force-deletionSkip the graceful shutdown and force-delete the VM.
Attention: Deleting a VM leaves its OS disk, data disks, NIC and public IP behind by default. Clean those up separately with "az disk delete" / "az network nic delete" / "az network public-ip delete" or they keep incurring cost.
az vm run-command invoke --resource-group <name> --name <vm-name> --command-id RunShellScript --scripts "<script>"Run a shell (Linux) or PowerShell (Windows, with --command-id RunPowerShellScript) script inside a VM without needing SSH or RDP access.

Runs through the Azure VM agent, so it works even when network security group rules block direct SSH/RDP from your location.

Storage

az storage account create --name <name> --resource-group <name> --sku <sku>Create a storage account, the parent resource for blob containers, file shares, queues and tables.

Options

--sku <sku>Replication and performance tier, for example Standard_LRS, Standard_GRS, Premium_LRS.
--kind <kind>Account kind, for example StorageV2 (default, recommended) or BlockBlobStorage.
--allow-blob-public-access <false|true>Whether anonymous public read access to blobs can be enabled at all. Defaults to false on new accounts.
Attention: Storage account names must be globally unique across all of Azure, 3-24 characters, lowercase letters and numbers only.
az storage container create --name <name> --account-name <account> --auth-mode loginCreate a blob container inside a storage account.

Options

--auth-mode <key|login>How to authorize the data operation: "key" uses the storage account key, "login" uses your signed-in Microsoft Entra identity (recommended, needs an RBAC role like Storage Blob Data Contributor).
--public-access <off|blob|container>Anonymous access level for the container. Defaults to off.
az storage blob upload --account-name <account> --container-name <container> --name <blob-name> --file <local-path> --auth-mode loginUpload a single local file as a blob.

Exemple

az storage blob upload --account-name mystorage --container-name site --name index.html --file ./dist/index.html --auth-mode login --overwrite

Options

--file <path>Local file to upload.
--name -n <blob-name>Name the blob will have in the container.
--overwriteReplace the blob if one with the same name already exists. Without it, the upload fails if the blob exists.
--auth-mode <key|login>Same as on container create.
az storage blob upload-batch --destination <container> --account-name <account> --source <local-dir> --auth-mode loginUpload every file in a local directory (optionally recursive) to a container in one command.

Options

--destination <container>Target container name.
--source <path>Local directory to upload from.
--pattern "<glob>"Only upload files matching this glob pattern.
--overwriteReplace blobs that already exist with the same name.
az storage blob list --account-name <account> --container-name <container> --auth-mode login --output tableList the blobs in a container.

Options

--prefix <value>Only list blobs whose name starts with this prefix.

Web apps

az appservice plan create --name <name> --resource-group <name> --sku <sku>Create an App Service plan, the compute tier (and billing unit) that one or more web apps run on.

Options

--sku <sku>Pricing tier, for example F1 (free), B1 (basic), P1V3 (premium).
--is-linuxCreate a Linux plan instead of the default Windows plan. Required for most container and Node/Python/PHP runtimes.
az webapp create --name <name> --resource-group <name> --plan <plan> --runtime <runtime>Create a web app on an existing App Service plan.

Exemple

az webapp create --name my-app --resource-group my-rg --plan my-plan --runtime "NODE:20-lts"

Options

--runtime <stack:version>Managed runtime stack, for example "NODE:20-lts", "PYTHON:3.12". Run "az webapp list-runtimes" to see current options.
--deployment-container-image-name <image>Use a container image instead of a managed runtime.
Attention: Web app names must be globally unique; the app becomes reachable at https://<name>.azurewebsites.net.
az webapp up --name <name> --resource-group <name> --runtime <runtime>A convenience command that creates the resource group, plan and web app (whichever do not already exist) and deploys the current folder in one step.

Good for quickly getting a project online; for repeatable deployments, prefer separate create/deploy steps or infrastructure as code.

az webapp deploy --resource-group <name> --name <app-name> --src-path <file>Deploy a zip, war, jar or static file to an existing web app.

Options

--src-path <path>Local package to deploy.
--type <zip|war|jar|static|startup>What kind of artifact is being deployed. Inferred from the file extension if omitted.
az webapp log tail --resource-group <name> --name <app-name>Stream live application and web server logs from a running web app to the terminal.

Requires log streaming to be enabled first with "az webapp log config --application-logging filesystem".

AKS (Kubernetes)

az aks create --resource-group <name> --name <cluster-name> --node-count <n> --generate-ssh-keysCreate a managed Kubernetes cluster.

Exemple

az aks create --resource-group my-rg --name my-cluster --node-count 2 --node-vm-size Standard_B2s --generate-ssh-keys

Options

--node-count <n>Number of nodes in the default node pool.
--node-vm-size <size>VM size for the nodes in the default node pool.
--generate-ssh-keysGenerate a new SSH key pair if none exists, needed for node access and required by the command if no key is configured.
--enable-cluster-autoscaler --min-count <n> --max-count <n>Automatically scale the node pool between these bounds based on load.
--network-plugin <azure|kubenet|none>CNI used for pod networking. azure gives pods IPs from the VNet; kubenet is simpler but has more limitations at scale.
--attach-acr <registry-name>Grant the cluster pull access to an existing Azure Container Registry.
az aks get-credentials --resource-group <name> --name <cluster-name>Download the cluster's kubeconfig and merge it into your local kubectl config, so kubectl can target this cluster.

Options

--adminGet cluster administrator credentials instead of the regular user credentials (bypasses Entra ID authentication, if enabled).
--overwrite-existingOverwrite an existing context of the same name instead of failing.
az aks scale --resource-group <name> --name <cluster-name> --node-count <n>Change the number of nodes in the default node pool.

For additional node pools beyond the default one, use "az aks nodepool scale" with --nodepool-name instead.

az aks delete --resource-group <name> --name <cluster-name>Delete an AKS cluster and its node pools.

Options

--yes -ySkip the confirmation prompt.
Attention: This deletes the cluster and its nodes. Persistent volumes backed by managed disks with a Retain reclaim policy can survive; anything else backed by the cluster is lost.

Les descriptions de cette référence sont pour l’instant en anglais.

Explication

Recherchez ou filtrez par groupe et copiez une commande en un clic. Ouvrez une commande pour voir ce qu’elle fait, un exemple et chaque paramètre qu’elle accepte, avec des avertissements pour tout ce qui supprime une ressource ou ouvre un accès réseau.

🔒 Votre saisie reste dans votre navigateur et n’est envoyée nulle part.

Questions fréquentes

Pourquoi az vm create ouvre-t-il SSH ou RDP vers internet par défaut ?

Sauf si vous définissez --nsg-rule NONE, Azure crée une règle de groupe de sécurité réseau qui ouvre SSH (Linux) ou RDP (Windows) depuis n’importe quelle adresse source. Restreignez la plage source au-delà d’un test rapide.

Et ensuite ?

Plus dans cette section

  • Aide-mémoire AWS CLIRéférence consultable AWS CLI : configuration, S3, EC2, VPC/Route 53, CloudWatch, Lambda, ECR/ECS, IAM et CloudFormation, avec chaque option expliquée.
  • Aide-mémoire AnsibleRéférence consultable des commandes Ansible : commandes ad-hoc, playbooks, rôles, modèles, handlers, boucles, Vault et Galaxy, avec chaque paramètre expliqué.

Aussi utile

  • Analyseur de NSG AzureCollez un export de NSG Azure pour repérer les ports ouverts, les conflits cachés entre règles de sous-réseau et de carte réseau, et un diagramme.
  • Analyseur de manifestes KubernetesCollez un manifeste Kubernetes pour repérer des limites de ressources manquantes, des réglages de sécurité risqués, des règles RBAC trop larges, et obtenir un patch suggéré.
  • Planificateur de VPC/sous-réseauPlanifiez des sous-réseaux dans un VPC ou VNet, voyez les adresses utilisables après réservations du fournisseur, repérez les chevauchements et exportez Terraform ou CloudFormation.
  • Générateur de scripts d’auditScripts et requêtes prêts à l’emploi, en lecture seule, pour des audits SQL, Active Directory, AWS CLI et Azure CLI. Cochez, copiez le script combiné.

Un problème ou une suggestion ? Dites-le-nous