From b18b520bbb3977462fe46032f3c23d79621833de Mon Sep 17 00:00:00 2001 From: "Brian Moore (AZURE RESOURCE MANAGER)" Date: Tue, 22 Sep 2020 17:19:03 -0500 Subject: [PATCH 1/2] using a task --- lz-lifecycle-mg/pipeline.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lz-lifecycle-mg/pipeline.json b/lz-lifecycle-mg/pipeline.json index 7d06a11..561f126 100644 --- a/lz-lifecycle-mg/pipeline.json +++ b/lz-lifecycle-mg/pipeline.json @@ -81,6 +81,30 @@ "pwsh": "true", "workingDirectory": "" } + }, + { + "environment": {}, + "enabled": true, + "continueOnError": false, + "alwaysRun": false, + "displayName": "Deploy BYOT Template", + "timeoutInMinutes": 0, + "condition": "succeeded()", + "task": { + "id": "e213ff0f-5d5c-4791-802d-52ea3e7be1f1", + "versionSpec": "2.*", + "definitionType": "task" + }, + "inputs": { + "targetType": "filePath", + "filePath": "Deploy-AzTemplate.ps1", + "arguments": "-ArtifactStagingDirectory \"BYOT\" -Location \"westus\" ", + "errorActionPreference": "stop", + "failOnStderr": "false", + "ignoreLASTEXITCODE": "false", + "pwsh": "true", + "workingDirectory": "" + } } ], "name": "Agent job 1", From 8e3d1381a710b3ad095921b0c6db96bc5e22b7f1 Mon Sep 17 00:00:00 2001 From: Brian Moore Date: Mon, 14 Dec 2020 10:08:16 -0600 Subject: [PATCH 2/2] misc commits --- Deploy-AzTemplate.ps1 | 2 +- .../BYOT/{azuredeploy.json => byot1.json} | 2 +- lz-lifecycle-mg/BYOT/byot2.json | 9 +++ lz-lifecycle-mg/byotdeploy.json | 61 +++++++++++++++++++ lz-lifecycle-mg/byotdeploy.parameters.json | 22 +++++++ 5 files changed, 94 insertions(+), 2 deletions(-) rename lz-lifecycle-mg/BYOT/{azuredeploy.json => byot1.json} (83%) create mode 100644 lz-lifecycle-mg/BYOT/byot2.json create mode 100644 lz-lifecycle-mg/byotdeploy.json create mode 100644 lz-lifecycle-mg/byotdeploy.parameters.json diff --git a/Deploy-AzTemplate.ps1 b/Deploy-AzTemplate.ps1 index 4fda9d2..cb6571e 100644 --- a/Deploy-AzTemplate.ps1 +++ b/Deploy-AzTemplate.ps1 @@ -257,7 +257,7 @@ else { } "managementGroup" { New-AzManagementGroupDeployment -Name $DeploymentName ` - -ManagementGroupId $managementGroupId + -ManagementGroupId $(get-azcontext).Tenant.Id -Location $Location ` @TemplateArgs ` @OptionalParameters ` diff --git a/lz-lifecycle-mg/BYOT/azuredeploy.json b/lz-lifecycle-mg/BYOT/byot1.json similarity index 83% rename from lz-lifecycle-mg/BYOT/azuredeploy.json rename to lz-lifecycle-mg/BYOT/byot1.json index 0ad2856..ac0efa8 100644 --- a/lz-lifecycle-mg/BYOT/azuredeploy.json +++ b/lz-lifecycle-mg/BYOT/byot1.json @@ -1,5 +1,5 @@ { - "$schema": "https://schema.management.azure.com/schemas/2019-08-01/tenantDeploymentTemplate.json#", + "$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "functions": [], diff --git a/lz-lifecycle-mg/BYOT/byot2.json b/lz-lifecycle-mg/BYOT/byot2.json new file mode 100644 index 0000000..ac0efa8 --- /dev/null +++ b/lz-lifecycle-mg/BYOT/byot2.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": {}, + "functions": [], + "variables": {}, + "resources": [], + "outputs": {} +} diff --git a/lz-lifecycle-mg/byotdeploy.json b/lz-lifecycle-mg/byotdeploy.json new file mode 100644 index 0000000..5bb66c5 --- /dev/null +++ b/lz-lifecycle-mg/byotdeploy.json @@ -0,0 +1,61 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "byot": { + "type": "array" + }, + "_artifactsLocation": { + "type": "string", + "metadata": { + "description": "The base URI where artifacts required by this template are located. When the template is deployed using the accompanying scripts, a private location in the subscription will be used and this value will be automatically generated." + }, + "defaultValue": "[deployment().properties.templateLink.uri]" + }, + "_artifactsLocationSasToken": { + "type": "securestring", + "metadata": { + "description": "The sasToken required to access _artifactsLocation. When the template is deployed using the accompanying scripts, a sasToken will be automatically generated." + }, + "defaultValue": "" + } + }, + "resources": [ + + { + "type": "Microsoft.Resources/deployments", + "apiVersion": "2019-10-01", + "name": "[concat('byotDeployment-', parameters('byot')[copyIndex()])]", + "location": "[deployment().location]", + "subscriptionId": "[if(not(empty(parameters('byot')[copyIndex()].subscriptionId)), parameters('byot')[copyIndex()].subscriptionId, json('null'))]", + "resourceGroup": "[if(not(empty(parameters('byot')[copyIndex()].resourceGroupName)), parameters('byot')[copyIndex()].resourceGroupName, json('null'))]", + "copy": { + "name": "byotLoop", + "count": "[length(parameters('byot'))]", + "mode": "Serial" + }, + "properties": { + "mode": "Incremental", + "templateLink": { + "contentVersion": "1.0.0.0", + "uri": "[uri(parameters('_artifactsLocation'), concat(parameters('byot')[copyIndex()].templateFileName, parameters('_artifactsLocationSasToken')))]" + }, + "parametersLink": { + "uri": "[if(not(empty(parameters('byot')[copyIndex()].parameterFileName)), + uri(parameters('_artifactsLocation'), concat(parameters('byot')[copyIndex()].parameterFileName, parameters('_artifactsLocationSasToken'))), + json('null'))]" + } + } + } + ], + "outputs": { + "BYOTs": { + "type": "array", + "copy": { + "count": "[length(parameters('byot'))]", + "input": "[parameters('byot')[copyIndex()]]" + + } + } + } +} \ No newline at end of file diff --git a/lz-lifecycle-mg/byotdeploy.parameters.json b/lz-lifecycle-mg/byotdeploy.parameters.json new file mode 100644 index 0000000..b08e0a2 --- /dev/null +++ b/lz-lifecycle-mg/byotdeploy.parameters.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "byot": { + "value": [ + { + "subscriptionId": "0cec7090-2e08-4498-9337-eb96ade50821", + "resourceGroupName": "byot1", + "templateFileName": "./byot/byot1.json", + "parameterFileName": "" + }, + { + "subscriptionId": "0cec7090-2e08-4498-9337-eb96ade50821", + "resourceGroupName": "byot2", + "templateFileName": "./byot/byot2.json", + "parameterFileName": "" + } + ] + } + } +} \ No newline at end of file