Ensure multiple subscriptions can be moved to a management in parallel (#288)

Ensure deployment name for moving subscription is unique
This commit is contained in:
Senthuran Sivananthan 2022-05-10 16:46:06 -04:00 коммит произвёл GitHub
Родитель 93d2f13847
Коммит c4133077e1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 15 добавлений и 10 удалений

2
.github/workflows/6-subscriptions.yml поставляемый
Просмотреть файл

@ -14,7 +14,7 @@ on:
inputs:
subscriptionIds:
type: string
description: Subscription ID(s) (optional), e.g. "abcd", "1234"
description: Subscription ID(s), e.g. "abcd", "1234"
required: true
environmentName:
type: string

Просмотреть файл

@ -84,25 +84,30 @@ function Set-Subscriptions {
Write-Output "Creating new file with runtime populated parameters: $PopulatedParametersFilePath"
$Configuration | ConvertTo-Json -Depth 100 | Set-Content $PopulatedParametersFilePath
$MoveDeploymentName="move-subscription-$SubscriptionId-$DeploymentRegion"
$MoveDeploymentName=-join $MoveDeploymentName[0..63]
Write-Output "Moving Subscription ($SubscriptionId) to Management Group ($ManagementGroupId)"
New-AzManagementGroupDeployment `
-Name $MoveDeploymentName `
-ManagementGroupId $ManagementGroupId `
-Location $Context.DeploymentRegion `
-TemplateFile "$($Context.WorkingDirectory)/landingzones/utils/mg-move/move-subscription.bicep" `
-TemplateParameterObject @{
managementGroupId = $ManagementGroupId
subscriptionId = $SubscriptionId
}
} `
-Verbose
Write-Output "Deploying $PopulatedParametersFilePath to $SubscriptionId in $Region"
Write-Output "Deploying $PopulatedParametersFilePath to $SubscriptionId in $Region"
Set-AzContext -Subscription $SubscriptionId
New-AzSubscriptionDeployment `
-Name "main-$DeploymentRegion" `
-Location $DeploymentRegion `
-TemplateFile "$($Context.WorkingDirectory)/landingzones/lz-$ArchetypeName/main.bicep" `
-TemplateParameterFile $PopulatedParametersFilePath `
-Verbose
Set-AzContext -Subscription $SubscriptionId
New-AzSubscriptionDeployment `
-Name "main-$DeploymentRegion" `
-Location $DeploymentRegion `
-TemplateFile "$($Context.WorkingDirectory)/landingzones/lz-$ArchetypeName/main.bicep" `
-TemplateParameterFile $PopulatedParametersFilePath `
-Verbose
Remove-Item $PopulatedParametersFilePath
}