TemplateDeployment

Manages a template deployment of resources

Note on ARM Template Deployments: Due to the way the underlying Azure API is designed, this provider can only manage the deployment of the ARM Template - and not any resources which are created by it. This means that when deleting the azure.core.TemplateDeployment resource, this provider will only remove the reference to the deployment, whilst leaving any resources created by that ARM Template Deployment. One workaround for this is to use a unique Resource Group for each ARM Template Deployment, which means deleting the Resource Group would contain any resources created within it - however this isn’t ideal. More information.

Note

This provider does not know about the individual resources created by Azure using a deployment template and therefore cannot delete these resources during a destroy. Destroying a template deployment removes the associated deployment operations, but will not delete the Azure resources created by the deployment. In order to delete these resources, the containing resource group must also be destroyed. More information.

Example Usage

using Pulumi;
using Azure = Pulumi.Azure;

class MyStack : Stack
{
    public MyStack()
    {
        var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new Azure.Core.ResourceGroupArgs
        {
            Location = "West Europe",
        });
        var exampleTemplateDeployment = new Azure.Core.TemplateDeployment("exampleTemplateDeployment", new Azure.Core.TemplateDeploymentArgs
        {
            ResourceGroupName = exampleResourceGroup.Name,
            TemplateBody = @"{
  ""$schema"": ""https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"",
  ""contentVersion"": ""1.0.0.0"",
  ""parameters"": {
    ""storageAccountType"": {
      ""type"": ""string"",
      ""defaultValue"": ""Standard_LRS"",
      ""allowedValues"": [
        ""Standard_LRS"",
        ""Standard_GRS"",
        ""Standard_ZRS""
      ],
      ""metadata"": {
        ""description"": ""Storage Account type""
      }
    }
  },
  ""variables"": {
    ""location"": ""[resourceGroup().location]"",
    ""storageAccountName"": ""[concat(uniquestring(resourceGroup().id), 'storage')]"",
    ""publicIPAddressName"": ""[concat('myPublicIp', uniquestring(resourceGroup().id))]"",
    ""publicIPAddressType"": ""Dynamic"",
    ""apiVersion"": ""2015-06-15"",
    ""dnsLabelPrefix"": ""example-acctest""
  },
  ""resources"": [
    {
      ""type"": ""Microsoft.Storage/storageAccounts"",
      ""name"": ""[variables('storageAccountName')]"",
      ""apiVersion"": ""[variables('apiVersion')]"",
      ""location"": ""[variables('location')]"",
      ""properties"": {
        ""accountType"": ""[parameters('storageAccountType')]""
      }
    },
    {
      ""type"": ""Microsoft.Network/publicIPAddresses"",
      ""apiVersion"": ""[variables('apiVersion')]"",
      ""name"": ""[variables('publicIPAddressName')]"",
      ""location"": ""[variables('location')]"",
      ""properties"": {
        ""publicIPAllocationMethod"": ""[variables('publicIPAddressType')]"",
        ""dnsSettings"": {
          ""domainNameLabel"": ""[variables('dnsLabelPrefix')]""
        }
      }
    }
  ],
  ""outputs"": {
    ""storageAccountName"": {
      ""type"": ""string"",
      ""value"": ""[variables('storageAccountName')]""
    }
  }
}
",
            Parameters = 
            {
                { "storageAccountType", "Standard_GRS" },
            },
            DeploymentMode = "Incremental",
        });
        this.StorageAccountName = exampleTemplateDeployment.Outputs.Apply(outputs => outputs.StorageAccountName);
    }

    [Output("storageAccountName")]
    public Output<string> StorageAccountName { get; set; }
}
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/core"
	"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
		}
		exampleTemplateDeployment, err := core.NewTemplateDeployment(ctx, "exampleTemplateDeployment", &core.TemplateDeploymentArgs{
			ResourceGroupName: exampleResourceGroup.Name,
			TemplateBody:      pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v%v", "{\n", "  \"", "$", "schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\n", "  \"contentVersion\": \"1.0.0.0\",\n", "  \"parameters\": {\n", "    \"storageAccountType\": {\n", "      \"type\": \"string\",\n", "      \"defaultValue\": \"Standard_LRS\",\n", "      \"allowedValues\": [\n", "        \"Standard_LRS\",\n", "        \"Standard_GRS\",\n", "        \"Standard_ZRS\"\n", "      ],\n", "      \"metadata\": {\n", "        \"description\": \"Storage Account type\"\n", "      }\n", "    }\n", "  },\n", "  \"variables\": {\n", "    \"location\": \"[resourceGroup().location]\",\n", "    \"storageAccountName\": \"[concat(uniquestring(resourceGroup().id), 'storage')]\",\n", "    \"publicIPAddressName\": \"[concat('myPublicIp', uniquestring(resourceGroup().id))]\",\n", "    \"publicIPAddressType\": \"Dynamic\",\n", "    \"apiVersion\": \"2015-06-15\",\n", "    \"dnsLabelPrefix\": \"example-acctest\"\n", "  },\n", "  \"resources\": [\n", "    {\n", "      \"type\": \"Microsoft.Storage/storageAccounts\",\n", "      \"name\": \"[variables('storageAccountName')]\",\n", "      \"apiVersion\": \"[variables('apiVersion')]\",\n", "      \"location\": \"[variables('location')]\",\n", "      \"properties\": {\n", "        \"accountType\": \"[parameters('storageAccountType')]\"\n", "      }\n", "    },\n", "    {\n", "      \"type\": \"Microsoft.Network/publicIPAddresses\",\n", "      \"apiVersion\": \"[variables('apiVersion')]\",\n", "      \"name\": \"[variables('publicIPAddressName')]\",\n", "      \"location\": \"[variables('location')]\",\n", "      \"properties\": {\n", "        \"publicIPAllocationMethod\": \"[variables('publicIPAddressType')]\",\n", "        \"dnsSettings\": {\n", "          \"domainNameLabel\": \"[variables('dnsLabelPrefix')]\"\n", "        }\n", "      }\n", "    }\n", "  ],\n", "  \"outputs\": {\n", "    \"storageAccountName\": {\n", "      \"type\": \"string\",\n", "      \"value\": \"[variables('storageAccountName')]\"\n", "    }\n", "  }\n", "}\n")),
			Parameters: pulumi.StringMap{
				"storageAccountType": pulumi.String("Standard_GRS"),
			},
			DeploymentMode: pulumi.String("Incremental"),
		})
		if err != nil {
			return err
		}
		ctx.Export("storageAccountName", exampleTemplateDeployment.Outputs.ApplyT(func(outputs map[string]string) (string, error) {
			return outputs.StorageAccountName, nil
		}).(pulumi.StringOutput))
		return nil
	})
}
import pulumi
import pulumi_azure as azure

example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_template_deployment = azure.core.TemplateDeployment("exampleTemplateDeployment",
    resource_group_name=example_resource_group.name,
    template_body="""{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "storageAccountType": {
      "type": "string",
      "defaultValue": "Standard_LRS",
      "allowedValues": [
        "Standard_LRS",
        "Standard_GRS",
        "Standard_ZRS"
      ],
      "metadata": {
        "description": "Storage Account type"
      }
    }
  },
  "variables": {
    "location": "[resourceGroup().location]",
    "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'storage')]",
    "publicIPAddressName": "[concat('myPublicIp', uniquestring(resourceGroup().id))]",
    "publicIPAddressType": "Dynamic",
    "apiVersion": "2015-06-15",
    "dnsLabelPrefix": "example-acctest"
  },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "name": "[variables('storageAccountName')]",
      "apiVersion": "[variables('apiVersion')]",
      "location": "[variables('location')]",
      "properties": {
        "accountType": "[parameters('storageAccountType')]"
      }
    },
    {
      "type": "Microsoft.Network/publicIPAddresses",
      "apiVersion": "[variables('apiVersion')]",
      "name": "[variables('publicIPAddressName')]",
      "location": "[variables('location')]",
      "properties": {
        "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
        "dnsSettings": {
          "domainNameLabel": "[variables('dnsLabelPrefix')]"
        }
      }
    }
  ],
  "outputs": {
    "storageAccountName": {
      "type": "string",
      "value": "[variables('storageAccountName')]"
    }
  }
}
""",
    parameters={
        "storageAccountType": "Standard_GRS",
    },
    deployment_mode="Incremental")
pulumi.export("storageAccountName", example_template_deployment.outputs["storageAccountName"])
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleTemplateDeployment = new azure.core.TemplateDeployment("exampleTemplateDeployment", {
    resourceGroupName: exampleResourceGroup.name,
    templateBody: `{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "storageAccountType": {
      "type": "string",
      "defaultValue": "Standard_LRS",
      "allowedValues": [
        "Standard_LRS",
        "Standard_GRS",
        "Standard_ZRS"
      ],
      "metadata": {
        "description": "Storage Account type"
      }
    }
  },
  "variables": {
    "location": "[resourceGroup().location]",
    "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'storage')]",
    "publicIPAddressName": "[concat('myPublicIp', uniquestring(resourceGroup().id))]",
    "publicIPAddressType": "Dynamic",
    "apiVersion": "2015-06-15",
    "dnsLabelPrefix": "example-acctest"
  },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "name": "[variables('storageAccountName')]",
      "apiVersion": "[variables('apiVersion')]",
      "location": "[variables('location')]",
      "properties": {
        "accountType": "[parameters('storageAccountType')]"
      }
    },
    {
      "type": "Microsoft.Network/publicIPAddresses",
      "apiVersion": "[variables('apiVersion')]",
      "name": "[variables('publicIPAddressName')]",
      "location": "[variables('location')]",
      "properties": {
        "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
        "dnsSettings": {
          "domainNameLabel": "[variables('dnsLabelPrefix')]"
        }
      }
    }
  ],
  "outputs": {
    "storageAccountName": {
      "type": "string",
      "value": "[variables('storageAccountName')]"
    }
  }
}
`,
    parameters: {
        storageAccountType: "Standard_GRS",
    },
    deploymentMode: "Incremental",
});
export const storageAccountName = exampleTemplateDeployment.outputs.storageAccountName;

Create a TemplateDeployment Resource

new TemplateDeployment(name: string, args: TemplateDeploymentArgs, opts?: CustomResourceOptions);
@overload
def TemplateDeployment(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       deployment_mode: Optional[str] = None,
                       name: Optional[str] = None,
                       parameters: Optional[Mapping[str, str]] = None,
                       parameters_body: Optional[str] = None,
                       resource_group_name: Optional[str] = None,
                       template_body: Optional[str] = None)
@overload
def TemplateDeployment(resource_name: str,
                       args: TemplateDeploymentArgs,
                       opts: Optional[ResourceOptions] = None)
func NewTemplateDeployment(ctx *Context, name string, args TemplateDeploymentArgs, opts ...ResourceOption) (*TemplateDeployment, error)
public TemplateDeployment(string name, TemplateDeploymentArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args TemplateDeploymentArgs
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 TemplateDeploymentArgs
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 TemplateDeploymentArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args TemplateDeploymentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

TemplateDeployment 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 TemplateDeployment resource accepts the following input properties:

DeploymentMode string
Specifies the mode that is used to deploy resources. This value could be either Incremental or Complete. Note that you will almost always want this to be set to Incremental otherwise the deployment will destroy all infrastructure not specified within the template, and this provider will not be aware of this.
ResourceGroupName string
The name of the resource group in which to create the template deployment.
Name string
Specifies the name of the template deployment. Changing this forces a new resource to be created.
Parameters Dictionary<string, string>
Specifies the name and value pairs that define the deployment parameters for the template.
ParametersBody string
Specifies a valid Azure JSON parameters file that define the deployment parameters. It can contain KeyVault references
TemplateBody string
Specifies the JSON definition for the template.
DeploymentMode string
Specifies the mode that is used to deploy resources. This value could be either Incremental or Complete. Note that you will almost always want this to be set to Incremental otherwise the deployment will destroy all infrastructure not specified within the template, and this provider will not be aware of this.
ResourceGroupName string
The name of the resource group in which to create the template deployment.
Name string
Specifies the name of the template deployment. Changing this forces a new resource to be created.
Parameters map[string]string
Specifies the name and value pairs that define the deployment parameters for the template.
ParametersBody string
Specifies a valid Azure JSON parameters file that define the deployment parameters. It can contain KeyVault references
TemplateBody string
Specifies the JSON definition for the template.
deploymentMode string
Specifies the mode that is used to deploy resources. This value could be either Incremental or Complete. Note that you will almost always want this to be set to Incremental otherwise the deployment will destroy all infrastructure not specified within the template, and this provider will not be aware of this.
resourceGroupName string
The name of the resource group in which to create the template deployment.
name string
Specifies the name of the template deployment. Changing this forces a new resource to be created.
parameters {[key: string]: string}
Specifies the name and value pairs that define the deployment parameters for the template.
parametersBody string
Specifies a valid Azure JSON parameters file that define the deployment parameters. It can contain KeyVault references
templateBody string
Specifies the JSON definition for the template.
deployment_mode str
Specifies the mode that is used to deploy resources. This value could be either Incremental or Complete. Note that you will almost always want this to be set to Incremental otherwise the deployment will destroy all infrastructure not specified within the template, and this provider will not be aware of this.
resource_group_name str
The name of the resource group in which to create the template deployment.
name str
Specifies the name of the template deployment. Changing this forces a new resource to be created.
parameters Mapping[str, str]
Specifies the name and value pairs that define the deployment parameters for the template.
parameters_body str
Specifies a valid Azure JSON parameters file that define the deployment parameters. It can contain KeyVault references
template_body str
Specifies the JSON definition for the template.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Outputs Dictionary<string, string>
A map of supported scalar output types returned from the deployment (currently, Azure Template Deployment outputs of type String, Int and Bool are supported, and are converted to strings - others will be ignored) and can be accessed using .outputs["name"].
Id string
The provider-assigned unique ID for this managed resource.
Outputs map[string]string
A map of supported scalar output types returned from the deployment (currently, Azure Template Deployment outputs of type String, Int and Bool are supported, and are converted to strings - others will be ignored) and can be accessed using .outputs["name"].
id string
The provider-assigned unique ID for this managed resource.
outputs {[key: string]: string}
A map of supported scalar output types returned from the deployment (currently, Azure Template Deployment outputs of type String, Int and Bool are supported, and are converted to strings - others will be ignored) and can be accessed using .outputs["name"].
id str
The provider-assigned unique ID for this managed resource.
outputs Mapping[str, str]
A map of supported scalar output types returned from the deployment (currently, Azure Template Deployment outputs of type String, Int and Bool are supported, and are converted to strings - others will be ignored) and can be accessed using .outputs["name"].

Look up an Existing TemplateDeployment Resource

Get an existing TemplateDeployment 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?: TemplateDeploymentState, opts?: CustomResourceOptions): TemplateDeployment
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        deployment_mode: Optional[str] = None,
        name: Optional[str] = None,
        outputs: Optional[Mapping[str, str]] = None,
        parameters: Optional[Mapping[str, str]] = None,
        parameters_body: Optional[str] = None,
        resource_group_name: Optional[str] = None,
        template_body: Optional[str] = None) -> TemplateDeployment
func GetTemplateDeployment(ctx *Context, name string, id IDInput, state *TemplateDeploymentState, opts ...ResourceOption) (*TemplateDeployment, error)
public static TemplateDeployment Get(string name, Input<string> id, TemplateDeploymentState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

DeploymentMode string
Specifies the mode that is used to deploy resources. This value could be either Incremental or Complete. Note that you will almost always want this to be set to Incremental otherwise the deployment will destroy all infrastructure not specified within the template, and this provider will not be aware of this.
Name string
Specifies the name of the template deployment. Changing this forces a new resource to be created.
Outputs Dictionary<string, string>
A map of supported scalar output types returned from the deployment (currently, Azure Template Deployment outputs of type String, Int and Bool are supported, and are converted to strings - others will be ignored) and can be accessed using .outputs["name"].
Parameters Dictionary<string, string>
Specifies the name and value pairs that define the deployment parameters for the template.
ParametersBody string
Specifies a valid Azure JSON parameters file that define the deployment parameters. It can contain KeyVault references
ResourceGroupName string
The name of the resource group in which to create the template deployment.
TemplateBody string
Specifies the JSON definition for the template.
DeploymentMode string
Specifies the mode that is used to deploy resources. This value could be either Incremental or Complete. Note that you will almost always want this to be set to Incremental otherwise the deployment will destroy all infrastructure not specified within the template, and this provider will not be aware of this.
Name string
Specifies the name of the template deployment. Changing this forces a new resource to be created.
Outputs map[string]string
A map of supported scalar output types returned from the deployment (currently, Azure Template Deployment outputs of type String, Int and Bool are supported, and are converted to strings - others will be ignored) and can be accessed using .outputs["name"].
Parameters map[string]string
Specifies the name and value pairs that define the deployment parameters for the template.
ParametersBody string
Specifies a valid Azure JSON parameters file that define the deployment parameters. It can contain KeyVault references
ResourceGroupName string
The name of the resource group in which to create the template deployment.
TemplateBody string
Specifies the JSON definition for the template.
deploymentMode string
Specifies the mode that is used to deploy resources. This value could be either Incremental or Complete. Note that you will almost always want this to be set to Incremental otherwise the deployment will destroy all infrastructure not specified within the template, and this provider will not be aware of this.
name string
Specifies the name of the template deployment. Changing this forces a new resource to be created.
outputs {[key: string]: string}
A map of supported scalar output types returned from the deployment (currently, Azure Template Deployment outputs of type String, Int and Bool are supported, and are converted to strings - others will be ignored) and can be accessed using .outputs["name"].
parameters {[key: string]: string}
Specifies the name and value pairs that define the deployment parameters for the template.
parametersBody string
Specifies a valid Azure JSON parameters file that define the deployment parameters. It can contain KeyVault references
resourceGroupName string
The name of the resource group in which to create the template deployment.
templateBody string
Specifies the JSON definition for the template.
deployment_mode str
Specifies the mode that is used to deploy resources. This value could be either Incremental or Complete. Note that you will almost always want this to be set to Incremental otherwise the deployment will destroy all infrastructure not specified within the template, and this provider will not be aware of this.
name str
Specifies the name of the template deployment. Changing this forces a new resource to be created.
outputs Mapping[str, str]
A map of supported scalar output types returned from the deployment (currently, Azure Template Deployment outputs of type String, Int and Bool are supported, and are converted to strings - others will be ignored) and can be accessed using .outputs["name"].
parameters Mapping[str, str]
Specifies the name and value pairs that define the deployment parameters for the template.
parameters_body str
Specifies a valid Azure JSON parameters file that define the deployment parameters. It can contain KeyVault references
resource_group_name str
The name of the resource group in which to create the template deployment.
template_body str
Specifies the JSON definition for the template.

Package Details

Repository
https://github.com/pulumi/pulumi-azure
License
Apache-2.0
Notes
This Pulumi package is based on the azurerm Terraform Provider.