VirtualMachineArgs

data class VirtualMachineArgs(val additionalCapabilities: Output<AdditionalCapabilitiesArgs>? = null, val availabilitySet: Output<SubResourceArgs>? = null, val billingProfile: Output<BillingProfileArgs>? = null, val diagnosticsProfile: Output<DiagnosticsProfileArgs>? = null, val evictionPolicy: Output<Either<String, VirtualMachineEvictionPolicyTypes>>? = null, val extendedLocation: Output<ExtendedLocationArgs>? = null, val extensionsTimeBudget: Output<String>? = null, val hardwareProfile: Output<HardwareProfileArgs>? = null, val host: Output<SubResourceArgs>? = null, val hostGroup: Output<SubResourceArgs>? = null, val identity: Output<VirtualMachineIdentityArgs>? = null, val licenseType: Output<String>? = null, val location: Output<String>? = null, val networkProfile: Output<NetworkProfileArgs>? = null, val osProfile: Output<OSProfileArgs>? = null, val plan: Output<PlanArgs>? = null, val platformFaultDomain: Output<Int>? = null, val priority: Output<Either<String, VirtualMachinePriorityTypes>>? = null, val proximityPlacementGroup: Output<SubResourceArgs>? = null, val resourceGroupName: Output<String>? = null, val scheduledEventsProfile: Output<ScheduledEventsProfileArgs>? = null, val securityProfile: Output<SecurityProfileArgs>? = null, val storageProfile: Output<StorageProfileArgs>? = null, val tags: Output<Map<String, String>>? = null, val userData: Output<String>? = null, val virtualMachineScaleSet: Output<SubResourceArgs>? = null, val vmName: Output<String>? = null, val zones: Output<List<String>>? = null) : ConvertibleToJava<VirtualMachineArgs>

Describes a Virtual Machine. API Version: 2021-03-01.

Example Usage

Create a Linux vm with a patch setting assessmentMode of ImageDefault.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D2s_v3",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
LinuxConfiguration = new AzureNative.Compute.Inputs.LinuxConfigurationArgs
{
PatchSettings = new AzureNative.Compute.Inputs.LinuxPatchSettingsArgs
{
AssessmentMode = "ImageDefault",
},
ProvisionVMAgent = true,
},
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "UbuntuServer",
Publisher = "Canonical",
Sku = "16.04-LTS",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Premium_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D2s_v3"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM"),
Map.entry("linuxConfiguration", Map.ofEntries(
Map.entry("patchSettings", Map.of("assessmentMode", "ImageDefault")),
Map.entry("provisionVMAgent", true)
))
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "UbuntuServer"),
Map.entry("publisher", "Canonical"),
Map.entry("sku", "16.04-LTS"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Premium_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a Linux vm with a patch setting patchMode of ImageDefault.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D2s_v3",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
LinuxConfiguration = new AzureNative.Compute.Inputs.LinuxConfigurationArgs
{
PatchSettings = new AzureNative.Compute.Inputs.LinuxPatchSettingsArgs
{
PatchMode = "ImageDefault",
},
ProvisionVMAgent = true,
},
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "UbuntuServer",
Publisher = "Canonical",
Sku = "16.04-LTS",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Premium_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D2s_v3"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM"),
Map.entry("linuxConfiguration", Map.ofEntries(
Map.entry("patchSettings", Map.of("patchMode", "ImageDefault")),
Map.entry("provisionVMAgent", true)
))
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "UbuntuServer"),
Map.entry("publisher", "Canonical"),
Map.entry("sku", "16.04-LTS"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Premium_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a Linux vm with a patch settings patchMode and assessmentMode set to AutomaticByPlatform.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D2s_v3",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
LinuxConfiguration = new AzureNative.Compute.Inputs.LinuxConfigurationArgs
{
PatchSettings = new AzureNative.Compute.Inputs.LinuxPatchSettingsArgs
{
AssessmentMode = "AutomaticByPlatform",
PatchMode = "AutomaticByPlatform",
},
ProvisionVMAgent = true,
},
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "UbuntuServer",
Publisher = "Canonical",
Sku = "16.04-LTS",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Premium_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D2s_v3"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM"),
Map.entry("linuxConfiguration", Map.ofEntries(
Map.entry("patchSettings", Map.ofEntries(
Map.entry("assessmentMode", "AutomaticByPlatform"),
Map.entry("patchMode", "AutomaticByPlatform")
)),
Map.entry("provisionVMAgent", true)
))
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "UbuntuServer"),
Map.entry("publisher", "Canonical"),
Map.entry("sku", "16.04-LTS"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Premium_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a VM with Uefi Settings of secureBoot and vTPM.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D2s_v3",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
SecurityProfile = new AzureNative.Compute.Inputs.SecurityProfileArgs
{
SecurityType = "TrustedLaunch",
UefiSettings = new AzureNative.Compute.Inputs.UefiSettingsArgs
{
SecureBootEnabled = true,
VTpmEnabled = true,
},
},
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "windowsserver-gen2preview-preview",
Publisher = "MicrosoftWindowsServer",
Sku = "windows10-tvm",
Version = "18363.592.2001092016",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadOnly,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "StandardSSD_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D2s_v3"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.securityProfile(Map.ofEntries(
Map.entry("securityType", "TrustedLaunch"),
Map.entry("uefiSettings", Map.ofEntries(
Map.entry("secureBootEnabled", true),
Map.entry("vTpmEnabled", true)
))
))
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "windowsserver-gen2preview-preview"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "windows10-tvm"),
Map.entry("version", "18363.592.2001092016")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadOnly"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "StandardSSD_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a VM with UserData

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
DiagnosticsProfile = new AzureNative.Compute.Inputs.DiagnosticsProfileArgs
{
BootDiagnostics = new AzureNative.Compute.Inputs.BootDiagnosticsArgs
{
Enabled = true,
StorageUri = "http://{existing-storage-account-name}.blob.core.windows.net",
},
},
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "{vm-name}",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "vmOSdisk",
},
},
UserData = "RXhhbXBsZSBVc2VyRGF0YQ==",
VmName = "{vm-name}",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.diagnosticsProfile(Map.of("bootDiagnostics", Map.ofEntries(
Map.entry("enabled", true),
Map.entry("storageUri", "http://{existing-storage-account-name}.blob.core.windows.net")
)))
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "{vm-name}")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "vmOSdisk")
))
))
.userData("RXhhbXBsZSBVc2VyRGF0YQ==")
.vmName("{vm-name}")
.build());
}
}

Create a VM with network interface configuration

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkApiVersion = "2020-11-01",
NetworkInterfaceConfigurations = new[]
{
new AzureNative.Compute.Inputs.VirtualMachineNetworkInterfaceConfigurationArgs
{
DeleteOption = "Delete",
IpConfigurations = new[]
{
new AzureNative.Compute.Inputs.VirtualMachineNetworkInterfaceIPConfigurationArgs
{
Name = "{ip-config-name}",
Primary = true,
PublicIPAddressConfiguration = new AzureNative.Compute.Inputs.VirtualMachinePublicIPAddressConfigurationArgs
{
DeleteOption = "Detach",
Name = "{publicIP-config-name}",
PublicIPAllocationMethod = "Static",
Sku = new AzureNative.Compute.Inputs.PublicIPAddressSkuArgs
{
Name = "Basic",
Tier = "Global",
},
},
},
},
Name = "{nic-config-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.ofEntries(
Map.entry("networkApiVersion", "2020-11-01"),
Map.entry("networkInterfaceConfigurations", Map.ofEntries(
Map.entry("deleteOption", "Delete"),
Map.entry("ipConfigurations", Map.ofEntries(
Map.entry("name", "{ip-config-name}"),
Map.entry("primary", true),
Map.entry("publicIPAddressConfiguration", Map.ofEntries(
Map.entry("deleteOption", "Detach"),
Map.entry("name", "{publicIP-config-name}"),
Map.entry("publicIPAllocationMethod", "Static"),
Map.entry("sku", Map.ofEntries(
Map.entry("name", "Basic"),
Map.entry("tier", "Global")
))
))
)),
Map.entry("name", "{nic-config-name}"),
Map.entry("primary", true)
))
))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a Windows vm with a patch setting assessmentMode of ImageDefault.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
WindowsConfiguration = new AzureNative.Compute.Inputs.WindowsConfigurationArgs
{
EnableAutomaticUpdates = true,
PatchSettings = new AzureNative.Compute.Inputs.PatchSettingsArgs
{
AssessmentMode = "ImageDefault",
},
ProvisionVMAgent = true,
},
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Premium_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM"),
Map.entry("windowsConfiguration", Map.ofEntries(
Map.entry("enableAutomaticUpdates", true),
Map.entry("patchSettings", Map.of("assessmentMode", "ImageDefault")),
Map.entry("provisionVMAgent", true)
))
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Premium_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a Windows vm with a patch setting patchMode of AutomaticByOS.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/nsgExistingNic",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
WindowsConfiguration = new AzureNative.Compute.Inputs.WindowsConfigurationArgs
{
EnableAutomaticUpdates = true,
PatchSettings = new AzureNative.Compute.Inputs.PatchSettingsArgs
{
PatchMode = "AutomaticByOS",
},
ProvisionVMAgent = true,
},
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Premium_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/nsgExistingNic"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM"),
Map.entry("windowsConfiguration", Map.ofEntries(
Map.entry("enableAutomaticUpdates", true),
Map.entry("patchSettings", Map.of("patchMode", "AutomaticByOS")),
Map.entry("provisionVMAgent", true)
))
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Premium_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a Windows vm with a patch setting patchMode of AutomaticByPlatform and enableHotpatching set to true.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
WindowsConfiguration = new AzureNative.Compute.Inputs.WindowsConfigurationArgs
{
EnableAutomaticUpdates = true,
PatchSettings = new AzureNative.Compute.Inputs.PatchSettingsArgs
{
EnableHotpatching = true,
PatchMode = "AutomaticByPlatform",
},
ProvisionVMAgent = true,
},
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Premium_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM"),
Map.entry("windowsConfiguration", Map.ofEntries(
Map.entry("enableAutomaticUpdates", true),
Map.entry("patchSettings", Map.ofEntries(
Map.entry("enableHotpatching", true),
Map.entry("patchMode", "AutomaticByPlatform")
)),
Map.entry("provisionVMAgent", true)
))
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Premium_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a Windows vm with a patch setting patchMode of Manual.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
WindowsConfiguration = new AzureNative.Compute.Inputs.WindowsConfigurationArgs
{
EnableAutomaticUpdates = true,
PatchSettings = new AzureNative.Compute.Inputs.PatchSettingsArgs
{
PatchMode = "Manual",
},
ProvisionVMAgent = true,
},
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Premium_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM"),
Map.entry("windowsConfiguration", Map.ofEntries(
Map.entry("enableAutomaticUpdates", true),
Map.entry("patchSettings", Map.of("patchMode", "Manual")),
Map.entry("provisionVMAgent", true)
))
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Premium_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a Windows vm with patch settings patchMode and assessmentMode set to AutomaticByPlatform.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
WindowsConfiguration = new AzureNative.Compute.Inputs.WindowsConfigurationArgs
{
EnableAutomaticUpdates = true,
PatchSettings = new AzureNative.Compute.Inputs.PatchSettingsArgs
{
AssessmentMode = "AutomaticByPlatform",
PatchMode = "AutomaticByPlatform",
},
ProvisionVMAgent = true,
},
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Premium_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM"),
Map.entry("windowsConfiguration", Map.ofEntries(
Map.entry("enableAutomaticUpdates", true),
Map.entry("patchSettings", Map.ofEntries(
Map.entry("assessmentMode", "AutomaticByPlatform"),
Map.entry("patchMode", "AutomaticByPlatform")
)),
Map.entry("provisionVMAgent", true)
))
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Premium_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a custom-image vm from an unmanaged generalized os image.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
Image = new AzureNative.Compute.Inputs.VirtualHardDiskArgs
{
Uri = "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd",
},
Name = "myVMosdisk",
OsType = AzureNative.Compute.OperatingSystemTypes.Windows,
Vhd = new AzureNative.Compute.Inputs.VirtualHardDiskArgs
{
Uri = "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk.vhd",
},
},
},
VmName = "{vm-name}",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.of("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("image", Map.of("uri", "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd")),
Map.entry("name", "myVMosdisk"),
Map.entry("osType", "Windows"),
Map.entry("vhd", Map.of("uri", "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk.vhd"))
)))
.vmName("{vm-name}")
.build());
}
}

Create a platform-image vm with unmanaged os and data disks.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D2_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
DataDisks = new[]
{
new AzureNative.Compute.Inputs.DataDiskArgs
{
CreateOption = "Empty",
DiskSizeGB = 1023,
Lun = 0,
Vhd = new AzureNative.Compute.Inputs.VirtualHardDiskArgs
{
Uri = "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk0.vhd",
},
},
new AzureNative.Compute.Inputs.DataDiskArgs
{
CreateOption = "Empty",
DiskSizeGB = 1023,
Lun = 1,
Vhd = new AzureNative.Compute.Inputs.VirtualHardDiskArgs
{
Uri = "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk1.vhd",
},
},
},
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
Name = "myVMosdisk",
Vhd = new AzureNative.Compute.Inputs.VirtualHardDiskArgs
{
Uri = "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk.vhd",
},
},
},
VmName = "{vm-name}",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D2_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("dataDisks",
Map.ofEntries(
Map.entry("createOption", "Empty"),
Map.entry("diskSizeGB", 1023),
Map.entry("lun", 0),
Map.entry("vhd", Map.of("uri", "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk0.vhd"))
),
Map.ofEntries(
Map.entry("createOption", "Empty"),
Map.entry("diskSizeGB", 1023),
Map.entry("lun", 1),
Map.entry("vhd", Map.of("uri", "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk1.vhd"))
)),
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("name", "myVMosdisk"),
Map.entry("vhd", Map.of("uri", "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk.vhd"))
))
))
.vmName("{vm-name}")
.build());
}
}

Create a vm from a custom image.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.of("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}")),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm from a generalized shared image.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.of("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage")),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm from a specialized shared image.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.of("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage")),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm in a Virtual Machine Scale Set with customer assigned platformFaultDomain.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
PlatformFaultDomain = 1,
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VirtualMachineScaleSet = new AzureNative.Compute.Inputs.SubResourceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{existing-flex-vmss-name-with-platformFaultDomainCount-greater-than-1}",
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.platformFaultDomain(1)
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.virtualMachineScaleSet(Map.of("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{existing-flex-vmss-name-with-platformFaultDomainCount-greater-than-1}"))
.vmName("myVM")
.build());
}
}

Create a vm in an availability set.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
AvailabilitySet = new AzureNative.Compute.Inputs.SubResourceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/availabilitySets/{existing-availability-set-name}",
},
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.availabilitySet(Map.of("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/availabilitySets/{existing-availability-set-name}"))
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with DiskEncryptionSet resource id in the os disk and data disk.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
DataDisks = new[]
{
new AzureNative.Compute.Inputs.DataDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "Empty",
DiskSizeGB = 1023,
Lun = 0,
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
DiskEncryptionSet = new AzureNative.Compute.Inputs.DiskEncryptionSetParametersArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}",
},
StorageAccountType = "Standard_LRS",
},
},
new AzureNative.Compute.Inputs.DataDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "Attach",
DiskSizeGB = 1023,
Lun = 1,
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
DiskEncryptionSet = new AzureNative.Compute.Inputs.DiskEncryptionSetParametersArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}",
},
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/{existing-managed-disk-name}",
StorageAccountType = "Standard_LRS",
},
},
},
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
DiskEncryptionSet = new AzureNative.Compute.Inputs.DiskEncryptionSetParametersArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}",
},
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("dataDisks",
Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "Empty"),
Map.entry("diskSizeGB", 1023),
Map.entry("lun", 0),
Map.entry("managedDisk", Map.ofEntries(
Map.entry("diskEncryptionSet", Map.of("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}")),
Map.entry("storageAccountType", "Standard_LRS")
))
),
Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "Attach"),
Map.entry("diskSizeGB", 1023),
Map.entry("lun", 1),
Map.entry("managedDisk", Map.ofEntries(
Map.entry("diskEncryptionSet", Map.of("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}")),
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/{existing-managed-disk-name}"),
Map.entry("storageAccountType", "Standard_LRS")
))
)),
Map.entry("imageReference", Map.of("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}")),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.ofEntries(
Map.entry("diskEncryptionSet", Map.of("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}")),
Map.entry("storageAccountType", "Standard_LRS")
)),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with Host Encryption using encryptionAtHost property.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_DS1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
Plan = new AzureNative.Compute.Inputs.PlanArgs
{
Name = "windows2016",
Product = "windows-data-science-vm",
Publisher = "microsoft-ads",
},
ResourceGroupName = "myResourceGroup",
SecurityProfile = new AzureNative.Compute.Inputs.SecurityProfileArgs
{
EncryptionAtHost = true,
},
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "windows-data-science-vm",
Publisher = "microsoft-ads",
Sku = "windows2016",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadOnly,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_DS1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.plan(Map.ofEntries(
Map.entry("name", "windows2016"),
Map.entry("product", "windows-data-science-vm"),
Map.entry("publisher", "microsoft-ads")
))
.resourceGroupName("myResourceGroup")
.securityProfile(Map.of("encryptionAtHost", true))
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "windows-data-science-vm"),
Map.entry("publisher", "microsoft-ads"),
Map.entry("sku", "windows2016"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadOnly"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with Scheduled Events Profile

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
DiagnosticsProfile = new AzureNative.Compute.Inputs.DiagnosticsProfileArgs
{
BootDiagnostics = new AzureNative.Compute.Inputs.BootDiagnosticsArgs
{
Enabled = true,
StorageUri = "http://{existing-storage-account-name}.blob.core.windows.net",
},
},
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
ScheduledEventsProfile = new AzureNative.Compute.Inputs.ScheduledEventsProfileArgs
{
TerminateNotificationProfile = new AzureNative.Compute.Inputs.TerminateNotificationProfileArgs
{
Enable = true,
NotBeforeTimeout = "PT10M",
},
},
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.diagnosticsProfile(Map.of("bootDiagnostics", Map.ofEntries(
Map.entry("enabled", true),
Map.entry("storageUri", "http://{existing-storage-account-name}.blob.core.windows.net")
)))
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.scheduledEventsProfile(Map.of("terminateNotificationProfile", Map.ofEntries(
Map.entry("enable", true),
Map.entry("notBeforeTimeout", "PT10M")
)))
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with a marketplace image plan.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
Plan = new AzureNative.Compute.Inputs.PlanArgs
{
Name = "windows2016",
Product = "windows-data-science-vm",
Publisher = "microsoft-ads",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "windows-data-science-vm",
Publisher = "microsoft-ads",
Sku = "windows2016",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.plan(Map.ofEntries(
Map.entry("name", "windows2016"),
Map.entry("product", "windows-data-science-vm"),
Map.entry("publisher", "microsoft-ads")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "windows-data-science-vm"),
Map.entry("publisher", "microsoft-ads"),
Map.entry("sku", "windows2016"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with an extensions time budget.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
DiagnosticsProfile = new AzureNative.Compute.Inputs.DiagnosticsProfileArgs
{
BootDiagnostics = new AzureNative.Compute.Inputs.BootDiagnosticsArgs
{
Enabled = true,
StorageUri = "http://{existing-storage-account-name}.blob.core.windows.net",
},
},
ExtensionsTimeBudget = "PT30M",
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.diagnosticsProfile(Map.of("bootDiagnostics", Map.ofEntries(
Map.entry("enabled", true),
Map.entry("storageUri", "http://{existing-storage-account-name}.blob.core.windows.net")
)))
.extensionsTimeBudget("PT30M")
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with boot diagnostics.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
DiagnosticsProfile = new AzureNative.Compute.Inputs.DiagnosticsProfileArgs
{
BootDiagnostics = new AzureNative.Compute.Inputs.BootDiagnosticsArgs
{
Enabled = true,
StorageUri = "http://{existing-storage-account-name}.blob.core.windows.net",
},
},
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.diagnosticsProfile(Map.of("bootDiagnostics", Map.ofEntries(
Map.entry("enabled", true),
Map.entry("storageUri", "http://{existing-storage-account-name}.blob.core.windows.net")
)))
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with empty data disks.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D2_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
DataDisks = new[]
{
new AzureNative.Compute.Inputs.DataDiskArgs
{
CreateOption = "Empty",
DiskSizeGB = 1023,
Lun = 0,
},
new AzureNative.Compute.Inputs.DataDiskArgs
{
CreateOption = "Empty",
DiskSizeGB = 1023,
Lun = 1,
},
},
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D2_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("dataDisks",
Map.ofEntries(
Map.entry("createOption", "Empty"),
Map.entry("diskSizeGB", 1023),
Map.entry("lun", 0)
),
Map.ofEntries(
Map.entry("createOption", "Empty"),
Map.entry("diskSizeGB", 1023),
Map.entry("lun", 1)
)),
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with ephemeral os disk provisioning in Cache disk using placement property.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_DS1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
Plan = new AzureNative.Compute.Inputs.PlanArgs
{
Name = "windows2016",
Product = "windows-data-science-vm",
Publisher = "microsoft-ads",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "windows-data-science-vm",
Publisher = "microsoft-ads",
Sku = "windows2016",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadOnly,
CreateOption = "FromImage",
DiffDiskSettings = new AzureNative.Compute.Inputs.DiffDiskSettingsArgs
{
Option = "Local",
Placement = "CacheDisk",
},
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_DS1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.plan(Map.ofEntries(
Map.entry("name", "windows2016"),
Map.entry("product", "windows-data-science-vm"),
Map.entry("publisher", "microsoft-ads")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "windows-data-science-vm"),
Map.entry("publisher", "microsoft-ads"),
Map.entry("sku", "windows2016"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadOnly"),
Map.entry("createOption", "FromImage"),
Map.entry("diffDiskSettings", Map.ofEntries(
Map.entry("option", "Local"),
Map.entry("placement", "CacheDisk")
)),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with ephemeral os disk provisioning in Resource disk using placement property.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_DS1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
Plan = new AzureNative.Compute.Inputs.PlanArgs
{
Name = "windows2016",
Product = "windows-data-science-vm",
Publisher = "microsoft-ads",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "windows-data-science-vm",
Publisher = "microsoft-ads",
Sku = "windows2016",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadOnly,
CreateOption = "FromImage",
DiffDiskSettings = new AzureNative.Compute.Inputs.DiffDiskSettingsArgs
{
Option = "Local",
Placement = "ResourceDisk",
},
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_DS1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.plan(Map.ofEntries(
Map.entry("name", "windows2016"),
Map.entry("product", "windows-data-science-vm"),
Map.entry("publisher", "microsoft-ads")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "windows-data-science-vm"),
Map.entry("publisher", "microsoft-ads"),
Map.entry("sku", "windows2016"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadOnly"),
Map.entry("createOption", "FromImage"),
Map.entry("diffDiskSettings", Map.ofEntries(
Map.entry("option", "Local"),
Map.entry("placement", "ResourceDisk")
)),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with ephemeral os disk.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_DS1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
Plan = new AzureNative.Compute.Inputs.PlanArgs
{
Name = "windows2016",
Product = "windows-data-science-vm",
Publisher = "microsoft-ads",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "windows-data-science-vm",
Publisher = "microsoft-ads",
Sku = "windows2016",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadOnly,
CreateOption = "FromImage",
DiffDiskSettings = new AzureNative.Compute.Inputs.DiffDiskSettingsArgs
{
Option = "Local",
},
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_DS1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.plan(Map.ofEntries(
Map.entry("name", "windows2016"),
Map.entry("product", "windows-data-science-vm"),
Map.entry("publisher", "microsoft-ads")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "windows-data-science-vm"),
Map.entry("publisher", "microsoft-ads"),
Map.entry("sku", "windows2016"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadOnly"),
Map.entry("createOption", "FromImage"),
Map.entry("diffDiskSettings", Map.of("option", "Local")),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with managed boot diagnostics.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
DiagnosticsProfile = new AzureNative.Compute.Inputs.DiagnosticsProfileArgs
{
BootDiagnostics = new AzureNative.Compute.Inputs.BootDiagnosticsArgs
{
Enabled = true,
},
},
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.diagnosticsProfile(Map.of("bootDiagnostics", Map.of("enabled", true)))
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with password authentication.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with premium storage.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminPassword = "{your-password}",
AdminUsername = "{your-username}",
ComputerName = "myVM",
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "WindowsServer",
Publisher = "MicrosoftWindowsServer",
Sku = "2016-Datacenter",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Premium_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminPassword", "{your-password}"),
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM")
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "WindowsServer"),
Map.entry("publisher", "MicrosoftWindowsServer"),
Map.entry("sku", "2016-Datacenter"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Premium_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Create a vm with ssh authentication.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachine = new AzureNative.Compute.VirtualMachine("virtualMachine", new()
{
HardwareProfile = new AzureNative.Compute.Inputs.HardwareProfileArgs
{
VmSize = "Standard_D1_v2",
},
Location = "westus",
NetworkProfile = new AzureNative.Compute.Inputs.NetworkProfileArgs
{
NetworkInterfaces = new[]
{
new AzureNative.Compute.Inputs.NetworkInterfaceReferenceArgs
{
Id = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
Primary = true,
},
},
},
OsProfile = new AzureNative.Compute.Inputs.OSProfileArgs
{
AdminUsername = "{your-username}",
ComputerName = "myVM",
LinuxConfiguration = new AzureNative.Compute.Inputs.LinuxConfigurationArgs
{
DisablePasswordAuthentication = true,
Ssh = new AzureNative.Compute.Inputs.SshConfigurationArgs
{
PublicKeys = new[]
{
new AzureNative.Compute.Inputs.SshPublicKeyArgs
{
KeyData = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1",
Path = "/home/{your-username}/.ssh/authorized_keys",
},
},
},
},
},
ResourceGroupName = "myResourceGroup",
StorageProfile = new AzureNative.Compute.Inputs.StorageProfileArgs
{
ImageReference = new AzureNative.Compute.Inputs.ImageReferenceArgs
{
Offer = "{image_offer}",
Publisher = "{image_publisher}",
Sku = "{image_sku}",
Version = "latest",
},
OsDisk = new AzureNative.Compute.Inputs.OSDiskArgs
{
Caching = AzureNative.Compute.CachingTypes.ReadWrite,
CreateOption = "FromImage",
ManagedDisk = new AzureNative.Compute.Inputs.ManagedDiskParametersArgs
{
StorageAccountType = "Standard_LRS",
},
Name = "myVMosdisk",
},
},
VmName = "myVM",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.compute.VirtualMachine;
import com.pulumi.azurenative.compute.VirtualMachineArgs;
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 virtualMachine = new VirtualMachine("virtualMachine", VirtualMachineArgs.builder()
.hardwareProfile(Map.of("vmSize", "Standard_D1_v2"))
.location("westus")
.networkProfile(Map.of("networkInterfaces", Map.ofEntries(
Map.entry("id", "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"),
Map.entry("primary", true)
)))
.osProfile(Map.ofEntries(
Map.entry("adminUsername", "{your-username}"),
Map.entry("computerName", "myVM"),
Map.entry("linuxConfiguration", Map.ofEntries(
Map.entry("disablePasswordAuthentication", true),
Map.entry("ssh", Map.of("publicKeys", Map.ofEntries(
Map.entry("keyData", "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1"),
Map.entry("path", "/home/{your-username}/.ssh/authorized_keys")
)))
))
))
.resourceGroupName("myResourceGroup")
.storageProfile(Map.ofEntries(
Map.entry("imageReference", Map.ofEntries(
Map.entry("offer", "{image_offer}"),
Map.entry("publisher", "{image_publisher}"),
Map.entry("sku", "{image_sku}"),
Map.entry("version", "latest")
)),
Map.entry("osDisk", Map.ofEntries(
Map.entry("caching", "ReadWrite"),
Map.entry("createOption", "FromImage"),
Map.entry("managedDisk", Map.of("storageAccountType", "Standard_LRS")),
Map.entry("name", "myVMosdisk")
))
))
.vmName("myVM")
.build());
}
}

Import

An existing resource can be imported using its type token, name, and identifier, e.g.

$ pulumi import azure-native:compute:VirtualMachine myVM /subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM

Constructors

Link copied to clipboard
constructor(additionalCapabilities: Output<AdditionalCapabilitiesArgs>? = null, availabilitySet: Output<SubResourceArgs>? = null, billingProfile: Output<BillingProfileArgs>? = null, diagnosticsProfile: Output<DiagnosticsProfileArgs>? = null, evictionPolicy: Output<Either<String, VirtualMachineEvictionPolicyTypes>>? = null, extendedLocation: Output<ExtendedLocationArgs>? = null, extensionsTimeBudget: Output<String>? = null, hardwareProfile: Output<HardwareProfileArgs>? = null, host: Output<SubResourceArgs>? = null, hostGroup: Output<SubResourceArgs>? = null, identity: Output<VirtualMachineIdentityArgs>? = null, licenseType: Output<String>? = null, location: Output<String>? = null, networkProfile: Output<NetworkProfileArgs>? = null, osProfile: Output<OSProfileArgs>? = null, plan: Output<PlanArgs>? = null, platformFaultDomain: Output<Int>? = null, priority: Output<Either<String, VirtualMachinePriorityTypes>>? = null, proximityPlacementGroup: Output<SubResourceArgs>? = null, resourceGroupName: Output<String>? = null, scheduledEventsProfile: Output<ScheduledEventsProfileArgs>? = null, securityProfile: Output<SecurityProfileArgs>? = null, storageProfile: Output<StorageProfileArgs>? = null, tags: Output<Map<String, String>>? = null, userData: Output<String>? = null, virtualMachineScaleSet: Output<SubResourceArgs>? = null, vmName: Output<String>? = null, zones: Output<List<String>>? = null)

Properties

Link copied to clipboard

Specifies additional capabilities enabled or disabled on the virtual machine.

Link copied to clipboard
val availabilitySet: Output<SubResourceArgs>? = null

Specifies information about the availability set that the virtual machine should be assigned to. Virtual machines specified in the same availability set are allocated to different nodes to maximize availability. For more information about availability sets, see Availability sets overview.

For more information on Azure planned maintenance, see Maintenance and updates for Virtual Machines in Azure

Currently, a VM can only be added to availability set at creation time. The availability set to which the VM is being added should be under the same resource group as the availability set resource. An existing VM cannot be added to an availability set.

This property cannot exist along with a non-null properties.virtualMachineScaleSet reference.

Link copied to clipboard
val billingProfile: Output<BillingProfileArgs>? = null

Specifies the billing related details of a Azure Spot virtual machine.

Minimum api-version: 2019-03-01.

Link copied to clipboard

Specifies the boot diagnostic settings state.

Minimum api-version: 2015-06-15.

Link copied to clipboard

Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set.

For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01.

For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2017-10-30-preview.

Link copied to clipboard

The extended location of the Virtual Machine.

Link copied to clipboard
val extensionsTimeBudget: Output<String>? = null

Specifies the time alloted for all extensions to start. The time duration should be between 15 minutes and 120 minutes (inclusive) and should be specified in ISO 8601 format. The default value is 90 minutes (PT1H30M).

Minimum api-version: 2020-06-01

Link copied to clipboard

Specifies the hardware settings for the virtual machine.

Link copied to clipboard
val host: Output<SubResourceArgs>? = null

Specifies information about the dedicated host that the virtual machine resides in.

Minimum api-version: 2018-10-01.

Link copied to clipboard
val hostGroup: Output<SubResourceArgs>? = null

Specifies information about the dedicated host group that the virtual machine resides in.

Minimum api-version: 2020-06-01.

NOTE: User cannot specify both host and hostGroup properties.

Link copied to clipboard

The identity of the virtual machine, if configured.

Link copied to clipboard
val licenseType: Output<String>? = null

Specifies that the image or disk that is being used was licensed on-premises.

Possible values for Windows Server operating system are:

Windows_Client

Windows_Server

Possible values for Linux Server operating system are:

RHEL_BYOS (for RHEL)

SLES_BYOS (for SUSE)

For more information, see Azure Hybrid Use Benefit for Windows Server

Azure Hybrid Use Benefit for Linux Server

Minimum api-version: 2015-06-15

Link copied to clipboard
val location: Output<String>? = null

Resource location

Link copied to clipboard
val networkProfile: Output<NetworkProfileArgs>? = null

Specifies the network interfaces of the virtual machine.

Link copied to clipboard
val osProfile: Output<OSProfileArgs>? = null

Specifies the operating system settings used while creating the virtual machine. Some of the settings cannot be changed once VM is provisioned.

Link copied to clipboard
val plan: Output<PlanArgs>? = null

Specifies information about the marketplace image used to create the virtual machine. This element is only used for marketplace images. Before you can use a marketplace image from an API, you must enable the image for programmatic use. In the Azure portal, find the marketplace image that you want to use and then click Want to deploy programmatically, Get Started ->. Enter any required information and then click Save.

Link copied to clipboard
val platformFaultDomain: Output<Int>? = null

Specifies the scale set logical fault domain into which the Virtual Machine will be created. By default, the Virtual Machine will by automatically assigned to a fault domain that best maintains balance across available fault domains.

  • This is applicable only if the 'virtualMachineScaleSet' property of this Virtual Machine is set.
  • The Virtual Machine Scale Set that is referenced, must have 'platformFaultDomainCount' > 1.
  • This property cannot be updated once the Virtual Machine is created.
  • Fault domain assignment can be viewed in the Virtual Machine Instance View.

    Minimum api‐version: 2020‐12‐01

  • Link copied to clipboard
    val priority: Output<Either<String, VirtualMachinePriorityTypes>>? = null

    Specifies the priority for the virtual machine.

    Minimum api-version: 2019-03-01

    Link copied to clipboard

    Specifies information about the proximity placement group that the virtual machine should be assigned to.

    Minimum api-version: 2018-04-01.

    Link copied to clipboard
    val resourceGroupName: Output<String>? = null

    The name of the resource group.

    Link copied to clipboard

    Specifies Scheduled Event related configurations.

    Link copied to clipboard

    Specifies the Security related profile settings for the virtual machine.

    Link copied to clipboard
    val storageProfile: Output<StorageProfileArgs>? = null

    Specifies the storage settings for the virtual machine disks.

    Link copied to clipboard
    val tags: Output<Map<String, String>>? = null

    Resource tags

    Link copied to clipboard
    val userData: Output<String>? = null

    UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here.

    Minimum api-version: 2021-03-01

    Link copied to clipboard

    Specifies information about the virtual machine scale set that the virtual machine should be assigned to. Virtual machines specified in the same virtual machine scale set are allocated to different nodes to maximize availability. Currently, a VM can only be added to virtual machine scale set at creation time. An existing VM cannot be added to a virtual machine scale set.

    This property cannot exist along with a non-null properties.availabilitySet reference.

    Minimum api‐version: 2019‐03‐01

    Link copied to clipboard
    val vmName: Output<String>? = null

    The name of the virtual machine.

    Link copied to clipboard
    val zones: Output<List<String>>? = null

    The virtual machine zones.

    Functions

    Link copied to clipboard
    open override fun toJava(): VirtualMachineArgs