Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This script creates an Azure Virtual Machine with an Ubuntu operating system. After running the script, you can access the virtual machine over SSH.
To run this sample, install the latest version of the Azure CLI. To start, run az login
to create a connection with Azure.
Samples for the Azure CLI are written for the bash
shell. To run this sample in Windows PowerShell or Command Prompt, you may need to change
elements of the script.
If you don't have an Azure subscription, create an Azure free account before you begin.
Run the following command to remove the resource group, VM, and all related resources.
az group delete --name myResourceGroup
This script uses the following commands to create a resource group, virtual machine, and all related resources. Each command in the table links to command specific documentation.
Command | Notes |
---|---|
az group create | Creates a resource group in which all resources are stored. |
az network vnet create | Creates an Azure virtual network and subnet. |
az network public-ip create | Creates a public IP address with a static IP address and an associated DNS name. |
az network nsg create | Creates a network security group (NSG), which is a security boundary between the internet and the virtual machine. |
az network nsg rule create | Creates an NSG rule to allow inbound traffic. In this sample, port 22 is opened for SSH traffic. |
az network nic create | Creates a virtual network card and attaches it to the virtual network, subnet, and NSG. |
az vm create | Creates the virtual machine and connects it to the network card, virtual network, subnet, and NSG. This command also specifies the virtual machine image to be used, and administrative credentials. |
az group delete | Deletes a resource group including all nested resources. |
For more information on the Azure CLI, see Azure CLI documentation.
Additional virtual machine CLI script samples can be found in the Azure Linux VM documentation.
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in