New-AzImageBuilderTemplateCustomizerObject
为 ImageTemplateCustomizer 创建内存中对象。
语法
New-AzImageBuilderTemplateCustomizerObject
[-FileCustomizer]
[-Destination <String>]
[-Sha256Checksum <String>]
[-SourceUri <String>]
[-Name <String>]
[<CommonParameters>]
New-AzImageBuilderTemplateCustomizerObject
[-Sha256Checksum <String>]
[-Name <String>]
[-Inline <String[]>]
[-ScriptUri <String>]
[-ShellCustomizer]
[<CommonParameters>]
New-AzImageBuilderTemplateCustomizerObject
[-Sha256Checksum <String>]
[-Name <String>]
[-PowerShellCustomizer]
[-Inline <String[]>]
[-RunAsSystem <Boolean>]
[-RunElevated <Boolean>]
[-ScriptUri <String>]
[-ValidExitCode <Int32[]>]
[<CommonParameters>]
New-AzImageBuilderTemplateCustomizerObject
[-Name <String>]
[-RestartCustomizer]
[-RestartCheckCommand <String>]
[-RestartCommand <String>]
[-RestartTimeout <String>]
[<CommonParameters>]
New-AzImageBuilderTemplateCustomizerObject
[-Name <String>]
[-WindowsUpdateCustomizer]
[-Filter <String[]>]
[-SearchCriterion <String>]
[-UpdateLimit <Int32>]
[<CommonParameters>]
说明
为 ImageTemplateCustomizer 创建内存中对象。
示例
示例 1:创建 Windows 更新定制器。
New-AzImageBuilderTemplateCustomizerObject -WindowsUpdateCustomizer -Name 'WindUpdate' -Filter ("BrowseOnly", "IsInstalled") -SearchCriterion "BrowseOnly=0 and IsInstalled=0" -UpdateLimit 100
Name Filter SearchCriterion UpdateLimit
---- ------ --------------- -----------
WindUpdate {BrowseOnly, IsInstalled} BrowseOnly=0 and IsInstalled=0 100
此命令创建 Windows 更新定制器。
示例 2:创建文件定制器。
New-AzImageBuilderTemplateCustomizerObject -FileCustomizer -Name 'filecus' -Destination 'c:\\buildArtifacts\\index.html' -SourceUri 'https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html'
Name Destination Sha256Checksum SourceUri
---- ----------- -------------- ---------
filecus c:\\buildArtifacts\\index.html https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html
此命令创建文件定制器。
示例 3:创建 powershell 定制器。
New-AzImageBuilderTemplateCustomizerObject -PowerShellCustomizer -Name settingUpMgmtAgtPath -RunElevated $false -Inline "mkdir c:\\buildActions", "echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt"
Name Inline RunAsSystem RunElevated ScriptUri Sha256Checksum ValidExitCode
---- ------ ----------- ----------- --------- -------------- -------------
settingUpMgmtAgtPath {mkdir c:\\buildActions, echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt} False
此命令将创建 powershell 定制器。
示例 4:创建重启定制器。
New-AzImageBuilderTemplateCustomizerObject -RestartCustomizer -Name 'restcus' -RestartCommand 'shutdown /f /r /t 0 /c \"packer restart\"' -RestartCheckCommand 'powershell -command "& {Write-Output "restarted."}"' -RestartTimeout '10m'
Name RestartCheckCommand RestartCommand RestartTimeout
---- ------------------- -------------- --------------
restcus powershell -command "& {Write-Output "restarted."}" shutdown /f /r /t 0 /c \"packer restart\" 10m
此命令将创建重启定制器。
示例 5:创建 shell 定制器。
New-AzImageBuilderTemplateCustomizerObject -ShellCustomizer -Name downloadBuildArtifacts -ScriptUri "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh"
Name Inline ScriptUri Sha256Checksum
---- ------ --------- --------------
downloadBuildArtifacts https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh
此命令创建 shell 定制器。
参数
-Destination
文件(已创建嵌套目录结构)的绝对路径,该文件(来自 sourceUri)将上传到 VM 中。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-FileCustomizer
将文件上传到 VM(Linux、Windows)。 对应于 Packer 文件预配程序。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-Filter
要选择要应用的更新的筛选器数组。 省略或指定空数组以使用默认值(无筛选器)。 有关此字段的示例和详细说明,请参阅上面的链接。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Inline
要执行的 PowerShell 命令数组。
类型: | String[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Name
用于提供此自定义步骤的上下文的友好名称。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-PowerShellCustomizer
在 VM(Windows)上运行指定的 PowerShell。 对应于 Packer powershell 预配程序。 只能指定“scriptUri”或“内联”之一。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-RestartCheckCommand
用于检查重启是否成功的命令 [Default: '']。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-RestartCommand
用于执行重启的命令 [Default: 'shutdown /r /f /t 0 /c 'packer restart'' ]。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-RestartCustomizer
重新启动 VM 并等待 VM 重新联机(Windows)。 对应于 Packer windows-restart 预配程序
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-RestartTimeout
指定为数量级和单位字符串的重启超时,例如“5m”(5 分钟)或“2h”(2 小时)[默认值: '5m']。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-RunAsSystem
如果指定,将使用本地系统用户提升的权限运行 PowerShell 脚本。 仅当上面的 runElevated 字段设置为 true 时,才能为 true。
类型: | Boolean |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-RunElevated
如果指定,将使用提升的权限运行 PowerShell 脚本。
类型: | Boolean |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ScriptUri
要运行用于自定义的 PowerShell 脚本的 URI。 它可以是 github 链接、用于Azure 存储的 SAS URI 等。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-SearchCriterion
搜索更新的条件。 省略或指定空字符串以使用默认值(全部搜索)。 有关此字段的示例和详细说明,请参阅上面的链接。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Sha256Checksum
上述 sourceUri 字段中提供的文件的 SHA256 校验和。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ShellCustomizer
在自定义阶段(Linux)中运行 shell 脚本。 对应于 Packer shell 预配程序。 只能指定“scriptUri”或“内联”之一。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-SourceUri
要上传的文件的 URI,用于自定义 VM。 它可以是 github 链接、用于Azure 存储的 SAS URI 等。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-UpdateLimit
一次应用的最大更新数。 省略或指定 0 以使用默认值 (1000)。
类型: | Int32 |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ValidExitCode
PowerShell 脚本的有效退出代码。 [默认值:0]。
类型: | Int32[] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-WindowsUpdateCustomizer
安装Windows 更新。 对应于 Packer Windows 更新 Provisioner (https://github.com/rgl/packer-provisioner-windows-update)
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |