Update ARM template examples to use ResourceGroupTemplateDeployment
MODIFY
classic-azure-py-arm-template/__main__.py
classic-azure-py-arm-template/__main__.py
-# Copyright 2016-2020, Pulumi Corporation. All rights reserved.
+# Copyright 2016-2021, Pulumi Corporation. All rights reserved.
import json
@@ -13,9 +13,15 @@ resource_group = azure.core.ResourceGroup('test')
template = {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
+ "outputs": {
+ "storageAccountName": {
+ "type": "String",
+ "value": "[variables('storageAccountName')]",
+ },
+ },
"parameters": {
"storageAccountType": {
- "type": "string",
+ "type": "String",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
@@ -27,13 +33,6 @@ template = {
},
},
},
- "variables": {
- "location": "[resourceGroup().location]",
- "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'storage')]",
- "publicIPAddressName": "[concat('myPublicIp', uniquestring(resourceGroup().id))]",
- "publicIPAddressType": "Dynamic",
- "dnsLabelPrefix": f"{get_project()}-{get_stack()}",
- },
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
@@ -57,23 +56,26 @@ template = {
},
},
],
- "outputs": {
- "storageAccountName": {
- "type": "string",
- "value": "[variables('storageAccountName')]",
+ "variables": {
+ "location": "[resourceGroup().location]",
+ "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'storage')]",
+ "publicIPAddressName": "[concat('myPublicIp', uniquestring(resourceGroup().id))]",
+ "publicIPAddressType": "Dynamic",
+ "dnsLabelPrefix": f"{get_project()}-{get_stack()}",
},
}
-}
# Create an ARM template deployment using the ordinary JSON ARM template as specified above. This could be read from disk, of course.
-arm_deployment = azure.core.TemplateDeployment('test-dep',
+arm_deployment = azure.core.ResourceGroupTemplateDeployment('test-dep',
resource_group_name=resource_group.name,
- template_body=json.dumps(template),
- parameters={
- 'storageAccountType': 'Standard_GRS'
- },
+ template_content=json.dumps(template),
+ parameters_content=json.dumps({
+ 'storageAccountType': {
+ 'value': 'Standard_GRS'
+ }
+ }),
deployment_mode='Incremental',
)
# Finally, export the allocated storage account name.
-export('storageAccountName', arm_deployment.outputs['storageAccountName'])
+export('storageAccountName', arm_deployment.output_content.apply(lambda j: json.loads(j)['storageAccountName']['value']))

MODIFY
classic-azure-ts-arm-template/index.ts
classic-azure-ts-arm-template/index.ts
-// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
+// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
import * as azure from "@pulumi/azure";
import * as pulumi from "@pulumi/pulumi";
@@ -7,14 +7,20 @@ import * as pulumi from "@pulumi/pulumi";
const resourceGroup = new azure.core.ResourceGroup("test");
// Create an ARM template deployment using an ordinary JSON ARM template. This could be read from disk, of course.
-const armDeployment = new azure.core.TemplateDeployment("test-dep", {
+const armDeployment = new azure.core.ResourceGroupTemplateDeployment("test-dep", {
resourceGroupName: resourceGroup.name,
- templateBody: JSON.stringify({
+ templateContent: JSON.stringify({
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
+ "outputs": {
+ "storageAccountName": {
+ "type": "String",
+ "value": "[variables('storageAccountName')]",
+ },
+ },
"parameters": {
"storageAccountType": {
- "type": "string",
+ "type": "String",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
@@ -26,13 +32,6 @@ const armDeployment = new azure.core.TemplateDeployment("test-dep", {
},
},
},
- "variables": {
- "location": "[resourceGroup().location]",
- "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'storage')]",
- "publicIPAddressName": "[concat('myPublicIp', uniquestring(resourceGroup().id))]",
- "publicIPAddressType": "Dynamic",
- "dnsLabelPrefix": `${pulumi.getProject()}-${pulumi.getStack()}`,
- },
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
@@ -56,18 +55,21 @@ const armDeployment = new azure.core.TemplateDeployment("test-dep", {
},
},
],
- "outputs": {
- "storageAccountName": {
- "type": "string",
- "value": "[variables('storageAccountName')]",
- },
+ "variables": {
+ "location": "[resourceGroup().location]",
+ "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'storage')]",
+ "publicIPAddressName": "[concat('myPublicIp', uniquestring(resourceGroup().id))]",
+ "publicIPAddressType": "Dynamic",
+ "dnsLabelPrefix": `${pulumi.getProject()}-${pulumi.getStack()}`,
},
}),
- parameters: {
- "storageAccountType": "Standard_GRS",
+ parametersContent: JSON.stringify({
+ "storageAccountType": {
+ "value": "Standard_GRS",
},
+ }),
deploymentMode: "Incremental",
});
// Finally, export the allocated storage account name.
-export const storageAccountName = armDeployment.outputs["storageAccountName"];
+export const storageAccountName = armDeployment.outputContent.apply((content: string) => JSON.parse(content)["storageAccountName"]["value"]);

Update ARM template examples to use ResourceGroupTemplateDeployment (#1139)