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 diff --git a/lz-lifecycle-mg/pipeline.json b/lz-lifecycle-mg/pipeline.json index 85a2207..1735d8c 100644 --- a/lz-lifecycle-mg/pipeline.json +++ b/lz-lifecycle-mg/pipeline.json @@ -80,6 +80,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",