ExtensionArgs

data class ExtensionArgs(val autoUpgradeMinorVersion: Output<Boolean>? = null, val automaticUpgradeEnabled: Output<Boolean>? = null, val failureSuppressionEnabled: Output<Boolean>? = null, val name: Output<String>? = null, val protectedSettings: Output<String>? = null, val protectedSettingsFromKeyVault: Output<ExtensionProtectedSettingsFromKeyVaultArgs>? = null, val provisionAfterExtensions: Output<List<String>>? = null, val publisher: Output<String>? = null, val settings: Output<String>? = null, val tags: Output<Map<String, String>>? = null, val type: Output<String>? = null, val typeHandlerVersion: Output<String>? = null, val virtualMachineId: Output<String>? = null) : ConvertibleToJava<ExtensionArgs>

Manages a Virtual Machine Extension to provide post deployment configuration and run automated tasks.

NOTE: Custom Script Extensions for Linux & Windows require that the commandToExecute returns a 0 exit code to be classified as successfully deployed. You can achieve this by appending exit 0 to the end of your commandToExecute. NOTE: Custom Script Extensions require that the Azure Virtual Machine Guest Agent is running on the Virtual Machine.

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.network.VirtualNetwork;
import com.pulumi.azure.network.VirtualNetworkArgs;
import com.pulumi.azure.network.Subnet;
import com.pulumi.azure.network.SubnetArgs;
import com.pulumi.azure.network.NetworkInterface;
import com.pulumi.azure.network.NetworkInterfaceArgs;
import com.pulumi.azure.network.inputs.NetworkInterfaceIpConfigurationArgs;
import com.pulumi.azure.compute.LinuxVirtualMachine;
import com.pulumi.azure.compute.LinuxVirtualMachineArgs;
import com.pulumi.azure.compute.inputs.LinuxVirtualMachineAdminSshKeyArgs;
import com.pulumi.azure.compute.inputs.LinuxVirtualMachineOsDiskArgs;
import com.pulumi.azure.compute.inputs.LinuxVirtualMachineSourceImageReferenceArgs;
import com.pulumi.azure.compute.Extension;
import com.pulumi.azure.compute.ExtensionArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()
.location("West Europe")
.build());
var exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()
.addressSpaces("10.0.0.0/16")
.location(exampleResourceGroup.location())
.resourceGroupName(exampleResourceGroup.name())
.build());
var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.virtualNetworkName(exampleVirtualNetwork.name())
.addressPrefixes("10.0.2.0/24")
.build());
var exampleNetworkInterface = new NetworkInterface("exampleNetworkInterface", NetworkInterfaceArgs.builder()
.location(exampleResourceGroup.location())
.resourceGroupName(exampleResourceGroup.name())
.ipConfigurations(NetworkInterfaceIpConfigurationArgs.builder()
.name("testconfiguration1")
.subnetId(exampleSubnet.id())
.privateIpAddressAllocation("Dynamic")
.build())
.build());
var exampleLinuxVirtualMachine = new LinuxVirtualMachine("exampleLinuxVirtualMachine", LinuxVirtualMachineArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.location(exampleResourceGroup.location())
.size("Standard_F2")
.adminUsername("adminuser")
.networkInterfaceIds(exampleNetworkInterface.id())
.adminSshKeys(LinuxVirtualMachineAdminSshKeyArgs.builder()
.username("adminuser")
.publicKey(Files.readString(Paths.get("~/.ssh/id_rsa.pub")))
.build())
.osDisk(LinuxVirtualMachineOsDiskArgs.builder()
.caching("ReadWrite")
.storageAccountType("Standard_LRS")
.build())
.sourceImageReference(LinuxVirtualMachineSourceImageReferenceArgs.builder()
.publisher("Canonical")
.offer("0001-com-ubuntu-server-focal")
.sku("20_04-lts")
.version("latest")
.build())
.build());
var exampleExtension = new Extension("exampleExtension", ExtensionArgs.builder()
.virtualMachineId(exampleLinuxVirtualMachine.id())
.publisher("Microsoft.Azure.Extensions")
.type("CustomScript")
.typeHandlerVersion("2.0")
.settings("""
{
"commandToExecute": "hostname && uptime"
}
""")
.tags(Map.of("environment", "Production"))
.build());
}
}

Import

Virtual Machine Extensions can be imported using the resource id, e.g.

$ pulumi import azure:compute/extension:Extension example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/myVM/extensions/extensionName

Constructors

Link copied to clipboard
fun ExtensionArgs(autoUpgradeMinorVersion: Output<Boolean>? = null, automaticUpgradeEnabled: Output<Boolean>? = null, failureSuppressionEnabled: Output<Boolean>? = null, name: Output<String>? = null, protectedSettings: Output<String>? = null, protectedSettingsFromKeyVault: Output<ExtensionProtectedSettingsFromKeyVaultArgs>? = null, provisionAfterExtensions: Output<List<String>>? = null, publisher: Output<String>? = null, settings: Output<String>? = null, tags: Output<Map<String, String>>? = null, type: Output<String>? = null, typeHandlerVersion: Output<String>? = null, virtualMachineId: Output<String>? = null)

Functions

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

Properties

Link copied to clipboard
val automaticUpgradeEnabled: Output<Boolean>? = null

Should the Extension be automatically updated whenever the Publisher releases a new version of this VM Extension?

Link copied to clipboard
val autoUpgradeMinorVersion: Output<Boolean>? = null

Specifies if the platform deploys the latest minor version update to the type_handler_version specified.

Link copied to clipboard
val failureSuppressionEnabled: Output<Boolean>? = null

Should failures from the extension be suppressed? Possible values are true or false. Defaults to false.

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

The name of the virtual machine extension peering. Changing this forces a new resource to be created.

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

The protected_settings passed to the extension, like settings, these are specified as a JSON object in a string.

Link copied to clipboard

A protected_settings_from_key_vault block as defined below.

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

Specifies the collection of extension names after which this extension needs to be provisioned.

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

The publisher of the extension, available publishers can be found by using the Azure CLI. Changing this forces a new resource to be created.

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

The settings passed to the extension, these are specified as a JSON object in a string.

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

A mapping of tags to assign to the resource.

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

The type of extension, available types for a publisher can be found using the Azure CLI.

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

Specifies the version of the extension to use, available versions can be found using the Azure CLI.

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

The ID of the Virtual Machine. Changing this forces a new resource to be created