Skip to content

Commit be43e75

Browse files
Merge pull request #46 from AlexanderSehr/users/alsehr/202412_smallFixes
fix: Several improvements / fixes on the windows image-side of things
2 parents ef2f8c3 + 78718e7 commit be43e75

File tree

14 files changed

+374
-269
lines changed

14 files changed

+374
-269
lines changed

.azuredevops/azureImageBuilder/.templates/pipeline.jobs.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ parameters:
33
default:
44
- name: deploymentsToPerform
55
default:
6+
- name: osType
7+
default:
68
- name: waitForImageBuild
79
default:
810
- name: removeImageTemplateResources
@@ -63,7 +65,7 @@ jobs:
6365
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'image' 'Remove-ImageTemplate.ps1')
6466
6567
$functionInput = @{
66-
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.bicep'
68+
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.${{ parameters.osType }}.bicep'
6769
}
6870
6971
Write-Verbose "Invoke task with" -Verbose
@@ -89,7 +91,7 @@ jobs:
8991
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'image' 'Remove-DeploymentScript.ps1')
9092
9193
$functionInput = @{
92-
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.bicep'
94+
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.${{ parameters.osType }}.bicep'
9395
}
9496
9597
Write-Verbose "Invoke task with" -Verbose
@@ -115,7 +117,7 @@ jobs:
115117
. (Join-Path '$(System.DefaultWorkingDirectory)' '$(orchestrationFunctionsPath)' 'image' 'Remove-ResourcesInStagingRg.ps1')
116118
117119
$functionInput = @{
118-
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.bicep'
120+
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.${{ parameters.osType }}.bicep'
119121
}
120122
121123
Write-Verbose "Invoke task with" -Verbose
@@ -186,7 +188,7 @@ jobs:
186188
# INVOKE DEPLOYMENT #
187189
# ----------------- #
188190
$functionInput = @{
189-
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.bicep'
191+
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.image.${{ parameters.osType }}.bicep'
190192
DeploymentMetadataLocation = '$(deploymentMetadataLocation)'
191193
SubscriptionId = (Get-AzContext).Subscription.Id
192194
RepoRoot = '$(System.DefaultWorkingDirectory)'

.azuredevops/azureImageBuilder/pipeline.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ parameters:
1919
- Only base
2020
- Only assets & image
2121
- Only image
22+
- name: osType
23+
displayName: OS to create the image for
24+
type: string
25+
default: Linux
26+
values:
27+
- Linux
28+
- Windows
2229
- name: waitForImageBuild
2330
displayName: Wait for image build
2431
type: boolean
@@ -41,6 +48,7 @@ stages:
4148
- template: .templates/pipeline.jobs.yml
4249
parameters:
4350
environment: 'sbx'
51+
osType: '${{ lower(parameters.osType) }}'
4452
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}'
4553
waitForImageBuild: '${{ parameters.waitForImageBuild }}'
4654
removeImageTemplateResources: '${{ parameters.removeImageTemplateResources }}'
@@ -57,6 +65,7 @@ stages:
5765
- template: .templates/pipeline.jobs.yml
5866
parameters:
5967
environment: 'dev'
68+
osType: '${{ lower(parameters.osType) }}'
6069
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}'
6170
waitForImageBuild: '${{ parameters.waitForImageBuild }}'
6271
removeImageTemplateResources: '${{ parameters.removeImageTemplateResources }}'
@@ -74,6 +83,7 @@ stages:
7483
- template: .templates/pipeline.jobs.yml
7584
parameters:
7685
environment: 'prd'
86+
osType: '${{ lower(parameters.osType) }}'
7787
deploymentsToPerform: '${{ parameters.deploymentsToPerform }}'
7888
waitForImageBuild: '${{ parameters.waitForImageBuild }}'
7989
removeImageTemplateResources: '${{ parameters.removeImageTemplateResources }}'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Currently the repository contains the following constructs:
1313

1414
| Construct | Description | Path |
1515
| - | - | - |
16-
| Azure Image Builder | This construct provides a packages solution to create custom images using the Azure Image Builder service with an Azure Compute Gallery, including guidelines to operate it. | [`constructs\azureImageBuilder`](https://github.com/Azure/DevOps-Self-Hosted/tree/main/constructs/azureImageBuilder) |
17-
| Managed DevOps Pool | This construct provides a packaged solution to deploy the infrastructure for self-hosted Managed DevOps Pools, including guidelines to maintain it. | [`constructs\managedDevOpsPool`](https://github.com/Azure/DevOps-Self-Hosted/tree/main/constructs/managedDevOpsPool) |
16+
| Azure Image Builder | This construct provides a packages solution to create custom images using the Azure Image Builder service with an Azure Compute Gallery, including guidelines to operate it. | [`constructs/azureImageBuilder`](https://github.com/Azure/DevOps-Self-Hosted/tree/main/constructs/azureImageBuilder) |
17+
| Managed DevOps Pool | This construct provides a packaged solution to deploy the infrastructure for self-hosted Managed DevOps Pools, including guidelines to maintain it. | [`constructs/managedDevOpsPool`](https://github.com/Azure/DevOps-Self-Hosted/tree/main/constructs/managedDevOpsPool) |
1818

1919
For detailed information on the constructs and how to get started, please continue to the [Wiki](https://github.com/Azure/DevOps-Self-Hosted/wiki).
2020

constructs/azureImageBuilder/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This construct consists of several components in different places. You can use the following table to make sure you are aware of all the ones you need:
44

5-
- Construct Templates, Scripts & Deployment Files: Folder `constructs\azureImageBuilder`
6-
- Azure DevOps Pipelines: Folder `.azuredevops\azureImageBuilder`
5+
- Construct Templates, Scripts & Deployment Files: Folder `constructs/azureImageBuilder`
6+
- Azure DevOps Pipelines: Folder `.azuredevops/azureImageBuilder`
77

88
For further information, please refer to the Wiki for information on how to apply the construct.

constructs/azureImageBuilder/deploymentFiles/sbx.image.bicep

Lines changed: 0 additions & 151 deletions
This file was deleted.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
targetScope = 'subscription'
2+
3+
//////////////////////////
4+
// Input Parameters //
5+
//////////////////////////
6+
@description('Optional. A parameter to control which deployments should be executed')
7+
@allowed([
8+
'All'
9+
'Only base'
10+
'Only assets & image'
11+
'Only image'
12+
])
13+
param deploymentsToPerform string = 'All'
14+
15+
@description('Optional. Specifies the location for resources.')
16+
param resourceLocation string = 'NorthEurope'
17+
18+
@description('Optional. A parameter to control if the deployment should wait for the image build to complete.')
19+
param waitForImageBuild bool = true
20+
21+
///////////////////////////////////////////////
22+
// Multi-referenced deployment variables //
23+
///////////////////////////////////////////////
24+
var computeGalleryImageDefinitionName = 'sid-linux'
25+
var assetsStorageAccountName = '<assetsStorageAccountName>'
26+
var assetsStorageAccountContainerName = 'aibscripts'
27+
var installPwshScriptName = 'Install-LinuxPowerShell.sh'
28+
var initializeSoftwareScriptName = 'Initialize-LinuxSoftware.ps1'
29+
30+
/////////////////////////////
31+
// Template deployment //
32+
/////////////////////////////
33+
module imageDeployment '../templates/image.deploy.bicep' = {
34+
name: '${uniqueString(deployment().name, resourceLocation)}-image-sbx'
35+
params: {
36+
resourceLocation: resourceLocation
37+
deploymentsToPerform: deploymentsToPerform
38+
computeGalleryName: '<computeGalleryName>'
39+
computeGalleryImageDefinitionName: computeGalleryImageDefinitionName
40+
waitForImageBuild: waitForImageBuild
41+
computeGalleryImageDefinitions: [
42+
{
43+
name: computeGalleryImageDefinitionName
44+
osType: 'Linux'
45+
identifier: {
46+
publisher: 'devops'
47+
offer: 'devops_linux'
48+
sku: 'devops_linux_az'
49+
}
50+
osState: 'Generalized'
51+
hyperVGeneration: 'V2'
52+
}
53+
]
54+
55+
assetsStorageAccountName: assetsStorageAccountName
56+
assetsStorageAccountContainerName: assetsStorageAccountContainerName
57+
58+
storageAccountFilesToUpload: [
59+
{
60+
name: installPwshScriptName
61+
value: loadTextContent('../scripts/uploads/linux/${installPwshScriptName}')
62+
}
63+
{
64+
name: initializeSoftwareScriptName
65+
value: loadTextContent('../scripts/uploads/linux/${initializeSoftwareScriptName}')
66+
}
67+
]
68+
imageTemplateImageSource: {
69+
type: 'PlatformImage'
70+
publisher: 'canonical'
71+
offer: '0001-com-ubuntu-server-jammy'
72+
sku: '22_04-lts-gen2'
73+
version: 'latest'
74+
// Custom image example
75+
// type: 'SharedImageVersion'
76+
// imageVersionID: '${subscription().id}/resourceGroups/myRg/providers/Microsoft.Compute/galleries/<computeGalleryName>/images/${computeGalleryImageDefinitionName}/versions/0.24470.675'
77+
}
78+
imageTemplateCustomizationSteps: [
79+
{
80+
type: 'Shell'
81+
name: 'PowerShell installation'
82+
scriptUri: 'https://${assetsStorageAccountName}.blob.${az.environment().suffixes.storage}/${assetsStorageAccountContainerName}/${installPwshScriptName}'
83+
}
84+
{
85+
type: 'File'
86+
name: 'Download ${initializeSoftwareScriptName}'
87+
sourceUri: 'https://${assetsStorageAccountName}.blob.${az.environment().suffixes.storage}/${assetsStorageAccountContainerName}/${initializeSoftwareScriptName}'
88+
destination: initializeSoftwareScriptName
89+
}
90+
{
91+
type: 'Shell'
92+
name: 'Software installation'
93+
inline: [
94+
'pwsh \'${initializeSoftwareScriptName}\''
95+
]
96+
}
97+
]
98+
}
99+
}

0 commit comments

Comments
 (0)