VirtualMachineImageTemplateArgs

data class VirtualMachineImageTemplateArgs(val buildTimeoutInMinutes: Output<Int>? = null, val customize: Output<List<Any>>? = null, val distribute: Output<List<Any>>? = null, val identity: Output<ImageTemplateIdentityArgs>? = null, val imageTemplateName: Output<String>? = null, val location: Output<String>? = null, val resourceGroupName: Output<String>? = null, val source: Output<Any>? = null, val tags: Output<Map<String, String>>? = null, val vmProfile: Output<ImageTemplateVmProfileArgs>? = null) : ConvertibleToJava<VirtualMachineImageTemplateArgs>

Image template is an ARM resource managed by Microsoft.VirtualMachineImages provider API Version: 2020-02-14.

Example Usage

Create an Image Template for Linux.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachineImageTemplate = new AzureNative.VirtualMachineImages.VirtualMachineImageTemplate("virtualMachineImageTemplate", new()
{
Customize = new[]
{
new AzureNative.VirtualMachineImages.Inputs.ImageTemplateShellCustomizerArgs
{
Name = "Shell Customizer Example",
ScriptUri = "https://example.com/path/to/script.sh",
Type = "Shell",
},
},
Distribute = new[]
{
new AzureNative.VirtualMachineImages.Inputs.ImageTemplateManagedImageDistributorArgs
{
ArtifactTags =
{
{ "tagName", "value" },
},
ImageId = "/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1",
Location = "1_location",
RunOutputName = "image_it_pir_1",
Type = "ManagedImage",
},
},
Identity = new AzureNative.VirtualMachineImages.Inputs.ImageTemplateIdentityArgs
{
Type = AzureNative.VirtualMachineImages.ResourceIdentityType.UserAssigned,
UserAssignedIdentities =
{
{ "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1", null },
},
},
ImageTemplateName = "myImageTemplate",
Location = "westus",
ResourceGroupName = "myResourceGroup",
Source = new AzureNative.VirtualMachineImages.Inputs.ImageTemplateManagedImageSourceArgs
{
ImageId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/images/source_image",
Type = "ManagedImage",
},
Tags =
{
{ "imagetemplate_tag1", "IT_T1" },
{ "imagetemplate_tag2", "IT_T2" },
},
VmProfile = new AzureNative.VirtualMachineImages.Inputs.ImageTemplateVmProfileArgs
{
OsDiskSizeGB = 64,
VmSize = "Standard_D2s_v3",
VnetConfig = new AzureNative.VirtualMachineImages.Inputs.VirtualNetworkConfigArgs
{
SubnetId = "/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name",
},
},
});
});
package main
import (
virtualmachineimages "github.com/pulumi/pulumi-azure-native-sdk/virtualmachineimages"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := virtualmachineimages.NewVirtualMachineImageTemplate(ctx, "virtualMachineImageTemplate", &virtualmachineimages.VirtualMachineImageTemplateArgs{
Customize: pulumi.AnyArray{
virtualmachineimages.ImageTemplateShellCustomizer{
Name: "Shell Customizer Example",
ScriptUri: "https://example.com/path/to/script.sh",
Type: "Shell",
},
},
Distribute: pulumi.AnyArray{
virtualmachineimages.ImageTemplateManagedImageDistributor{
ArtifactTags: map[string]interface{}{
"tagName": "value",
},
ImageId: "/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1",
Location: "1_location",
RunOutputName: "image_it_pir_1",
Type: "ManagedImage",
},
},
Identity: &virtualmachineimages.ImageTemplateIdentityArgs{
Type: virtualmachineimages.ResourceIdentityTypeUserAssigned,
UserAssignedIdentities: pulumi.AnyMap{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1": nil,
},
},
ImageTemplateName: pulumi.String("myImageTemplate"),
Location: pulumi.String("westus"),
ResourceGroupName: pulumi.String("myResourceGroup"),
Source: virtualmachineimages.ImageTemplateManagedImageSource{
ImageId: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/images/source_image",
Type: "ManagedImage",
},
Tags: pulumi.StringMap{
"imagetemplate_tag1": pulumi.String("IT_T1"),
"imagetemplate_tag2": pulumi.String("IT_T2"),
},
VmProfile: virtualmachineimages.ImageTemplateVmProfileResponse{
OsDiskSizeGB: pulumi.Int(64),
VmSize: pulumi.String("Standard_D2s_v3"),
VnetConfig: &virtualmachineimages.VirtualNetworkConfigArgs{
SubnetId: pulumi.String("/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name"),
},
},
})
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.azurenative.virtualmachineimages.VirtualMachineImageTemplate;
import com.pulumi.azurenative.virtualmachineimages.VirtualMachineImageTemplateArgs;
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 virtualMachineImageTemplate = new VirtualMachineImageTemplate("virtualMachineImageTemplate", VirtualMachineImageTemplateArgs.builder()
.customize(Map.ofEntries(
Map.entry("name", "Shell Customizer Example"),
Map.entry("scriptUri", "https://example.com/path/to/script.sh"),
Map.entry("type", "Shell")
))
.distribute(Map.ofEntries(
Map.entry("artifactTags", ImageTemplateManagedImageDistributorArgs.builder()
.tagName("value")
.build()),
Map.entry("imageId", "/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1"),
Map.entry("location", "1_location"),
Map.entry("runOutputName", "image_it_pir_1"),
Map.entry("type", "ManagedImage")
))
.identity(Map.ofEntries(
Map.entry("type", "UserAssigned"),
Map.entry("userAssignedIdentities", Map.of("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1", ))
))
.imageTemplateName("myImageTemplate")
.location("westus")
.resourceGroupName("myResourceGroup")
.source(Map.ofEntries(
Map.entry("imageId", "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/images/source_image"),
Map.entry("type", "ManagedImage")
))
.tags(Map.ofEntries(
Map.entry("imagetemplate_tag1", "IT_T1"),
Map.entry("imagetemplate_tag2", "IT_T2")
))
.vmProfile(Map.ofEntries(
Map.entry("osDiskSizeGB", 64),
Map.entry("vmSize", "Standard_D2s_v3"),
Map.entry("vnetConfig", Map.of("subnetId", "/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name"))
))
.build());
}
}

Create an Image Template for Windows.

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var virtualMachineImageTemplate = new AzureNative.VirtualMachineImages.VirtualMachineImageTemplate("virtualMachineImageTemplate", new()
{
Customize = new[]
{
new AzureNative.VirtualMachineImages.Inputs.ImageTemplatePowerShellCustomizerArgs
{
Inline = new[]
{
"Powershell command-1",
"Powershell command-2",
"Powershell command-3",
},
Name = "PowerShell (inline) Customizer Example",
Type = "PowerShell",
},
new AzureNative.VirtualMachineImages.Inputs.ImageTemplatePowerShellCustomizerArgs
{
Inline = new[]
{
"Powershell command-1",
"Powershell command-2",
"Powershell command-3",
},
Name = "PowerShell (inline) Customizer Elevated user Example",
RunElevated = true,
Type = "PowerShell",
},
new AzureNative.VirtualMachineImages.Inputs.ImageTemplatePowerShellCustomizerArgs
{
Inline = new[]
{
"Powershell command-1",
"Powershell command-2",
"Powershell command-3",
},
Name = "PowerShell (inline) Customizer Elevated Local System user Example",
RunAsSystem = true,
RunElevated = true,
Type = "PowerShell",
},
new AzureNative.VirtualMachineImages.Inputs.ImageTemplatePowerShellCustomizerArgs
{
Name = "PowerShell (script) Customizer Example",
ScriptUri = "https://example.com/path/to/script.ps1",
Type = "PowerShell",
ValidExitCodes = new[]
{
0,
1,
},
},
new AzureNative.VirtualMachineImages.Inputs.ImageTemplatePowerShellCustomizerArgs
{
Name = "PowerShell (script) Customizer Elevated Local System user Example",
RunElevated = true,
ScriptUri = "https://example.com/path/to/script.ps1",
Type = "PowerShell",
ValidExitCodes = new[]
{
0,
1,
},
},
new AzureNative.VirtualMachineImages.Inputs.ImageTemplatePowerShellCustomizerArgs
{
Name = "PowerShell (script) Customizer Elevated Local System user Example",
RunAsSystem = true,
RunElevated = true,
ScriptUri = "https://example.com/path/to/script.ps1",
Type = "PowerShell",
ValidExitCodes = new[]
{
0,
1,
},
},
new AzureNative.VirtualMachineImages.Inputs.ImageTemplateRestartCustomizerArgs
{
Name = "Restart Customizer Example",
RestartCheckCommand = "powershell -command \"& {Write-Output 'restarted.'}\"",
RestartCommand = "shutdown /f /r /t 0 /c \"packer restart\"",
RestartTimeout = "10m",
Type = "WindowsRestart",
},
new AzureNative.VirtualMachineImages.Inputs.ImageTemplateWindowsUpdateCustomizerArgs
{
Filters = new[]
{
"$_.BrowseOnly",
},
Name = "Windows Update Customizer Example",
SearchCriteria = "BrowseOnly=0 and IsInstalled=0",
Type = "WindowsUpdate",
UpdateLimit = 100,
},
},
Distribute = new[]
{
new AzureNative.VirtualMachineImages.Inputs.ImageTemplateManagedImageDistributorArgs
{
ArtifactTags =
{
{ "tagName", "value" },
},
ImageId = "/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1",
Location = "1_location",
RunOutputName = "image_it_pir_1",
Type = "ManagedImage",
},
},
Identity = new AzureNative.VirtualMachineImages.Inputs.ImageTemplateIdentityArgs
{
Type = AzureNative.VirtualMachineImages.ResourceIdentityType.UserAssigned,
UserAssignedIdentities =
{
{ "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1", null },
},
},
ImageTemplateName = "myImageTemplate",
Location = "westus",
ResourceGroupName = "myResourceGroup",
Source = new AzureNative.VirtualMachineImages.Inputs.ImageTemplateManagedImageSourceArgs
{
ImageId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/images/source_image",
Type = "ManagedImage",
},
Tags =
{
{ "imagetemplate_tag1", "IT_T1" },
{ "imagetemplate_tag2", "IT_T2" },
},
VmProfile = new AzureNative.VirtualMachineImages.Inputs.ImageTemplateVmProfileArgs
{
OsDiskSizeGB = 64,
VmSize = "Standard_D2s_v3",
VnetConfig = new AzureNative.VirtualMachineImages.Inputs.VirtualNetworkConfigArgs
{
SubnetId = "/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name",
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.virtualmachineimages.VirtualMachineImageTemplate;
import com.pulumi.azurenative.virtualmachineimages.VirtualMachineImageTemplateArgs;
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 virtualMachineImageTemplate = new VirtualMachineImageTemplate("virtualMachineImageTemplate", VirtualMachineImageTemplateArgs.builder()
.customize(
Map.ofEntries(
Map.entry("inline",
"Powershell command-1",
"Powershell command-2",
"Powershell command-3"),
Map.entry("name", "PowerShell (inline) Customizer Example"),
Map.entry("type", "PowerShell")
),
Map.ofEntries(
Map.entry("inline",
"Powershell command-1",
"Powershell command-2",
"Powershell command-3"),
Map.entry("name", "PowerShell (inline) Customizer Elevated user Example"),
Map.entry("runElevated", true),
Map.entry("type", "PowerShell")
),
Map.ofEntries(
Map.entry("inline",
"Powershell command-1",
"Powershell command-2",
"Powershell command-3"),
Map.entry("name", "PowerShell (inline) Customizer Elevated Local System user Example"),
Map.entry("runAsSystem", true),
Map.entry("runElevated", true),
Map.entry("type", "PowerShell")
),
Map.ofEntries(
Map.entry("name", "PowerShell (script) Customizer Example"),
Map.entry("scriptUri", "https://example.com/path/to/script.ps1"),
Map.entry("type", "PowerShell"),
Map.entry("validExitCodes",
0,
1)
),
Map.ofEntries(
Map.entry("name", "PowerShell (script) Customizer Elevated Local System user Example"),
Map.entry("runElevated", true),
Map.entry("scriptUri", "https://example.com/path/to/script.ps1"),
Map.entry("type", "PowerShell"),
Map.entry("validExitCodes",
0,
1)
),
Map.ofEntries(
Map.entry("name", "PowerShell (script) Customizer Elevated Local System user Example"),
Map.entry("runAsSystem", true),
Map.entry("runElevated", true),
Map.entry("scriptUri", "https://example.com/path/to/script.ps1"),
Map.entry("type", "PowerShell"),
Map.entry("validExitCodes",
0,
1)
),
Map.ofEntries(
Map.entry("name", "Restart Customizer Example"),
Map.entry("restartCheckCommand", "powershell -command \"& {Write-Output 'restarted.'}\""),
Map.entry("restartCommand", "shutdown /f /r /t 0 /c \"packer restart\""),
Map.entry("restartTimeout", "10m"),
Map.entry("type", "WindowsRestart")
),
Map.ofEntries(
Map.entry("filters", "$_.BrowseOnly"),
Map.entry("name", "Windows Update Customizer Example"),
Map.entry("searchCriteria", "BrowseOnly=0 and IsInstalled=0"),
Map.entry("type", "WindowsUpdate"),
Map.entry("updateLimit", 100)
))
.distribute(Map.ofEntries(
Map.entry("artifactTags", ImageTemplateManagedImageDistributorArgs.builder()
.tagName("value")
.build()),
Map.entry("imageId", "/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Compute/images/image_it_1"),
Map.entry("location", "1_location"),
Map.entry("runOutputName", "image_it_pir_1"),
Map.entry("type", "ManagedImage")
))
.identity(Map.ofEntries(
Map.entry("type", "UserAssigned"),
Map.entry("userAssignedIdentities", Map.of("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity_1", ))
))
.imageTemplateName("myImageTemplate")
.location("westus")
.resourceGroupName("myResourceGroup")
.source(Map.ofEntries(
Map.entry("imageId", "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Compute/images/source_image"),
Map.entry("type", "ManagedImage")
))
.tags(Map.ofEntries(
Map.entry("imagetemplate_tag1", "IT_T1"),
Map.entry("imagetemplate_tag2", "IT_T2")
))
.vmProfile(Map.ofEntries(
Map.entry("osDiskSizeGB", 64),
Map.entry("vmSize", "Standard_D2s_v3"),
Map.entry("vnetConfig", Map.of("subnetId", "/subscriptions/{subscription-id}/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name"))
))
.build());
}
}

Import

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

$ pulumi import azure-native:virtualmachineimages:VirtualMachineImageTemplate myImageTemplate /subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.VirtualMachineImages/imageTemplates/myImageTemplate

Constructors

Link copied to clipboard
constructor(buildTimeoutInMinutes: Output<Int>? = null, customize: Output<List<Any>>? = null, distribute: Output<List<Any>>? = null, identity: Output<ImageTemplateIdentityArgs>? = null, imageTemplateName: Output<String>? = null, location: Output<String>? = null, resourceGroupName: Output<String>? = null, source: Output<Any>? = null, tags: Output<Map<String, String>>? = null, vmProfile: Output<ImageTemplateVmProfileArgs>? = null)

Properties

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

Maximum duration to wait while building the image template. Omit or specify 0 to use the default (4 hours).

Link copied to clipboard
val customize: Output<List<Any>>? = null

Specifies the properties used to describe the customization steps of the image, like Image source etc

Link copied to clipboard
val distribute: Output<List<Any>>? = null

The distribution targets where the image output needs to go to.

Link copied to clipboard
val identity: Output<ImageTemplateIdentityArgs>? = null

The identity of the image template, if configured.

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

The name of the image Template

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

Resource location

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

The name of the resource group.

Link copied to clipboard
val source: Output<Any>? = null

Specifies the properties used to describe the source image.

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

Resource tags

Link copied to clipboard

Describes how virtual machine is set up to build images

Functions

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