Linux Virtual Machine Args
Manages a Linux Virtual Machine.
Disclaimers
Note This provider will automatically remove the OS Disk by default - this behaviour can be configured using the
features
configuration within the Provider configuration block. Note All arguments including the administrator login and password will be stored in the raw state as plain-text. Note This resource does not support Unmanaged Disks. If you need to use Unmanaged Disks you can continue to use theazure.compute.VirtualMachine
resource instead. Note This resource does not support attaching existing OS Disks. You can instead capture an image of the OS Disk or continue to use theazure.compute.VirtualMachine
resource instead. In this release there's a known issue where thepublic_ip_address
andpublic_ip_addresses
fields may not be fully populated for Dynamic Public IP's.
Example Usage
This example provisions a basic Linux Virtual Machine on an internal network.
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.network.VirtualNetwork;
import com.pulumi.azure.network.VirtualNetworkArgs;
import com.pulumi.azure.network.Subnet;
import com.pulumi.azure.network.SubnetArgs;
import com.pulumi.azure.network.NetworkInterface;
import com.pulumi.azure.network.NetworkInterfaceArgs;
import com.pulumi.azure.network.inputs.NetworkInterfaceIpConfigurationArgs;
import com.pulumi.azure.compute.LinuxVirtualMachine;
import com.pulumi.azure.compute.LinuxVirtualMachineArgs;
import com.pulumi.azure.compute.inputs.LinuxVirtualMachineAdminSshKeyArgs;
import com.pulumi.azure.compute.inputs.LinuxVirtualMachineOsDiskArgs;
import com.pulumi.azure.compute.inputs.LinuxVirtualMachineSourceImageReferenceArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()
.location("West Europe")
.build());
var exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()
.addressSpaces("10.0.0.0/16")
.location(exampleResourceGroup.location())
.resourceGroupName(exampleResourceGroup.name())
.build());
var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.virtualNetworkName(exampleVirtualNetwork.name())
.addressPrefixes("10.0.2.0/24")
.build());
var exampleNetworkInterface = new NetworkInterface("exampleNetworkInterface", NetworkInterfaceArgs.builder()
.location(exampleResourceGroup.location())
.resourceGroupName(exampleResourceGroup.name())
.ipConfigurations(NetworkInterfaceIpConfigurationArgs.builder()
.name("internal")
.subnetId(exampleSubnet.id())
.privateIpAddressAllocation("Dynamic")
.build())
.build());
var exampleLinuxVirtualMachine = new LinuxVirtualMachine("exampleLinuxVirtualMachine", LinuxVirtualMachineArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.location(exampleResourceGroup.location())
.size("Standard_F2")
.adminUsername("adminuser")
.networkInterfaceIds(exampleNetworkInterface.id())
.adminSshKeys(LinuxVirtualMachineAdminSshKeyArgs.builder()
.username("adminuser")
.publicKey(Files.readString(Paths.get("~/.ssh/id_rsa.pub")))
.build())
.osDisk(LinuxVirtualMachineOsDiskArgs.builder()
.caching("ReadWrite")
.storageAccountType("Standard_LRS")
.build())
.sourceImageReference(LinuxVirtualMachineSourceImageReferenceArgs.builder()
.publisher("Canonical")
.offer("0001-com-ubuntu-server-focal")
.sku("20_04-lts")
.version("latest")
.build())
.build());
}
}
Import
Linux Virtual Machines can be imported using the resource id
, e.g.
$ pulumi import azure:compute/linuxVirtualMachine:LinuxVirtualMachine example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/machine1
Constructors
Functions
Properties
The maximum price you're willing to pay for this Virtual Machine, in US Dollars; which must be greater than the current spot price. If this bid price falls below the current spot price the Virtual Machine will be evicted using the eviction_policy
. Defaults to -1
, which means that the Virtual Machine should not be evicted for price reasons.
Specifies the mode of in-guest patching to this Linux Virtual Machine. Possible values are AutomaticByPlatform
and ImageDefault
. Defaults to ImageDefault
. For more information on patch modes please see the product documentation.
Specifies the Platform Fault Domain in which this Linux Virtual Machine should be created. Defaults to -1
, which means this will be automatically assigned to a fault domain that best maintains balance across the available fault domains. Changing this forces a new Linux Virtual Machine to be created.
The ID of the Image which this Virtual Machine should be created from. Changing this forces a new resource to be created. Possible Image ID types include Image ID
s, Shared Image ID
s, Shared Image Version ID
s, Community Gallery Image ID
s, Community Gallery Image Version ID
s, Shared Gallery Image ID
s and Shared Gallery Image Version ID
s.