Cheat sheet de Azure CLI

Referencia de comandos de Azure CLI con búsqueda: inicio de sesión, grupos de recursos, VMs, almacenamiento, web apps y AKS, con cada parámetro explicado.

Se ejecuta en tu navegador · no se envía nadaNuevo

31 comandos

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.

Opciones

--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.

Ejemplo

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.

Ejemplo

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

Opciones

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.

Ejemplo

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.

Ejemplo

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

Opciones

--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.

Opciones

--yes -ySkip the interactive confirmation prompt.
--no-waitReturn immediately instead of waiting for the deletion to finish.
Cuidado: 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.

Ejemplo

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

Opciones

--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.
Cuidado: 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.

Opciones

--yes -ySkip the confirmation prompt.
--force-deletionSkip the graceful shutdown and force-delete the VM.
Cuidado: 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.

Opciones

--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.
Cuidado: 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.

Opciones

--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.

Ejemplo

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

Opciones

--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.

Opciones

--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.

Opciones

--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.

Opciones

--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.

Ejemplo

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

Opciones

--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.
Cuidado: 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.

Opciones

--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.

Ejemplo

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

Opciones

--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.

Opciones

--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.

Opciones

--yes -ySkip the confirmation prompt.
Cuidado: 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.

Las descripciones de esta referencia están por ahora en inglés.

Explicación

Busca o filtra por grupo y copia un comando con un clic. Abre un comando para ver qué hace, un ejemplo y cada parámetro que acepta, con avisos para todo lo que elimine un recurso o abra acceso de red.

🔒 Tu entrada se queda en tu navegador y no se envía a ningún sitio.

Preguntas frecuentes

¿Por qué az vm create abre SSH o RDP a internet por defecto?

A menos que establezcas --nsg-rule NONE, Azure crea una regla de grupo de seguridad de red que abre SSH (Linux) o RDP (Windows) desde cualquier dirección de origen. Restringe el rango de origen para cualquier uso más allá de una prueba rápida.

Qué hacer después

Más en esta sección

  • Cheat sheet de AWS CLIReferencia de AWS CLI con búsqueda: configuración, S3, EC2, VPC/Route 53, CloudWatch, Lambda, ECR/ECS, IAM y CloudFormation, con cada opción explicada.
  • Cheat sheet de AnsibleReferencia de comandos de Ansible con búsqueda: comandos ad-hoc, playbooks, roles, plantillas, handlers, bucles, Vault y Galaxy, con cada parámetro explicado.

También útil

  • Analizador de NSG de AzurePega una exportación de NSG de Azure para detectar puertos abiertos, conflictos ocultos entre reglas de subred y de NIC, y ver un diagrama.
  • Analizador de manifiestos de KubernetesPega un manifiesto de Kubernetes para detectar límites de recursos ausentes, ajustes de seguridad arriesgados y reglas RBAC demasiado amplias, con un parche sugerido.
  • Planificador de VPC/subredPlanifica subredes dentro de una VPC o VNet, ve las direcciones utilizables tras las reservas del proveedor, detecta solapamientos y exporta Terraform o CloudFormation.
  • Generador de scripts de auditoríaScripts y consultas listas para usar, de solo lectura, para auditorías de SQL, Active Directory, AWS CLI y Azure CLI. Marca y copia el script combinado.

¿Has encontrado un problema o tienes una sugerencia? Cuéntanoslo