Skip to content

Commit 9a4af9d

Browse files
Remove Sha256Checksum parameter of example of New-AzImageBuilderCustomizerObject. (#12301)
* Copy generation imagebuilder code. * Update ChangeLog.md of imagebuilder. * Update ChangeLog.md Co-authored-by: Dingmeng Xue <[email protected]>
1 parent 86382dd commit 9a4af9d

File tree

11 files changed

+65
-58
lines changed

11 files changed

+65
-58
lines changed

src/ImageBuilder/Az.ImageBuilder.psm1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
}
2525
}
2626
if(-not $accountsModule) {
27-
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'1.7.4' } | Measure-Object).Count -gt 0
27+
$hasAdequateVersion = (Get-Module -Name $accountsName -ListAvailable | Where-Object { $_.Version -ge [System.Version]'1.8.1' } | Measure-Object).Count -gt 0
2828
if($hasAdequateVersion) {
29-
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 1.7.4 -Scope Global -PassThru
29+
$accountsModule = Import-Module -Name $accountsName -MinimumVersion 1.8.1 -Scope Global -PassThru
3030
}
3131
}
3232
}
3333

3434
if(-not $accountsModule) {
35-
Write-Error "`nThis module requires $accountsName version 1.7.4 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
36-
} elseif (($accountsModule.Version -lt [System.Version]'1.7.4') -and (-not $localAccounts)) {
37-
Write-Error "`nThis module requires $accountsName version 1.7.4 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to remove '.PSSharedModules' in your home directory. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
35+
Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
36+
} elseif (($accountsModule.Version -lt [System.Version]'1.8.1') -and (-not $localAccounts)) {
37+
Write-Error "`nThis module requires $accountsName version 1.8.1 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to remove '.PSSharedModules' in your home directory. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
3838
}
3939
Write-Information "Loaded Module '$($accountsModule.Name)'"
4040

src/ImageBuilder/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Removed `Sha256Checksum` parameter from example of `New-AzImageBuilderCustomizerObject`.
2122

2223
## Version 0.1.1
2324
* Made `Sha256Checksum` optional in `New-AzImageBuilderCustomizerObject`.

src/ImageBuilder/check-dependencies.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ if(-not $Isolated) {
2121
return
2222
}
2323

24-
function DownloadModule ([bool]$predicate, [string]$path, [string]$moduleName, [string]$versionMinimum) {
24+
function DownloadModule ([bool]$predicate, [string]$path, [string]$moduleName, [string]$versionMinimum, [string]$requiredVersion) {
2525
if($predicate) {
2626
$module = Get-Module -ListAvailable -Name $moduleName
2727
if((-not $module) -or ($versionMinimum -and ($module | ForEach-Object { $_.Version } | Where-Object { $_ -ge [System.Version]$versionMinimum } | Measure-Object).Count -eq 0)) {
2828
$null = New-Item -ItemType Directory -Force -Path $path
2929
Write-Host -ForegroundColor Green "Installing local $moduleName module into '$path'..."
30-
if($versionMinimum) {
30+
if ($requiredVersion) {
31+
Find-Module -Name $moduleName -RequiredVersion $requiredVersion -Repository PSGallery | Save-Module -Path $path
32+
}elseif($versionMinimum) {
3133
Find-Module -Name $moduleName -MinimumVersion $versionMinimum -Repository PSGallery | Save-Module -Path $path
3234
} else {
3335
Find-Module -Name $moduleName -Repository PSGallery | Save-Module -Path $path
@@ -44,8 +46,8 @@ if(Test-Path -Path $localModulesPath) {
4446
$env:PSModulePath = "$localModulesPath$([IO.Path]::PathSeparator)$env:PSModulePath"
4547
}
4648

47-
DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '1.7.4'
48-
DownloadModule -predicate ($all -or $Pester) -path $localModulesPath -moduleName 'Pester' -versionMinimum ''
49+
DownloadModule -predicate ($all -or $Accounts) -path $localModulesPath -moduleName 'Az.Accounts' -versionMinimum '1.8.1'
50+
DownloadModule -predicate ($all -or $Pester) -path $localModulesPath -moduleName 'Pester' -requiredVersion '4.10.1'
4951

5052
$tools = Join-Path $PSScriptRoot 'tools'
5153
$resourceDir = Join-Path $tools 'Resources'

src/ImageBuilder/examples/New-AzImageBuilderCustomizerObject.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ This command creates a windows update customizer.
1111

1212
### Example 2: Create a file customizer
1313
```powershell
14-
PS C:\> New-AzImageBuilderCustomizerObject -FileCustomizer -CustomizerName 'filecus' -Sha256Checksum 'ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93' -Destination 'c:\\buildArtifacts\\index.html' -SourceUri 'https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html'
14+
PS C:\> New-AzImageBuilderCustomizerObject -FileCustomizer -CustomizerName 'filecus' -Destination 'c:\\buildArtifacts\\index.html' -SourceUri 'https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html'
1515
16-
Name Type Destination Sha256Checksum SourceUri
17-
---- ---- ----------- -------------- ---------
18-
filecus File c:\\buildArtifacts\\index.html ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93 https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html
16+
Name Type Destination Sha256Checksum SourceUri
17+
---- ---- ----------- -------------- ---------
18+
filecus File c:\\buildArtifacts\\index.html https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/
1919
2020
```
2121

@@ -24,11 +24,12 @@ This command creates a file customizer.
2424
### Example 3: Create a powershell customizer
2525
```powershell
2626
PS C:\> $inline = @("mkdir c:\\buildActions", "echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt")
27-
PS C:\> New-AzImageBuilderCustomizerObject -PowerShellCustomizer -CustomizerName settingUpMgmtAgtPath -RunElevated $false -Sha256Checksum ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93 -Inline $inline
27+
PS C:\> New-AzImageBuilderCustomizerObject -PowerShellCustomizer -CustomizerName settingUpMgmtAgtPath -RunElevated $false -Inline $inline
28+
29+
Name Type Inline RunElevated ScriptUri Sha256Checksum
30+
---- ---- ------ ----------- --------- --------------
31+
settingUpMgmtAgtPath PowerShell {mkdir c:\\buildActions, echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt} False
2832
29-
Name Type Inline RunElevated ScriptUri Sha256Checksum ValidExitC e
30-
---- ---- ------ ----------- --------- -------------- --
31-
settingUpMgmtAgtPath PowerShell {mkdir c:\\buildActions, echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt} False ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93
3233
```
3334

3435
This command creates a powershell customizer.
@@ -46,11 +47,11 @@ This command creates a restart customizer.
4647

4748
### Example 5: Create a shell customizer
4849
```powershell
49-
PS C:\> New-AzImageBuilderCustomizerObject -ShellCustomizer -CustomizerName downloadBuildArtifacts -ScriptUri "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh" -Sha256Checksum ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93
50+
PS C:\> New-AzImageBuilderCustomizerObject -ShellCustomizer -CustomizerName downloadBuildArtifacts -ScriptUri "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh"
5051
5152
Name Type Inline ScriptUri Sha256Checksum
5253
---- ---- ------ --------- --------------
53-
downloadBuildArtifacts Shell https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93
54+
downloadBuildArtifacts Shell https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh
5455
```
5556

5657
This command creates a shell customizer.

src/ImageBuilder/exports/New-AzImageBuilderCustomizerObject.ps1

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,32 @@ Name Type Filter SearchCriterion
2525
---- ---- ------ --------------- -----------
2626
WindUpdate WindowsUpdate {BrowseOnly, IsInstalled} BrowseOnly=0 and IsInstalled=0 100
2727
.Example
28-
PS C:\> New-AzImageBuilderCustomizerObject -FileCustomizer -CustomizerName 'filecus' -Sha256Checksum 'ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93' -Destination 'c:\\buildArtifacts\\index.html' -SourceUri 'https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html'
28+
PS C:\> New-AzImageBuilderCustomizerObject -FileCustomizer -CustomizerName 'filecus' -Destination 'c:\\buildArtifacts\\index.html' -SourceUri 'https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html'
2929
30-
Name Type Destination Sha256Checksum SourceUri
31-
---- ---- ----------- -------------- ---------
32-
filecus File c:\\buildArtifacts\\index.html ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93 https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html
30+
Name Type Destination Sha256Checksum SourceUri
31+
---- ---- ----------- -------------- ---------
32+
filecus File c:\\buildArtifacts\\index.html https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/
3333
3434
.Example
3535
PS C:\> $inline = @("mkdir c:\\buildActions", "echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt")
36-
PS C:\> New-AzImageBuilderCustomizerObject -PowerShellCustomizer -CustomizerName settingUpMgmtAgtPath -RunElevated $false -Sha256Checksum ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93 -Inline $inline
36+
PS C:\> New-AzImageBuilderCustomizerObject -PowerShellCustomizer -CustomizerName settingUpMgmtAgtPath -RunElevated $false -Inline $inline
37+
38+
Name Type Inline RunElevated ScriptUri Sha256Checksum
39+
---- ---- ------ ----------- --------- --------------
40+
settingUpMgmtAgtPath PowerShell {mkdir c:\\buildActions, echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt} False
3741
38-
Name Type Inline RunElevated ScriptUri Sha256Checksum ValidExitC e
39-
---- ---- ------ ----------- --------- -------------- --
40-
settingUpMgmtAgtPath PowerShell {mkdir c:\\buildActions, echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt} False ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93
4142
.Example
4243
PS C:\> New-AzImageBuilderCustomizerObject -RestartCustomizer -CustomizerName 'restcus' -RestartCommand 'shutdown /f /r /t 0 /c \"packer restart\"' -RestartCheckCommand 'powershell -command "& {Write-Output "restarted."}"' -RestartTimeout '10m'
4344
4445
Name Type RestartCheckCommand RestartCommand RestartTimeout
4546
---- ---- ------------------- -------------- --------------
4647
restcus WindowsRestart powershell -command "& {Write-Output "restarted."}" shutdown /f /r /t 0 /c \"packer restart\" 10m
4748
.Example
48-
PS C:\> New-AzImageBuilderCustomizerObject -ShellCustomizer -CustomizerName downloadBuildArtifacts -ScriptUri "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh" -Sha256Checksum ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93
49+
PS C:\> New-AzImageBuilderCustomizerObject -ShellCustomizer -CustomizerName downloadBuildArtifacts -ScriptUri "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh"
4950
5051
Name Type Inline ScriptUri Sha256Checksum
5152
---- ---- ------ --------- --------------
52-
downloadBuildArtifacts Shell https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93
53+
downloadBuildArtifacts Shell https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh
5354
5455
.Outputs
5556
Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateCustomizer

0 commit comments

Comments
 (0)