Skip to content

Commit

Permalink
Merge pull request #22 from AlexanderSehr/main
Browse files Browse the repository at this point in the history
Upgraded to CARML 0.9 alongside several structural improvements
  • Loading branch information
AlexanderSehr authored Feb 2, 2023
2 parents 567650d + a90d4d7 commit 3eab840
Show file tree
Hide file tree
Showing 208 changed files with 2,867 additions and 1,600 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ jobs:
# Define PS modules to install on the runner
$Modules = @(
@{ Name = 'Az.Accounts' },
@{ Name = 'Az.Resources' },
@{ Name = 'Az.Compute' }
@{ Name = 'Az.Resources' }
)
# Set agent up
Expand Down Expand Up @@ -72,7 +71,7 @@ jobs:
# INVOKE DEPLOYMENT #
# ----------------- #
$functionInput = @{
templateFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.scaleset.bicep'
templateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.scaleset.bicep'
location = '$(location)'
subscriptionId = (Get-AzContext).Subscription.Id
}
Expand Down Expand Up @@ -114,40 +113,10 @@ jobs:
# Load used functions
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'registerAgentPool' 'Sync-ElasticPool.ps1')
# Get scale set properties
$templateFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.scaleset.bicep'
$templateContent = az bicep build --file $templateFilePath --stdout | ConvertFrom-Json -AsHashtable
# Get VMSS name
if($templateContent.resources[-1].properties.parameters.Keys -contains 'virtualMachineScaleSetName') {
# Used explicit value
$VMSSName = $templateContent.resources[-1].properties.parameters['virtualMachineScaleSetName'].value
} else {
# Used default value
$VMSSName = $templateContent.resources[-1].properties.template.parameters['virtualMachineScaleSetName'].defaultValue
}
# Get VMMS RG name
if($templateContent.resources[-1].properties.parameters.Keys -contains 'resourceGroupName') {
# Used explicit value
$VMSSResourceGroupName = $templateContent.resources[-1].properties.parameters['resourceGroupName'].value
} else {
# Used default value
$VMSSResourceGroupName = $templateContent.resources[-1].properties.template.parameters['resourceGroupName'].defaultValue
}
# Get agent pool properties
$agentsParameterFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.agentpool.config.json'
$agentPoolParameterFileContent = ConvertFrom-Json (Get-Content $agentsParameterFilePath -Raw) -AsHashTable
$functionInput = @{
PAT = '$(System.AccessToken)'
Organization = $agentPoolParameterFileContent.Organization
Project = $agentPoolParameterFileContent.Project
ServiceConnectionName = $agentPoolParameterFileContent.ServiceConnectionName
VMSSName = $VMSSName
VMSSResourceGroupName = $VMSSResourceGroupName
AgentPoolProperties = $agentPoolParameterFileContent.AgentPoolProperties
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.scaleset.bicep'
AgentParametersFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.agentpool.config.json'
PAT = '$(System.AccessToken)'
}
Write-Verbose "Invoke task with" -Verbose
Expand Down
4 changes: 2 additions & 2 deletions .azuredevops/azureDevOpsScaleSet/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## - These variables are used to configure the pipeline and provide ##
## variables to pipeline scripts ##
## - Parameters used for resource deployments are located in the ##
## parameter files in the '.\Parameters' folder ##
## deployment files in the '.\deploymentFiles' folder ##
#######################################################################

variables:
Expand All @@ -27,7 +27,7 @@ variables:

#region specific
templatesPath: 'constructs/azureDevOpsScaleSet/templates'
parametersPath: 'constructs/azureDevOpsScaleSet/parameters'
deploymentFilesPath: 'constructs/azureDevOpsScaleSet/deploymentFiles'
orchestrationFunctionsPath: 'constructs/azureDevOpsScaleSet/scripts'
sharedOrchestrationFunctionsPath: 'sharedScripts'
location: westeurope
Expand Down
88 changes: 7 additions & 81 deletions .azuredevops/azureImageBuilder/.templates/pipeline.image.jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ jobs:
# Define PS modules to install on the runner
$Modules = @(
@{ Name = 'Az.Accounts' },
@{ Name = 'Az.Resources' },
@{ Name = 'Az.ResourceGraph' }
@{ Name = 'Az.Accounts' }
)
# Set agent up
Expand All @@ -66,34 +64,8 @@ jobs:
Write-Verbose "Load function" -Verbose
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'image' 'Remove-ImageTemplate.ps1')
$templateFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.imageTemplate.bicep'
$templateContent = az bicep build --file $templateFilePath --stdout | ConvertFrom-Json -AsHashtable
# Get Image Template name
if($templateContent.resources[-1].properties.parameters.Keys -contains 'imageTemplateName') {
# Used explicit value
$imageTemplateName = $templateContent.resources[-1].properties.parameters['imageTemplateName'].value
} else {
# Used default value
$imageTemplateName = $templateContent.resources[-1].properties.template.parameters['imageTemplateName'].defaultValue
}
# Get Resource Group name
if($templateContent.resources[-1].properties.parameters.Keys -contains 'resourceGroupName') {
# Used explicit value
$resourceGroupName = $templateContent.resources[-1].properties.parameters['resourceGroupName'].value
} else {
# Used default value
$resourceGroupName = $templateContent.resources[-1].properties.template.parameters['resourceGroupName'].defaultValue
}
$functionInput = @{
resourcegroupName = $resourceGroupName
# imageTemplateName = $templateContent.variables.itParam.name
# Workaround until 'https://github.com/Azure/bicep/issues/6955' is resolved. Then the above snippet can be used
imageTemplateName = ((Get-Content $templateFilePath -Raw) -replace "`r") | Select-String '(?m)^var itParam = \{\n\s*name:\s*''(.+)''$' | Foreach-Object { $_.Matches.Groups[1].Value }
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.imageTemplate.bicep'
}
Write-Verbose "Invoke task with" -Verbose
Expand All @@ -118,30 +90,8 @@ jobs:
Write-Verbose "Load function" -Verbose
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'image' 'Remove-DeploymentScript.ps1')
$templateFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.imageTemplate.bicep'
$templateContent = az bicep build --file $templateFilePath --stdout | ConvertFrom-Json -AsHashtable
# Get Deployment Script prefix name
if($templateContent.resources[-1].properties.parameters.Keys -contains 'deploymentScriptName') {
# Used explicit value
$deploymentScriptName = $templateContent.resources[-1].properties.parameters['deploymentScriptName'].value
} else {
# Used default value
$deploymentScriptName = $templateContent.resources[-1].properties.template.parameters['deploymentScriptName'].defaultValue
}
# Get Resource Group name
if($templateContent.resources[-1].properties.parameters.Keys -contains 'resourceGroupName') {
# Used explicit value
$resourceGroupName = $templateContent.resources[-1].properties.parameters['resourceGroupName'].value
} else {
# Used default value
$resourceGroupName = $templateContent.resources[-1].properties.template.parameters['resourceGroupName'].defaultValue
}
$functionInput = @{
resourcegroupName = $resourceGroupName
deploymentScriptPrefix = $deploymentScriptName
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.imageTemplate.bicep'
}
Write-Verbose "Invoke task with" -Verbose
Expand Down Expand Up @@ -218,7 +168,7 @@ jobs:
# INVOKE DEPLOYMENT #
# ----------------- #
$functionInput = @{
templateFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.imageInfra.bicep'
templateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.imageInfra.bicep'
location = '$(location)'
subscriptionId = (Get-AzContext).Subscription.Id
}
Expand Down Expand Up @@ -258,20 +208,8 @@ jobs:
Write-Verbose "Load function" -Verbose
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'storage' 'Invoke-StorageAccountPostDeployment.ps1')
$templateFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.imageInfra.bicep'
$templateContent = az bicep build --file $templateFilePath --stdout | ConvertFrom-Json -AsHashtable
# Get Storage Account name
if($templateContent.resources[-1].properties.parameters.Keys -contains 'storageAccountName') {
# Used explicit value
$storageAccountName = $templateContent.resources[-1].properties.parameters['storageAccountName'].value
} else {
# Used default value
$storageAccountName = $templateContent.resources[-1].properties.template.parameters['storageAccountName'].defaultValue
}
$functionInput = @{
StorageAccountName = $storageAccountName
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.imageInfra.bicep'
}
Write-Verbose "Invoke task with" -Verbose
Expand Down Expand Up @@ -305,7 +243,7 @@ jobs:
# INVOKE DEPLOYMENT #
# ----------------- #
$functionInput = @{
templateFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.imageTemplate.bicep'
templateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.imageTemplate.bicep'
location = '$(location)'
subscriptionId = (Get-AzContext).Subscription.Id
}
Expand Down Expand Up @@ -355,20 +293,8 @@ jobs:
Write-Verbose "Load function" -Verbose
. '$(Build.Repository.LocalPath)/$(orchestrationFunctionsPath)/image/Wait-ForImageBuild.ps1'
$templateFilePath = Join-Path '$(parametersPath)' '${{ parameters.environment }}.imageTemplate.bicep'
$templateContent = az bicep build --file $templateFilePath --stdout | ConvertFrom-Json -AsHashtable
# Get Resource Group name
if($templateContent.resources[-1].properties.parameters.Keys -contains 'resourceGroupName') {
# Used explicit value
$resourceGroupName = $templateContent.resources[-1].properties.parameters['resourceGroupName'].value
} else {
# Used default value
$resourceGroupName = $templateContent.resources[-1].properties.template.parameters['resourceGroupName'].defaultValue
}
$functionInput = @{
ResourceGroupName = $resourceGroupName
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.imageTemplate.bicep'
ImageTemplateName = $env:IMAGETEMPATENAME # template deployment output
}
Expand Down
4 changes: 2 additions & 2 deletions .azuredevops/azureImageBuilder/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## - These variables are used to configure the pipeline and provide ##
## variables to pipeline scripts ##
## - Parameters used for resource deployments are located in the ##
## parameter files in the '.\Parameters' folder ##
## deployment files in the '.\deploymentFiles' folder ##
#######################################################################

variables:
Expand All @@ -27,7 +27,7 @@ variables:

#region specific
templatesPath: 'constructs/azureImageBuilder/templates'
parametersPath: 'constructs/azureImageBuilder/parameters'
deploymentFilesPath: 'constructs/azureImageBuilder/deploymentFiles'
orchestrationFunctionsPath: 'constructs/azureImageBuilder/scripts'
sharedOrchestrationFunctionsPath: 'sharedScripts'
location: westeurope
Expand Down
Loading

0 comments on commit 3eab840

Please sign in to comment.