Skip to content

Commit

Permalink
fix: Fixed Compute-Image dependency - avm/res/compute/image (#2019)
Browse files Browse the repository at this point in the history
## Description

- The current combination of deployment script PowerShell version `8.0`
and the installed
[Az.ImageBuilder](https://www.powershellgallery.com/packages/Az.ImageBuilder/0.4.1)
version `0.4.1` were incompatible (as the latter needs at least
Az.Accounts version `2.19.0` installed, which is not available in pwsh
`8.0`)
- Upgrading just the Deployment Script's PowerShell version does not
work, as the [latest
available](https://[mcr.microsoft.com/v2/azuredeploymentscripts-powershell/tags/list](https://mcr.microsoft.com/v2/azuredeploymentscripts-powershell/tags/list))
is `11.5` which only has Az.Accounts version `2.13.0` installed
- So, to solve the issue I updated the implementation to install
Az.ImageBuilder version `0.4.0` explicitely which has only a dependency
on Az.Accounts version `2.13.0`.
- In the same way, I updated the installation of the `Az.Storage` module
(which in its latest version required Az.Accounts `3.0.0`)

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.compute.image](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.compute.image.yml/badge.svg?branch=users%2Falsehr%2F1625_computeImageVersion&event=workflow_dispatch)](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.compute.image.yml)
|

## Type of Change

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utlities (Non-module effecting
changes)
- [ ] Azure Verified Module updates:
- [x] Bugfix containing backwards compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] Update to documentation
  • Loading branch information
AlexanderSehr authored May 28, 2024
1 parent cfbe2e3 commit 2d04a5c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 25 deletions.
4 changes: 2 additions & 2 deletions avm/res/compute/image/tests/e2e/defaults/dependencies.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ resource triggerImageDeploymentScript 'Microsoft.Resources/deploymentScripts@202
}
}
properties: {
azPowerShellVersion: '8.0'
azPowerShellVersion: '11.5' // Source: https://mcr.microsoft.com/v2/azuredeploymentscripts-powershell/tags/list
retentionInterval: 'P1D'
arguments: '-ImageTemplateName \\"${imageTemplate.name}\\" -ImageTemplateResourceGroup \\"${resourceGroup().name}\\"'
scriptContent: loadTextContent('../../../../../../utilities/e2e-template-assets/scripts/Start-ImageTemplate.ps1')
Expand All @@ -130,7 +130,7 @@ resource copyVhdDeploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-
}
}
properties: {
azPowerShellVersion: '8.0'
azPowerShellVersion: '11.5' // Source: https://mcr.microsoft.com/v2/azuredeploymentscripts-powershell/tags/list
retentionInterval: 'P1D'
arguments: '-ImageTemplateName \\"${imageTemplate.name}\\" -ImageTemplateResourceGroup \\"${resourceGroup().name}\\" -DestinationStorageAccountName \\"${storageAccount.name}\\" -VhdName \\"${imageTemplateNamePrefix}\\" -WaitForComplete'
scriptContent: loadTextContent('../../../../../../utilities/e2e-template-assets/scripts/Copy-VhdToStorageAccount.ps1')
Expand Down
4 changes: 2 additions & 2 deletions avm/res/compute/image/tests/e2e/max/dependencies.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ resource triggerImageDeploymentScript 'Microsoft.Resources/deploymentScripts@202
}
}
properties: {
azPowerShellVersion: '8.0'
azPowerShellVersion: '11.5' // Source: https://mcr.microsoft.com/v2/azuredeploymentscripts-powershell/tags/list
retentionInterval: 'P1D'
arguments: '-ImageTemplateName \\"${imageTemplate.name}\\" -ImageTemplateResourceGroup \\"${resourceGroup().name}\\"'
scriptContent: loadTextContent('../../../../../../utilities/e2e-template-assets/scripts/Start-ImageTemplate.ps1')
Expand All @@ -136,7 +136,7 @@ resource copyVhdDeploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-
}
}
properties: {
azPowerShellVersion: '8.0'
azPowerShellVersion: '11.5' // Source: https://mcr.microsoft.com/v2/azuredeploymentscripts-powershell/tags/list
retentionInterval: 'P1D'
arguments: '-ImageTemplateName \\"${imageTemplate.name}\\" -ImageTemplateResourceGroup \\"${resourceGroup().name}\\" -DestinationStorageAccountName \\"${storageAccount.name}\\" -VhdName \\"${imageTemplateNamePrefix}\\" -WaitForComplete'
scriptContent: loadTextContent('../../../../../../utilities/e2e-template-assets/scripts/Copy-VhdToStorageAccount.ps1')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ resource triggerImageDeploymentScript 'Microsoft.Resources/deploymentScripts@202
}
}
properties: {
azPowerShellVersion: '8.0'
azPowerShellVersion: '11.5' // Source: https://mcr.microsoft.com/v2/azuredeploymentscripts-powershell/tags/list
retentionInterval: 'P1D'
arguments: '-ImageTemplateName \\"${imageTemplate.name}\\" -ImageTemplateResourceGroup \\"${resourceGroup().name}\\"'
scriptContent: loadTextContent('../../../../../../utilities/e2e-template-assets/scripts/Start-ImageTemplate.ps1')
Expand All @@ -136,7 +136,7 @@ resource copyVhdDeploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-
}
}
properties: {
azPowerShellVersion: '8.0'
azPowerShellVersion: '11.5' // Source: https://mcr.microsoft.com/v2/azuredeploymentscripts-powershell/tags/list
retentionInterval: 'P1D'
arguments: '-ImageTemplateName \\"${imageTemplate.name}\\" -ImageTemplateResourceGroup \\"${resourceGroup().name}\\" -DestinationStorageAccountName \\"${storageAccount.name}\\" -VhdName \\"${imageTemplateNamePrefix}\\" -WaitForComplete'
scriptContent: loadTextContent('../../../../../../utilities/e2e-template-assets/scripts/Copy-VhdToStorageAccount.ps1')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,23 @@ begin {
$currentVerbosePreference = $VerbosePreference
$VerbosePreference = 'SilentlyContinue'
$requiredModules = @(
'Az.ImageBuilder',
'Az.Storage'
@{ Name = 'Az.ImageBuilder'; Version = '0.4.0' },
@{ Name = 'Az.Storage'; Version = '6.0.0' }
)
foreach ($moduleName in $requiredModules) {
if (-not ($installedModule = Get-Module $moduleName -ListAvailable)) {
Install-Module $moduleName -Repository 'PSGallery' -Force -Scope 'CurrentUser'
if ($installed = Get-Module -Name $moduleName -ListAvailable) {
Write-Verbose ('Installed module [{0}] with version [{1}]' -f $installed.Name, $installed.Version) -Verbose
}
} else {
Write-Verbose ('Module [{0}] already installed in version [{1}]' -f $installedModule[0].Name, $installedModule[0].Version) -Verbose
foreach ($module in $requiredModules) {
$installationInput = @{
Name = $module.Name
Repository = 'PSGallery'
Scope = 'CurrentUser'
Force = $true
}
if ($Module.Version) {
$installationInput['RequiredVersion'] = $module.Version
}
Install-Module @installationInput

if ($installed = Get-Module -Name $module.Name -ListAvailable) {
Write-Verbose ('Installed module [{0}] with version [{1}]' -f $installed.Name, $installed.Version) -Verbose
}
}
$VerbosePreference = $currentVerbosePreference
Expand Down
24 changes: 15 additions & 9 deletions avm/utilities/e2e-template-assets/scripts/Start-ImageTemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,22 @@ begin {
$currentVerbosePreference = $VerbosePreference
$VerbosePreference = 'SilentlyContinue'
$requiredModules = @(
'Az.ImageBuilder'
@{ Name = 'Az.ImageBuilder'; Version = '0.4.0' }
)
foreach ($moduleName in $requiredModules) {
if (-not ($installedModule = Get-Module $moduleName -ListAvailable)) {
Install-Module $moduleName -Repository 'PSGallery' -Force -Scope 'CurrentUser'
if ($installed = Get-Module -Name $moduleName -ListAvailable) {
Write-Verbose ('Installed module [{0}] with version [{1}]' -f $installed.Name, $installed.Version) -Verbose
}
} else {
Write-Verbose ('Module [{0}] already installed in version [{1}]' -f $installedModule[0].Name, $installedModule[0].Version) -Verbose
foreach ($module in $requiredModules) {
$installationInput = @{
Name = $module.Name
Repository = 'PSGallery'
Scope = 'CurrentUser'
Force = $true
}
if ($Module.Version) {
$installationInput['RequiredVersion'] = $module.Version
}
Install-Module @installationInput

if ($installed = Get-Module -Name $module.Name -ListAvailable) {
Write-Verbose ('Installed module [{0}] with version [{1}]' -f $installed.Name, $installed.Version) -Verbose
}
}
$VerbosePreference = $currentVerbosePreference
Expand Down

0 comments on commit 2d04a5c

Please sign in to comment.