Azure Classic

v5.25.0 published on Thursday, Nov 24, 2022 by Pulumi

AssignmentVirtualMachineScaleSet

Manages a maintenance assignment to a virtual machine scale set.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new()
    {
        Location = "West Europe",
    });

    var exampleVirtualNetwork = new Azure.Network.VirtualNetwork("exampleVirtualNetwork", new()
    {
        AddressSpaces = new[]
        {
            "10.0.0.0/16",
        },
        Location = exampleResourceGroup.Location,
        ResourceGroupName = exampleResourceGroup.Name,
    });

    var exampleSubnet = new Azure.Network.Subnet("exampleSubnet", new()
    {
        ResourceGroupName = exampleResourceGroup.Name,
        VirtualNetworkName = exampleVirtualNetwork.Name,
        AddressPrefixes = new[]
        {
            "10.0.2.0/24",
        },
    });

    var examplePublicIp = new Azure.Network.PublicIp("examplePublicIp", new()
    {
        Location = exampleResourceGroup.Location,
        ResourceGroupName = exampleResourceGroup.Name,
        AllocationMethod = "Static",
    });

    var exampleLoadBalancer = new Azure.Lb.LoadBalancer("exampleLoadBalancer", new()
    {
        Location = exampleResourceGroup.Location,
        ResourceGroupName = exampleResourceGroup.Name,
        FrontendIpConfigurations = new[]
        {
            new Azure.Lb.Inputs.LoadBalancerFrontendIpConfigurationArgs
            {
                Name = "internal",
                PublicIpAddressId = examplePublicIp.Id,
            },
        },
    });

    var exampleBackendAddressPool = new Azure.Lb.BackendAddressPool("exampleBackendAddressPool", new()
    {
        LoadbalancerId = exampleLoadBalancer.Id,
    });

    var exampleProbe = new Azure.Lb.Probe("exampleProbe", new()
    {
        LoadbalancerId = exampleLoadBalancer.Id,
        Port = 22,
        Protocol = "Tcp",
    });

    var exampleRule = new Azure.Lb.Rule("exampleRule", new()
    {
        LoadbalancerId = exampleLoadBalancer.Id,
        ProbeId = exampleProbe.Id,
        FrontendIpConfigurationName = "internal",
        Protocol = "Tcp",
        FrontendPort = 22,
        BackendPort = 22,
    });

    var exampleConfiguration = new Azure.Maintenance.Configuration("exampleConfiguration", new()
    {
        ResourceGroupName = exampleResourceGroup.Name,
        Location = exampleResourceGroup.Location,
        Scope = "OSImage",
        Visibility = "Custom",
        Window = new Azure.Maintenance.Inputs.ConfigurationWindowArgs
        {
            StartDateTime = "2021-12-31 00:00",
            ExpirationDateTime = "9999-12-31 00:00",
            Duration = "06:00",
            TimeZone = "Pacific Standard Time",
            RecurEvery = "1Days",
        },
    });

    var exampleNetworkInterface = new Azure.Network.NetworkInterface("exampleNetworkInterface", new()
    {
        Location = exampleResourceGroup.Location,
        ResourceGroupName = exampleResourceGroup.Name,
        IpConfigurations = new[]
        {
            new Azure.Network.Inputs.NetworkInterfaceIpConfigurationArgs
            {
                Name = "testconfiguration1",
                PrivateIpAddressAllocation = "Dynamic",
            },
        },
    });

    var exampleLinuxVirtualMachine = new Azure.Compute.LinuxVirtualMachine("exampleLinuxVirtualMachine", new()
    {
        ResourceGroupName = exampleResourceGroup.Name,
        Location = exampleResourceGroup.Location,
        Size = "Standard_F2",
        AdminUsername = "adminuser",
        NetworkInterfaceIds = new[]
        {
            exampleNetworkInterface.Id,
        },
        OsDisk = new Azure.Compute.Inputs.LinuxVirtualMachineOsDiskArgs
        {
            Caching = "ReadWrite",
            StorageAccountType = "Standard_LRS",
        },
    });

    var exampleLinuxVirtualMachineScaleSet = new Azure.Compute.LinuxVirtualMachineScaleSet("exampleLinuxVirtualMachineScaleSet", new()
    {
        ResourceGroupName = exampleResourceGroup.Name,
        Location = exampleResourceGroup.Location,
        Sku = "Standard_F2",
        Instances = 1,
        AdminUsername = "adminuser",
        AdminPassword = "P@ssword1234!",
        UpgradeMode = "Automatic",
        HealthProbeId = exampleProbe.Id,
        DisablePasswordAuthentication = false,
        SourceImageReference = new Azure.Compute.Inputs.LinuxVirtualMachineScaleSetSourceImageReferenceArgs
        {
            Publisher = "Canonical",
            Offer = "UbuntuServer",
            Sku = "16.04-LTS",
            Version = "latest",
        },
        OsDisk = new Azure.Compute.Inputs.LinuxVirtualMachineScaleSetOsDiskArgs
        {
            StorageAccountType = "Standard_LRS",
            Caching = "ReadWrite",
        },
        NetworkInterfaces = new[]
        {
            new Azure.Compute.Inputs.LinuxVirtualMachineScaleSetNetworkInterfaceArgs
            {
                Name = "example",
                Primary = true,
                IpConfigurations = new[]
                {
                    new Azure.Compute.Inputs.LinuxVirtualMachineScaleSetNetworkInterfaceIpConfigurationArgs
                    {
                        Name = "internal",
                        Primary = true,
                        SubnetId = exampleSubnet.Id,
                        LoadBalancerBackendAddressPoolIds = new[]
                        {
                            exampleBackendAddressPool.Id,
                        },
                    },
                },
            },
        },
        AutomaticOsUpgradePolicy = new Azure.Compute.Inputs.LinuxVirtualMachineScaleSetAutomaticOsUpgradePolicyArgs
        {
            DisableAutomaticRollback = true,
            EnableAutomaticOsUpgrade = true,
        },
        RollingUpgradePolicy = new Azure.Compute.Inputs.LinuxVirtualMachineScaleSetRollingUpgradePolicyArgs
        {
            MaxBatchInstancePercent = 20,
            MaxUnhealthyInstancePercent = 20,
            MaxUnhealthyUpgradedInstancePercent = 20,
            PauseTimeBetweenBatches = "PT0S",
        },
    }, new CustomResourceOptions
    {
        DependsOn = new[]
        {
            "azurerm_lb_rule.example",
        },
    });

    var exampleAssignmentVirtualMachineScaleSet = new Azure.Maintenance.AssignmentVirtualMachineScaleSet("exampleAssignmentVirtualMachineScaleSet", new()
    {
        Location = exampleResourceGroup.Location,
        MaintenanceConfigurationId = exampleConfiguration.Id,
        VirtualMachineScaleSetId = exampleLinuxVirtualMachine.Id,
    });

});
package main

import (
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/compute"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/lb"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/maintenance"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/network"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
			Location: pulumi.String("West Europe"),
		})
		if err != nil {
			return err
		}
		exampleVirtualNetwork, err := network.NewVirtualNetwork(ctx, "exampleVirtualNetwork", &network.VirtualNetworkArgs{
			AddressSpaces: pulumi.StringArray{
				pulumi.String("10.0.0.0/16"),
			},
			Location:          exampleResourceGroup.Location,
			ResourceGroupName: exampleResourceGroup.Name,
		})
		if err != nil {
			return err
		}
		exampleSubnet, err := network.NewSubnet(ctx, "exampleSubnet", &network.SubnetArgs{
			ResourceGroupName:  exampleResourceGroup.Name,
			VirtualNetworkName: exampleVirtualNetwork.Name,
			AddressPrefixes: pulumi.StringArray{
				pulumi.String("10.0.2.0/24"),
			},
		})
		if err != nil {
			return err
		}
		examplePublicIp, err := network.NewPublicIp(ctx, "examplePublicIp", &network.PublicIpArgs{
			Location:          exampleResourceGroup.Location,
			ResourceGroupName: exampleResourceGroup.Name,
			AllocationMethod:  pulumi.String("Static"),
		})
		if err != nil {
			return err
		}
		exampleLoadBalancer, err := lb.NewLoadBalancer(ctx, "exampleLoadBalancer", &lb.LoadBalancerArgs{
			Location:          exampleResourceGroup.Location,
			ResourceGroupName: exampleResourceGroup.Name,
			FrontendIpConfigurations: lb.LoadBalancerFrontendIpConfigurationArray{
				&lb.LoadBalancerFrontendIpConfigurationArgs{
					Name:              pulumi.String("internal"),
					PublicIpAddressId: examplePublicIp.ID(),
				},
			},
		})
		if err != nil {
			return err
		}
		exampleBackendAddressPool, err := lb.NewBackendAddressPool(ctx, "exampleBackendAddressPool", &lb.BackendAddressPoolArgs{
			LoadbalancerId: exampleLoadBalancer.ID(),
		})
		if err != nil {
			return err
		}
		exampleProbe, err := lb.NewProbe(ctx, "exampleProbe", &lb.ProbeArgs{
			LoadbalancerId: exampleLoadBalancer.ID(),
			Port:           pulumi.Int(22),
			Protocol:       pulumi.String("Tcp"),
		})
		if err != nil {
			return err
		}
		_, err = lb.NewRule(ctx, "exampleRule", &lb.RuleArgs{
			LoadbalancerId:              exampleLoadBalancer.ID(),
			ProbeId:                     exampleProbe.ID(),
			FrontendIpConfigurationName: pulumi.String("internal"),
			Protocol:                    pulumi.String("Tcp"),
			FrontendPort:                pulumi.Int(22),
			BackendPort:                 pulumi.Int(22),
		})
		if err != nil {
			return err
		}
		exampleConfiguration, err := maintenance.NewConfiguration(ctx, "exampleConfiguration", &maintenance.ConfigurationArgs{
			ResourceGroupName: exampleResourceGroup.Name,
			Location:          exampleResourceGroup.Location,
			Scope:             pulumi.String("OSImage"),
			Visibility:        pulumi.String("Custom"),
			Window: &maintenance.ConfigurationWindowArgs{
				StartDateTime:      pulumi.String("2021-12-31 00:00"),
				ExpirationDateTime: pulumi.String("9999-12-31 00:00"),
				Duration:           pulumi.String("06:00"),
				TimeZone:           pulumi.String("Pacific Standard Time"),
				RecurEvery:         pulumi.String("1Days"),
			},
		})
		if err != nil {
			return err
		}
		exampleNetworkInterface, err := network.NewNetworkInterface(ctx, "exampleNetworkInterface", &network.NetworkInterfaceArgs{
			Location:          exampleResourceGroup.Location,
			ResourceGroupName: exampleResourceGroup.Name,
			IpConfigurations: network.NetworkInterfaceIpConfigurationArray{
				&network.NetworkInterfaceIpConfigurationArgs{
					Name:                       pulumi.String("testconfiguration1"),
					PrivateIpAddressAllocation: pulumi.String("Dynamic"),
				},
			},
		})
		if err != nil {
			return err
		}
		exampleLinuxVirtualMachine, err := compute.NewLinuxVirtualMachine(ctx, "exampleLinuxVirtualMachine", &compute.LinuxVirtualMachineArgs{
			ResourceGroupName: exampleResourceGroup.Name,
			Location:          exampleResourceGroup.Location,
			Size:              pulumi.String("Standard_F2"),
			AdminUsername:     pulumi.String("adminuser"),
			NetworkInterfaceIds: pulumi.StringArray{
				exampleNetworkInterface.ID(),
			},
			OsDisk: &compute.LinuxVirtualMachineOsDiskArgs{
				Caching:            pulumi.String("ReadWrite"),
				StorageAccountType: pulumi.String("Standard_LRS"),
			},
		})
		if err != nil {
			return err
		}
		_, err = compute.NewLinuxVirtualMachineScaleSet(ctx, "exampleLinuxVirtualMachineScaleSet", &compute.LinuxVirtualMachineScaleSetArgs{
			ResourceGroupName:             exampleResourceGroup.Name,
			Location:                      exampleResourceGroup.Location,
			Sku:                           pulumi.String("Standard_F2"),
			Instances:                     pulumi.Int(1),
			AdminUsername:                 pulumi.String("adminuser"),
			AdminPassword:                 pulumi.String("P@ssword1234!"),
			UpgradeMode:                   pulumi.String("Automatic"),
			HealthProbeId:                 exampleProbe.ID(),
			DisablePasswordAuthentication: pulumi.Bool(false),
			SourceImageReference: &compute.LinuxVirtualMachineScaleSetSourceImageReferenceArgs{
				Publisher: pulumi.String("Canonical"),
				Offer:     pulumi.String("UbuntuServer"),
				Sku:       pulumi.String("16.04-LTS"),
				Version:   pulumi.String("latest"),
			},
			OsDisk: &compute.LinuxVirtualMachineScaleSetOsDiskArgs{
				StorageAccountType: pulumi.String("Standard_LRS"),
				Caching:            pulumi.String("ReadWrite"),
			},
			NetworkInterfaces: compute.LinuxVirtualMachineScaleSetNetworkInterfaceArray{
				&compute.LinuxVirtualMachineScaleSetNetworkInterfaceArgs{
					Name:    pulumi.String("example"),
					Primary: pulumi.Bool(true),
					IpConfigurations: compute.LinuxVirtualMachineScaleSetNetworkInterfaceIpConfigurationArray{
						&compute.LinuxVirtualMachineScaleSetNetworkInterfaceIpConfigurationArgs{
							Name:     pulumi.String("internal"),
							Primary:  pulumi.Bool(true),
							SubnetId: exampleSubnet.ID(),
							LoadBalancerBackendAddressPoolIds: pulumi.StringArray{
								exampleBackendAddressPool.ID(),
							},
						},
					},
				},
			},
			AutomaticOsUpgradePolicy: &compute.LinuxVirtualMachineScaleSetAutomaticOsUpgradePolicyArgs{
				DisableAutomaticRollback: pulumi.Bool(true),
				EnableAutomaticOsUpgrade: pulumi.Bool(true),
			},
			RollingUpgradePolicy: &compute.LinuxVirtualMachineScaleSetRollingUpgradePolicyArgs{
				MaxBatchInstancePercent:             pulumi.Int(20),
				MaxUnhealthyInstancePercent:         pulumi.Int(20),
				MaxUnhealthyUpgradedInstancePercent: pulumi.Int(20),
				PauseTimeBetweenBatches:             pulumi.String("PT0S"),
			},
		}, pulumi.DependsOn([]pulumi.Resource{
			pulumi.Resource("azurerm_lb_rule.example"),
		}))
		if err != nil {
			return err
		}
		_, err = maintenance.NewAssignmentVirtualMachineScaleSet(ctx, "exampleAssignmentVirtualMachineScaleSet", &maintenance.AssignmentVirtualMachineScaleSetArgs{
			Location:                   exampleResourceGroup.Location,
			MaintenanceConfigurationId: exampleConfiguration.ID(),
			VirtualMachineScaleSetId:   exampleLinuxVirtualMachine.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
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.PublicIp;
import com.pulumi.azure.network.PublicIpArgs;
import com.pulumi.azure.lb.LoadBalancer;
import com.pulumi.azure.lb.LoadBalancerArgs;
import com.pulumi.azure.lb.inputs.LoadBalancerFrontendIpConfigurationArgs;
import com.pulumi.azure.lb.BackendAddressPool;
import com.pulumi.azure.lb.BackendAddressPoolArgs;
import com.pulumi.azure.lb.Probe;
import com.pulumi.azure.lb.ProbeArgs;
import com.pulumi.azure.lb.Rule;
import com.pulumi.azure.lb.RuleArgs;
import com.pulumi.azure.maintenance.Configuration;
import com.pulumi.azure.maintenance.ConfigurationArgs;
import com.pulumi.azure.maintenance.inputs.ConfigurationWindowArgs;
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.LinuxVirtualMachineOsDiskArgs;
import com.pulumi.azure.compute.LinuxVirtualMachineScaleSet;
import com.pulumi.azure.compute.LinuxVirtualMachineScaleSetArgs;
import com.pulumi.azure.compute.inputs.LinuxVirtualMachineScaleSetSourceImageReferenceArgs;
import com.pulumi.azure.compute.inputs.LinuxVirtualMachineScaleSetOsDiskArgs;
import com.pulumi.azure.compute.inputs.LinuxVirtualMachineScaleSetNetworkInterfaceArgs;
import com.pulumi.azure.compute.inputs.LinuxVirtualMachineScaleSetAutomaticOsUpgradePolicyArgs;
import com.pulumi.azure.compute.inputs.LinuxVirtualMachineScaleSetRollingUpgradePolicyArgs;
import com.pulumi.azure.maintenance.AssignmentVirtualMachineScaleSet;
import com.pulumi.azure.maintenance.AssignmentVirtualMachineScaleSetArgs;
import com.pulumi.resources.CustomResourceOptions;
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 examplePublicIp = new PublicIp("examplePublicIp", PublicIpArgs.builder()        
            .location(exampleResourceGroup.location())
            .resourceGroupName(exampleResourceGroup.name())
            .allocationMethod("Static")
            .build());

        var exampleLoadBalancer = new LoadBalancer("exampleLoadBalancer", LoadBalancerArgs.builder()        
            .location(exampleResourceGroup.location())
            .resourceGroupName(exampleResourceGroup.name())
            .frontendIpConfigurations(LoadBalancerFrontendIpConfigurationArgs.builder()
                .name("internal")
                .publicIpAddressId(examplePublicIp.id())
                .build())
            .build());

        var exampleBackendAddressPool = new BackendAddressPool("exampleBackendAddressPool", BackendAddressPoolArgs.builder()        
            .loadbalancerId(exampleLoadBalancer.id())
            .build());

        var exampleProbe = new Probe("exampleProbe", ProbeArgs.builder()        
            .loadbalancerId(exampleLoadBalancer.id())
            .port(22)
            .protocol("Tcp")
            .build());

        var exampleRule = new Rule("exampleRule", RuleArgs.builder()        
            .loadbalancerId(exampleLoadBalancer.id())
            .probeId(exampleProbe.id())
            .frontendIpConfigurationName("internal")
            .protocol("Tcp")
            .frontendPort(22)
            .backendPort(22)
            .build());

        var exampleConfiguration = new Configuration("exampleConfiguration", ConfigurationArgs.builder()        
            .resourceGroupName(exampleResourceGroup.name())
            .location(exampleResourceGroup.location())
            .scope("OSImage")
            .visibility("Custom")
            .window(ConfigurationWindowArgs.builder()
                .startDateTime("2021-12-31 00:00")
                .expirationDateTime("9999-12-31 00:00")
                .duration("06:00")
                .timeZone("Pacific Standard Time")
                .recurEvery("1Days")
                .build())
            .build());

        var exampleNetworkInterface = new NetworkInterface("exampleNetworkInterface", NetworkInterfaceArgs.builder()        
            .location(exampleResourceGroup.location())
            .resourceGroupName(exampleResourceGroup.name())
            .ipConfigurations(NetworkInterfaceIpConfigurationArgs.builder()
                .name("testconfiguration1")
                .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())
            .osDisk(LinuxVirtualMachineOsDiskArgs.builder()
                .caching("ReadWrite")
                .storageAccountType("Standard_LRS")
                .build())
            .build());

        var exampleLinuxVirtualMachineScaleSet = new LinuxVirtualMachineScaleSet("exampleLinuxVirtualMachineScaleSet", LinuxVirtualMachineScaleSetArgs.builder()        
            .resourceGroupName(exampleResourceGroup.name())
            .location(exampleResourceGroup.location())
            .sku("Standard_F2")
            .instances(1)
            .adminUsername("adminuser")
            .adminPassword("P@ssword1234!")
            .upgradeMode("Automatic")
            .healthProbeId(exampleProbe.id())
            .disablePasswordAuthentication(false)
            .sourceImageReference(LinuxVirtualMachineScaleSetSourceImageReferenceArgs.builder()
                .publisher("Canonical")
                .offer("UbuntuServer")
                .sku("16.04-LTS")
                .version("latest")
                .build())
            .osDisk(LinuxVirtualMachineScaleSetOsDiskArgs.builder()
                .storageAccountType("Standard_LRS")
                .caching("ReadWrite")
                .build())
            .networkInterfaces(LinuxVirtualMachineScaleSetNetworkInterfaceArgs.builder()
                .name("example")
                .primary(true)
                .ipConfigurations(LinuxVirtualMachineScaleSetNetworkInterfaceIpConfigurationArgs.builder()
                    .name("internal")
                    .primary(true)
                    .subnetId(exampleSubnet.id())
                    .loadBalancerBackendAddressPoolIds(exampleBackendAddressPool.id())
                    .build())
                .build())
            .automaticOsUpgradePolicy(LinuxVirtualMachineScaleSetAutomaticOsUpgradePolicyArgs.builder()
                .disableAutomaticRollback(true)
                .enableAutomaticOsUpgrade(true)
                .build())
            .rollingUpgradePolicy(LinuxVirtualMachineScaleSetRollingUpgradePolicyArgs.builder()
                .maxBatchInstancePercent(20)
                .maxUnhealthyInstancePercent(20)
                .maxUnhealthyUpgradedInstancePercent(20)
                .pauseTimeBetweenBatches("PT0S")
                .build())
            .build(), CustomResourceOptions.builder()
                .dependsOn("azurerm_lb_rule.example")
                .build());

        var exampleAssignmentVirtualMachineScaleSet = new AssignmentVirtualMachineScaleSet("exampleAssignmentVirtualMachineScaleSet", AssignmentVirtualMachineScaleSetArgs.builder()        
            .location(exampleResourceGroup.location())
            .maintenanceConfigurationId(exampleConfiguration.id())
            .virtualMachineScaleSetId(exampleLinuxVirtualMachine.id())
            .build());

    }
}
import pulumi
import pulumi_azure as azure

example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_virtual_network = azure.network.VirtualNetwork("exampleVirtualNetwork",
    address_spaces=["10.0.0.0/16"],
    location=example_resource_group.location,
    resource_group_name=example_resource_group.name)
example_subnet = azure.network.Subnet("exampleSubnet",
    resource_group_name=example_resource_group.name,
    virtual_network_name=example_virtual_network.name,
    address_prefixes=["10.0.2.0/24"])
example_public_ip = azure.network.PublicIp("examplePublicIp",
    location=example_resource_group.location,
    resource_group_name=example_resource_group.name,
    allocation_method="Static")
example_load_balancer = azure.lb.LoadBalancer("exampleLoadBalancer",
    location=example_resource_group.location,
    resource_group_name=example_resource_group.name,
    frontend_ip_configurations=[azure.lb.LoadBalancerFrontendIpConfigurationArgs(
        name="internal",
        public_ip_address_id=example_public_ip.id,
    )])
example_backend_address_pool = azure.lb.BackendAddressPool("exampleBackendAddressPool", loadbalancer_id=example_load_balancer.id)
example_probe = azure.lb.Probe("exampleProbe",
    loadbalancer_id=example_load_balancer.id,
    port=22,
    protocol="Tcp")
example_rule = azure.lb.Rule("exampleRule",
    loadbalancer_id=example_load_balancer.id,
    probe_id=example_probe.id,
    frontend_ip_configuration_name="internal",
    protocol="Tcp",
    frontend_port=22,
    backend_port=22)
example_configuration = azure.maintenance.Configuration("exampleConfiguration",
    resource_group_name=example_resource_group.name,
    location=example_resource_group.location,
    scope="OSImage",
    visibility="Custom",
    window=azure.maintenance.ConfigurationWindowArgs(
        start_date_time="2021-12-31 00:00",
        expiration_date_time="9999-12-31 00:00",
        duration="06:00",
        time_zone="Pacific Standard Time",
        recur_every="1Days",
    ))
example_network_interface = azure.network.NetworkInterface("exampleNetworkInterface",
    location=example_resource_group.location,
    resource_group_name=example_resource_group.name,
    ip_configurations=[azure.network.NetworkInterfaceIpConfigurationArgs(
        name="testconfiguration1",
        private_ip_address_allocation="Dynamic",
    )])
example_linux_virtual_machine = azure.compute.LinuxVirtualMachine("exampleLinuxVirtualMachine",
    resource_group_name=example_resource_group.name,
    location=example_resource_group.location,
    size="Standard_F2",
    admin_username="adminuser",
    network_interface_ids=[example_network_interface.id],
    os_disk=azure.compute.LinuxVirtualMachineOsDiskArgs(
        caching="ReadWrite",
        storage_account_type="Standard_LRS",
    ))
example_linux_virtual_machine_scale_set = azure.compute.LinuxVirtualMachineScaleSet("exampleLinuxVirtualMachineScaleSet",
    resource_group_name=example_resource_group.name,
    location=example_resource_group.location,
    sku="Standard_F2",
    instances=1,
    admin_username="adminuser",
    admin_password="P@ssword1234!",
    upgrade_mode="Automatic",
    health_probe_id=example_probe.id,
    disable_password_authentication=False,
    source_image_reference=azure.compute.LinuxVirtualMachineScaleSetSourceImageReferenceArgs(
        publisher="Canonical",
        offer="UbuntuServer",
        sku="16.04-LTS",
        version="latest",
    ),
    os_disk=azure.compute.LinuxVirtualMachineScaleSetOsDiskArgs(
        storage_account_type="Standard_LRS",
        caching="ReadWrite",
    ),
    network_interfaces=[azure.compute.LinuxVirtualMachineScaleSetNetworkInterfaceArgs(
        name="example",
        primary=True,
        ip_configurations=[azure.compute.LinuxVirtualMachineScaleSetNetworkInterfaceIpConfigurationArgs(
            name="internal",
            primary=True,
            subnet_id=example_subnet.id,
            load_balancer_backend_address_pool_ids=[example_backend_address_pool.id],
        )],
    )],
    automatic_os_upgrade_policy=azure.compute.LinuxVirtualMachineScaleSetAutomaticOsUpgradePolicyArgs(
        disable_automatic_rollback=True,
        enable_automatic_os_upgrade=True,
    ),
    rolling_upgrade_policy=azure.compute.LinuxVirtualMachineScaleSetRollingUpgradePolicyArgs(
        max_batch_instance_percent=20,
        max_unhealthy_instance_percent=20,
        max_unhealthy_upgraded_instance_percent=20,
        pause_time_between_batches="PT0S",
    ),
    opts=pulumi.ResourceOptions(depends_on=["azurerm_lb_rule.example"]))
example_assignment_virtual_machine_scale_set = azure.maintenance.AssignmentVirtualMachineScaleSet("exampleAssignmentVirtualMachineScaleSet",
    location=example_resource_group.location,
    maintenance_configuration_id=example_configuration.id,
    virtual_machine_scale_set_id=example_linux_virtual_machine.id)
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleVirtualNetwork = new azure.network.VirtualNetwork("exampleVirtualNetwork", {
    addressSpaces: ["10.0.0.0/16"],
    location: exampleResourceGroup.location,
    resourceGroupName: exampleResourceGroup.name,
});
const exampleSubnet = new azure.network.Subnet("exampleSubnet", {
    resourceGroupName: exampleResourceGroup.name,
    virtualNetworkName: exampleVirtualNetwork.name,
    addressPrefixes: ["10.0.2.0/24"],
});
const examplePublicIp = new azure.network.PublicIp("examplePublicIp", {
    location: exampleResourceGroup.location,
    resourceGroupName: exampleResourceGroup.name,
    allocationMethod: "Static",
});
const exampleLoadBalancer = new azure.lb.LoadBalancer("exampleLoadBalancer", {
    location: exampleResourceGroup.location,
    resourceGroupName: exampleResourceGroup.name,
    frontendIpConfigurations: [{
        name: "internal",
        publicIpAddressId: examplePublicIp.id,
    }],
});
const exampleBackendAddressPool = new azure.lb.BackendAddressPool("exampleBackendAddressPool", {loadbalancerId: exampleLoadBalancer.id});
const exampleProbe = new azure.lb.Probe("exampleProbe", {
    loadbalancerId: exampleLoadBalancer.id,
    port: 22,
    protocol: "Tcp",
});
const exampleRule = new azure.lb.Rule("exampleRule", {
    loadbalancerId: exampleLoadBalancer.id,
    probeId: exampleProbe.id,
    frontendIpConfigurationName: "internal",
    protocol: "Tcp",
    frontendPort: 22,
    backendPort: 22,
});
const exampleConfiguration = new azure.maintenance.Configuration("exampleConfiguration", {
    resourceGroupName: exampleResourceGroup.name,
    location: exampleResourceGroup.location,
    scope: "OSImage",
    visibility: "Custom",
    window: {
        startDateTime: "2021-12-31 00:00",
        expirationDateTime: "9999-12-31 00:00",
        duration: "06:00",
        timeZone: "Pacific Standard Time",
        recurEvery: "1Days",
    },
});
const exampleNetworkInterface = new azure.network.NetworkInterface("exampleNetworkInterface", {
    location: exampleResourceGroup.location,
    resourceGroupName: exampleResourceGroup.name,
    ipConfigurations: [{
        name: "testconfiguration1",
        privateIpAddressAllocation: "Dynamic",
    }],
});
const exampleLinuxVirtualMachine = new azure.compute.LinuxVirtualMachine("exampleLinuxVirtualMachine", {
    resourceGroupName: exampleResourceGroup.name,
    location: exampleResourceGroup.location,
    size: "Standard_F2",
    adminUsername: "adminuser",
    networkInterfaceIds: [exampleNetworkInterface.id],
    osDisk: {
        caching: "ReadWrite",
        storageAccountType: "Standard_LRS",
    },
});
const exampleLinuxVirtualMachineScaleSet = new azure.compute.LinuxVirtualMachineScaleSet("exampleLinuxVirtualMachineScaleSet", {
    resourceGroupName: exampleResourceGroup.name,
    location: exampleResourceGroup.location,
    sku: "Standard_F2",
    instances: 1,
    adminUsername: "adminuser",
    adminPassword: "P@ssword1234!",
    upgradeMode: "Automatic",
    healthProbeId: exampleProbe.id,
    disablePasswordAuthentication: false,
    sourceImageReference: {
        publisher: "Canonical",
        offer: "UbuntuServer",
        sku: "16.04-LTS",
        version: "latest",
    },
    osDisk: {
        storageAccountType: "Standard_LRS",
        caching: "ReadWrite",
    },
    networkInterfaces: [{
        name: "example",
        primary: true,
        ipConfigurations: [{
            name: "internal",
            primary: true,
            subnetId: exampleSubnet.id,
            loadBalancerBackendAddressPoolIds: [exampleBackendAddressPool.id],
        }],
    }],
    automaticOsUpgradePolicy: {
        disableAutomaticRollback: true,
        enableAutomaticOsUpgrade: true,
    },
    rollingUpgradePolicy: {
        maxBatchInstancePercent: 20,
        maxUnhealthyInstancePercent: 20,
        maxUnhealthyUpgradedInstancePercent: 20,
        pauseTimeBetweenBatches: "PT0S",
    },
}, {
    dependsOn: ["azurerm_lb_rule.example"],
});
const exampleAssignmentVirtualMachineScaleSet = new azure.maintenance.AssignmentVirtualMachineScaleSet("exampleAssignmentVirtualMachineScaleSet", {
    location: exampleResourceGroup.location,
    maintenanceConfigurationId: exampleConfiguration.id,
    virtualMachineScaleSetId: exampleLinuxVirtualMachine.id,
});
resources:
  exampleResourceGroup:
    type: azure:core:ResourceGroup
    properties:
      location: West Europe
  exampleVirtualNetwork:
    type: azure:network:VirtualNetwork
    properties:
      addressSpaces:
        - 10.0.0.0/16
      location: ${exampleResourceGroup.location}
      resourceGroupName: ${exampleResourceGroup.name}
  exampleSubnet:
    type: azure:network:Subnet
    properties:
      resourceGroupName: ${exampleResourceGroup.name}
      virtualNetworkName: ${exampleVirtualNetwork.name}
      addressPrefixes:
        - 10.0.2.0/24
  examplePublicIp:
    type: azure:network:PublicIp
    properties:
      location: ${exampleResourceGroup.location}
      resourceGroupName: ${exampleResourceGroup.name}
      allocationMethod: Static
  exampleLoadBalancer:
    type: azure:lb:LoadBalancer
    properties:
      location: ${exampleResourceGroup.location}
      resourceGroupName: ${exampleResourceGroup.name}
      frontendIpConfigurations:
        - name: internal
          publicIpAddressId: ${examplePublicIp.id}
  exampleBackendAddressPool:
    type: azure:lb:BackendAddressPool
    properties:
      loadbalancerId: ${exampleLoadBalancer.id}
  exampleProbe:
    type: azure:lb:Probe
    properties:
      loadbalancerId: ${exampleLoadBalancer.id}
      port: 22
      protocol: Tcp
  exampleRule:
    type: azure:lb:Rule
    properties:
      loadbalancerId: ${exampleLoadBalancer.id}
      probeId: ${exampleProbe.id}
      frontendIpConfigurationName: internal
      protocol: Tcp
      frontendPort: 22
      backendPort: 22
  exampleConfiguration:
    type: azure:maintenance:Configuration
    properties:
      resourceGroupName: ${exampleResourceGroup.name}
      location: ${exampleResourceGroup.location}
      scope: OSImage
      visibility: Custom
      window:
        startDateTime: 2021-12-31 00:00
        expirationDateTime: 9999-12-31 00:00
        duration: 06:00
        timeZone: Pacific Standard Time
        recurEvery: 1Days
  exampleNetworkInterface:
    type: azure:network:NetworkInterface
    properties:
      location: ${exampleResourceGroup.location}
      resourceGroupName: ${exampleResourceGroup.name}
      ipConfigurations:
        - name: testconfiguration1
          privateIpAddressAllocation: Dynamic
  exampleLinuxVirtualMachine:
    type: azure:compute:LinuxVirtualMachine
    properties:
      resourceGroupName: ${exampleResourceGroup.name}
      location: ${exampleResourceGroup.location}
      size: Standard_F2
      adminUsername: adminuser
      networkInterfaceIds:
        - ${exampleNetworkInterface.id}
      osDisk:
        caching: ReadWrite
        storageAccountType: Standard_LRS
  exampleLinuxVirtualMachineScaleSet:
    type: azure:compute:LinuxVirtualMachineScaleSet
    properties:
      resourceGroupName: ${exampleResourceGroup.name}
      location: ${exampleResourceGroup.location}
      sku: Standard_F2
      instances: 1
      adminUsername: adminuser
      adminPassword: P@ssword1234!
      upgradeMode: Automatic
      healthProbeId: ${exampleProbe.id}
      disablePasswordAuthentication: false
      sourceImageReference:
        publisher: Canonical
        offer: UbuntuServer
        sku: 16.04-LTS
        version: latest
      osDisk:
        storageAccountType: Standard_LRS
        caching: ReadWrite
      networkInterfaces:
        - name: example
          primary: true
          ipConfigurations:
            - name: internal
              primary: true
              subnetId: ${exampleSubnet.id}
              loadBalancerBackendAddressPoolIds:
                - ${exampleBackendAddressPool.id}
      automaticOsUpgradePolicy:
        disableAutomaticRollback: true
        enableAutomaticOsUpgrade: true
      rollingUpgradePolicy:
        maxBatchInstancePercent: 20
        maxUnhealthyInstancePercent: 20
        maxUnhealthyUpgradedInstancePercent: 20
        pauseTimeBetweenBatches: PT0S
    options:
      dependson:
        - azurerm_lb_rule.example
  exampleAssignmentVirtualMachineScaleSet:
    type: azure:maintenance:AssignmentVirtualMachineScaleSet
    properties:
      location: ${exampleResourceGroup.location}
      maintenanceConfigurationId: ${exampleConfiguration.id}
      virtualMachineScaleSetId: ${exampleLinuxVirtualMachine.id}

Create AssignmentVirtualMachineScaleSet Resource

new AssignmentVirtualMachineScaleSet(name: string, args: AssignmentVirtualMachineScaleSetArgs, opts?: CustomResourceOptions);
@overload
def AssignmentVirtualMachineScaleSet(resource_name: str,
                                     opts: Optional[ResourceOptions] = None,
                                     location: Optional[str] = None,
                                     maintenance_configuration_id: Optional[str] = None,
                                     virtual_machine_scale_set_id: Optional[str] = None)
@overload
def AssignmentVirtualMachineScaleSet(resource_name: str,
                                     args: AssignmentVirtualMachineScaleSetArgs,
                                     opts: Optional[ResourceOptions] = None)
func NewAssignmentVirtualMachineScaleSet(ctx *Context, name string, args AssignmentVirtualMachineScaleSetArgs, opts ...ResourceOption) (*AssignmentVirtualMachineScaleSet, error)
public AssignmentVirtualMachineScaleSet(string name, AssignmentVirtualMachineScaleSetArgs args, CustomResourceOptions? opts = null)
public AssignmentVirtualMachineScaleSet(String name, AssignmentVirtualMachineScaleSetArgs args)
public AssignmentVirtualMachineScaleSet(String name, AssignmentVirtualMachineScaleSetArgs args, CustomResourceOptions options)
type: azure:maintenance:AssignmentVirtualMachineScaleSet
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args AssignmentVirtualMachineScaleSetArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args AssignmentVirtualMachineScaleSetArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args AssignmentVirtualMachineScaleSetArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args AssignmentVirtualMachineScaleSetArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args AssignmentVirtualMachineScaleSetArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

AssignmentVirtualMachineScaleSet Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The AssignmentVirtualMachineScaleSet resource accepts the following input properties:

MaintenanceConfigurationId string

Specifies the ID of the Maintenance Configuration Resource. Changing this forces a new resource to be created.

VirtualMachineScaleSetId string

Specifies the Virtual Machine Scale Set ID to which the Maintenance Configuration will be assigned. Changing this forces a new resource to be created.

Location string

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

MaintenanceConfigurationId string

Specifies the ID of the Maintenance Configuration Resource. Changing this forces a new resource to be created.

VirtualMachineScaleSetId string

Specifies the Virtual Machine Scale Set ID to which the Maintenance Configuration will be assigned. Changing this forces a new resource to be created.

Location string

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

maintenanceConfigurationId String

Specifies the ID of the Maintenance Configuration Resource. Changing this forces a new resource to be created.

virtualMachineScaleSetId String

Specifies the Virtual Machine Scale Set ID to which the Maintenance Configuration will be assigned. Changing this forces a new resource to be created.

location String

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

maintenanceConfigurationId string

Specifies the ID of the Maintenance Configuration Resource. Changing this forces a new resource to be created.

virtualMachineScaleSetId string

Specifies the Virtual Machine Scale Set ID to which the Maintenance Configuration will be assigned. Changing this forces a new resource to be created.

location string

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

maintenance_configuration_id str

Specifies the ID of the Maintenance Configuration Resource. Changing this forces a new resource to be created.

virtual_machine_scale_set_id str

Specifies the Virtual Machine Scale Set ID to which the Maintenance Configuration will be assigned. Changing this forces a new resource to be created.

location str

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

maintenanceConfigurationId String

Specifies the ID of the Maintenance Configuration Resource. Changing this forces a new resource to be created.

virtualMachineScaleSetId String

Specifies the Virtual Machine Scale Set ID to which the Maintenance Configuration will be assigned. Changing this forces a new resource to be created.

location String

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

Outputs

All input properties are implicitly available as output properties. Additionally, the AssignmentVirtualMachineScaleSet resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up Existing AssignmentVirtualMachineScaleSet Resource

Get an existing AssignmentVirtualMachineScaleSet resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: AssignmentVirtualMachineScaleSetState, opts?: CustomResourceOptions): AssignmentVirtualMachineScaleSet
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        location: Optional[str] = None,
        maintenance_configuration_id: Optional[str] = None,
        virtual_machine_scale_set_id: Optional[str] = None) -> AssignmentVirtualMachineScaleSet
func GetAssignmentVirtualMachineScaleSet(ctx *Context, name string, id IDInput, state *AssignmentVirtualMachineScaleSetState, opts ...ResourceOption) (*AssignmentVirtualMachineScaleSet, error)
public static AssignmentVirtualMachineScaleSet Get(string name, Input<string> id, AssignmentVirtualMachineScaleSetState? state, CustomResourceOptions? opts = null)
public static AssignmentVirtualMachineScaleSet get(String name, Output<String> id, AssignmentVirtualMachineScaleSetState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Location string

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

MaintenanceConfigurationId string

Specifies the ID of the Maintenance Configuration Resource. Changing this forces a new resource to be created.

VirtualMachineScaleSetId string

Specifies the Virtual Machine Scale Set ID to which the Maintenance Configuration will be assigned. Changing this forces a new resource to be created.

Location string

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

MaintenanceConfigurationId string

Specifies the ID of the Maintenance Configuration Resource. Changing this forces a new resource to be created.

VirtualMachineScaleSetId string

Specifies the Virtual Machine Scale Set ID to which the Maintenance Configuration will be assigned. Changing this forces a new resource to be created.

location String

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

maintenanceConfigurationId String

Specifies the ID of the Maintenance Configuration Resource. Changing this forces a new resource to be created.

virtualMachineScaleSetId String

Specifies the Virtual Machine Scale Set ID to which the Maintenance Configuration will be assigned. Changing this forces a new resource to be created.

location string

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

maintenanceConfigurationId string

Specifies the ID of the Maintenance Configuration Resource. Changing this forces a new resource to be created.

virtualMachineScaleSetId string

Specifies the Virtual Machine Scale Set ID to which the Maintenance Configuration will be assigned. Changing this forces a new resource to be created.

location str

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

maintenance_configuration_id str

Specifies the ID of the Maintenance Configuration Resource. Changing this forces a new resource to be created.

virtual_machine_scale_set_id str

Specifies the Virtual Machine Scale Set ID to which the Maintenance Configuration will be assigned. Changing this forces a new resource to be created.

location String

Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

maintenanceConfigurationId String

Specifies the ID of the Maintenance Configuration Resource. Changing this forces a new resource to be created.

virtualMachineScaleSetId String

Specifies the Virtual Machine Scale Set ID to which the Maintenance Configuration will be assigned. Changing this forces a new resource to be created.

Import

Maintenance Assignment can be imported using the resource id, e.g.

 $ pulumi import azure:maintenance/assignmentVirtualMachineScaleSet:AssignmentVirtualMachineScaleSet example /subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resGroup1/providers/microsoft.compute/virtualMachineScaleSets/vmss1/providers/Microsoft.Maintenance/configurationAssignments/assign1

Package Details

Repository
https://github.com/pulumi/pulumi-azure
License
Apache-2.0
Notes

This Pulumi package is based on the azurerm Terraform Provider.