From 3da841f8b7af21a452d27ea63e82db8fc4b3014d Mon Sep 17 00:00:00 2001 From: Beisi Zhou Date: Fri, 5 Aug 2022 16:46:54 +0800 Subject: [PATCH] draft --- src/ImageBuilder/.gitignore | 16 + src/ImageBuilder/Az.ImageBuilder.psd1 | 135 +---- src/ImageBuilder/README.md | 111 ++-- .../New-AzImageBuilderCustomizerObject.ps1 | 171 ------ .../New-AzImageBuilderDistributorObject.ps1 | 109 ---- .../custom/New-AzImageBuilderSourceObject.ps1 | 117 ----- .../ImageBuilder.cs | 65 +++ ...zImageBuilderTemplate_JsonTemplatePath.ps1 | 159 ++++++ ...mageBuilderTemplate_CreateViaJsonString.cs | 493 ++++++++++++++++++ ...emplateCustomizerObject_FileCustomizer.ps1 | 75 +++ ...eCustomizerObject_PowerShellCustomizer.ps1 | 93 ++++ ...lateCustomizerObject_RestartCustomizer.ps1 | 75 +++ ...mplateCustomizerObject_ShellCustomizer.ps1 | 75 +++ ...stomizerObject_WindowsUpdateCustomizer.ps1 | 75 +++ ...tributorObject_ManagedImageDistributor.ps1 | 75 +++ ...stributorObject_SharedImageDistributor.ps1 | 88 ++++ ...mplateDistributorObject_VhdDistributor.ps1 | 63 +++ ...emplateSourceObject_ManagedImageSource.ps1 | 57 ++ ...mplateSourceObject_PlatformImageSource.ps1 | 93 ++++ ...eSourceObject_SharedImageVersionSource.ps1 | 57 ++ ...ateValidatorObject_PowerShellValidator.ps1 | 93 ++++ ...TemplateValidatorObject_ShellValidator.ps1 | 75 +++ .../custom/New-AzImagerBuilderTemplate.ps1 | 403 -------------- src/ImageBuilder/custom/README.md | 14 +- .../custom/Update-AzImageBuilderTemplate.ps1 | 331 ------------ src/ImageBuilder/docs/Az.ImageBuilder.md | 27 +- .../docs/Get-AzImageBuilderTemplate.md | 86 ++- ...=> Get-AzImageBuilderTemplateRunOutput.md} | 58 +-- .../docs/New-AzImageBuilderTemplate.md | 278 +++++++--- ...AzImageBuilderTemplateCustomizerObject.md} | 123 ++--- ...zImageBuilderTemplateDistributorObject.md} | 74 +-- ...New-AzImageBuilderTemplateSourceObject.md} | 150 +++--- ...w-AzImageBuilderTemplateValidatorObject.md | 219 ++++++++ src/ImageBuilder/docs/README.md | 2 +- .../docs/Remove-AzImageBuilderTemplate.md | 39 +- .../docs/Start-AzImageBuilderTemplate.md | 38 +- .../docs/Stop-AzImageBuilderTemplate.md | 39 +- .../examples/Get-AzImageBuilderRunOutput.md | 38 -- .../examples/Get-AzImageBuilderTemplate.md | 52 +- .../Get-AzImageBuilderTemplateRunOutput.md | 25 + .../New-AzImageBuilderCustomizerObject.md | 66 --- .../New-AzImageBuilderDistributorObject.md | 41 -- .../New-AzImageBuilderSourceObject.md | 40 -- .../examples/New-AzImageBuilderTemplate.md | 29 +- ...-AzImageBuilderTemplateCustomizerObject.md | 64 +++ ...AzImageBuilderTemplateDistributorObject.md | 40 ++ .../New-AzImageBuilderTemplateSourceObject.md | 39 ++ ...w-AzImageBuilderTemplateValidatorObject.md | 26 + .../examples/Remove-AzImageBuilderTemplate.md | 6 +- .../examples/Start-AzImageBuilderTemplate.md | 5 +- .../examples/Stop-AzImageBuilderTemplate.md | 9 +- src/ImageBuilder/how-to.md | 58 +++ src/ImageBuilder/license.txt | 227 ++++++++ src/ImageBuilder/resources/README.md | 11 + ...geBuilderTemplateRunOutput.Recording.json} | 0 ...AzImageBuilderTemplateRunOutput.Tests.ps1} | 2 +- ...BuilderTemplateCustomizerObject.Tests.ps1} | 0 ...uilderTemplateDistributorObject.Tests.ps1} | 0 ...mageBuilderTemplateSourceObject.Tests.ps1} | 0 ...geBuilderTemplateValidatorObject.Tests.ps1 | 25 + .../NewSourceObjectFromJsonObject.Tests.ps1 | 18 - src/ImageBuilder/test/loadEnv.ps1 | 5 +- .../utils/Unprotect-SecureString.ps1 | 16 + 63 files changed, 3130 insertions(+), 1963 deletions(-) create mode 100644 src/ImageBuilder/.gitignore delete mode 100644 src/ImageBuilder/custom/New-AzImageBuilderCustomizerObject.ps1 delete mode 100644 src/ImageBuilder/custom/New-AzImageBuilderDistributorObject.ps1 delete mode 100644 src/ImageBuilder/custom/New-AzImageBuilderSourceObject.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplate/ImageBuilder.cs create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplate/New-AzImageBuilderTemplate_JsonTemplatePath.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplate/NewAzImageBuilderTemplate_CreateViaJsonString.cs create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_FileCustomizer.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_PowerShellCustomizer.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_RestartCustomizer.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_ShellCustomizer.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_WindowsUpdateCustomizer.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateDistributorObject/New-AzImageBuilderTemplateDistributorObject_ManagedImageDistributor.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateDistributorObject/New-AzImageBuilderTemplateDistributorObject_SharedImageDistributor.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateDistributorObject/New-AzImageBuilderTemplateDistributorObject_VhdDistributor.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateSourceObject/New-AzImageBuilderTemplateSourceObject_ManagedImageSource.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateSourceObject/New-AzImageBuilderTemplateSourceObject_PlatformImageSource.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateSourceObject/New-AzImageBuilderTemplateSourceObject_SharedImageVersionSource.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateValidatorObject/New-AzImageBuilderTemplateValidatorObject_PowerShellValidator.ps1 create mode 100644 src/ImageBuilder/custom/New-AzImageBuilderTemplateValidatorObject/New-AzImageBuilderTemplateValidatorObject_ShellValidator.ps1 delete mode 100644 src/ImageBuilder/custom/New-AzImagerBuilderTemplate.ps1 delete mode 100644 src/ImageBuilder/custom/Update-AzImageBuilderTemplate.ps1 rename src/ImageBuilder/docs/{Get-AzImageBuilderRunOutput.md => Get-AzImageBuilderTemplateRunOutput.md} (72%) rename src/ImageBuilder/docs/{New-AzImageBuilderCustomizerObject.md => New-AzImageBuilderTemplateCustomizerObject.md} (65%) rename src/ImageBuilder/docs/{New-AzImageBuilderDistributorObject.md => New-AzImageBuilderTemplateDistributorObject.md} (56%) rename src/ImageBuilder/docs/{New-AzImageBuilderSourceObject.md => New-AzImageBuilderTemplateSourceObject.md} (56%) create mode 100644 src/ImageBuilder/docs/New-AzImageBuilderTemplateValidatorObject.md delete mode 100644 src/ImageBuilder/examples/Get-AzImageBuilderRunOutput.md create mode 100644 src/ImageBuilder/examples/Get-AzImageBuilderTemplateRunOutput.md delete mode 100644 src/ImageBuilder/examples/New-AzImageBuilderCustomizerObject.md delete mode 100644 src/ImageBuilder/examples/New-AzImageBuilderDistributorObject.md delete mode 100644 src/ImageBuilder/examples/New-AzImageBuilderSourceObject.md create mode 100644 src/ImageBuilder/examples/New-AzImageBuilderTemplateCustomizerObject.md create mode 100644 src/ImageBuilder/examples/New-AzImageBuilderTemplateDistributorObject.md create mode 100644 src/ImageBuilder/examples/New-AzImageBuilderTemplateSourceObject.md create mode 100644 src/ImageBuilder/examples/New-AzImageBuilderTemplateValidatorObject.md create mode 100644 src/ImageBuilder/how-to.md create mode 100644 src/ImageBuilder/license.txt create mode 100644 src/ImageBuilder/resources/README.md rename src/ImageBuilder/test/{Get-AzImageBuilderRunOutput.Recording.json => Get-AzImageBuilderTemplateRunOutput.Recording.json} (100%) rename src/ImageBuilder/test/{Get-AzImageBuilderRunOutput.Tests.ps1 => Get-AzImageBuilderTemplateRunOutput.Tests.ps1} (99%) rename src/ImageBuilder/test/{New-AzImageBuilderCustomizerObject.Tests.ps1 => New-AzImageBuilderTemplateCustomizerObject.Tests.ps1} (100%) rename src/ImageBuilder/test/{New-AzImageBuilderDistributorObject.Tests.ps1 => New-AzImageBuilderTemplateDistributorObject.Tests.ps1} (100%) rename src/ImageBuilder/test/{New-AzImageBuilderSourceObject.Tests.ps1 => New-AzImageBuilderTemplateSourceObject.Tests.ps1} (100%) create mode 100644 src/ImageBuilder/test/New-AzImageBuilderTemplateValidatorObject.Tests.ps1 delete mode 100644 src/ImageBuilder/test/NewSourceObjectFromJsonObject.Tests.ps1 create mode 100644 src/ImageBuilder/utils/Unprotect-SecureString.ps1 diff --git a/src/ImageBuilder/.gitignore b/src/ImageBuilder/.gitignore new file mode 100644 index 000000000000..3c3d57339c8b --- /dev/null +++ b/src/ImageBuilder/.gitignore @@ -0,0 +1,16 @@ +bin +obj +.vs +generated +internal +exports +tools +custom/*.psm1 +custom/autogen-model-cmdlets +test/*-TestResults.xml +/*.ps1 +/*.ps1xml +/*.psm1 +/*.snk +/*.csproj +/*.nuspec \ No newline at end of file diff --git a/src/ImageBuilder/Az.ImageBuilder.psd1 b/src/ImageBuilder/Az.ImageBuilder.psd1 index 6c57898dc0c1..737b13dc4ba9 100644 --- a/src/ImageBuilder/Az.ImageBuilder.psd1 +++ b/src/ImageBuilder/Az.ImageBuilder.psd1 @@ -1,139 +1,24 @@ -# -# Module manifest for module 'Az.ImageBuilder' -# -# Generated by: Microsoft Corporation -# -# Generated on: 2021-03-11 -# - @{ - - # Script module or binary module file associated with this manifest. + GUID = 'bdedc683-d9b6-41ea-b310-d068b8c72305' RootModule = './Az.ImageBuilder.psm1' - - # Version number of this module. - ModuleVersion = '0.2.0' - - # Supported PSEditions + ModuleVersion = '0.1.0' CompatiblePSEditions = 'Core', 'Desktop' - - # ID used to uniquely identify this module - GUID = 'bdedc683-d9b6-41ea-b310-d068b8c72305' - - # Author of this module Author = 'Microsoft Corporation' - - # Company or vendor of this module CompanyName = 'Microsoft Corporation' - - # Copyright statement for this module Copyright = 'Microsoft Corporation. All rights reserved.' - - # Description of the functionality provided by this module Description = 'Microsoft Azure PowerShell: ImageBuilder cmdlets' - - # Minimum version of the PowerShell engine required by this module PowerShellVersion = '5.1' - - # Name of the PowerShell host required by this module - # PowerShellHostName = '' - - # Minimum version of the PowerShell host required by this module - # PowerShellHostVersion = '' - - # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. DotNetFrameworkVersion = '4.7.2' - - # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. - # ClrVersion = '' - - # Processor architecture (None, X86, Amd64) required by this module - # ProcessorArchitecture = '' - - # Modules that must be imported into the global environment prior to importing this module - RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '2.2.8'; }) - - # Assemblies that must be loaded prior to importing this module RequiredAssemblies = './bin/Az.ImageBuilder.private.dll' - - # Script files (.ps1) that are run in the caller's environment prior to importing this module. - # ScriptsToProcess = @() - - # Type files (.ps1xml) to be loaded when importing this module - # TypesToProcess = @() - - # Format files (.ps1xml) to be loaded when importing this module FormatsToProcess = './Az.ImageBuilder.format.ps1xml' - - # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess - # NestedModules = @() - - # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - FunctionsToExport = 'Get-AzImageBuilderRunOutput', 'Get-AzImageBuilderTemplate', - 'New-AzImageBuilderCustomizerObject', - 'New-AzImageBuilderDistributorObject', - 'New-AzImageBuilderSourceObject', 'New-AzImageBuilderTemplate', - 'Remove-AzImageBuilderTemplate', 'Start-AzImageBuilderTemplate', - 'Stop-AzImageBuilderTemplate' - - # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. - CmdletsToExport = @() - - # Variables to export from this module - # VariablesToExport = @() - - # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + FunctionsToExport = 'Get-AzImageBuilderTemplate', 'Get-AzImageBuilderTemplateRunOutput', 'New-AzImageBuilderTemplate', 'New-AzImageBuilderTemplateCustomizerObject', 'New-AzImageBuilderTemplateDistributorObject', 'New-AzImageBuilderTemplateSourceObject', 'New-AzImageBuilderTemplateValidatorObject', 'Remove-AzImageBuilderTemplate', 'Start-AzImageBuilderTemplate', 'Stop-AzImageBuilderTemplate', '*' AliasesToExport = '*' - - # DSC resources to export from this module - # DscResourcesToExport = @() - - # List of all modules packaged with this module - # ModuleList = @() - - # List of all files packaged with this module - # FileList = @() - - # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. PrivateData = @{ - - PSData = @{ - - # Tags applied to this module. These help with module discovery in online galleries. - Tags = 'Azure','ResourceManager','ARM','PSModule','ImageBuilder' - - # A URL to the license for this module. - LicenseUri = 'https://aka.ms/azps-license' - - # A URL to the main website for this project. - ProjectUri = 'https://github.com/Azure/azure-powershell' - - # A URL to an icon representing this module. - # IconUri = '' - - # ReleaseNotes of this module - ReleaseNotes = '* Added support for runAsSystem parameter in `New-AzImageBuilderCustomizerObject` [#13163] - * Added support to create template basing on imported json in `New-AzImageBuilderTemplate`. [#12634]' - - # Prerelease string of this module - # Prerelease = '' - - # Flag to indicate whether the module requires explicit user acceptance for install/update/save - # RequireLicenseAcceptance = $false - - # External dependent modules of this module - # ExternalModuleDependencies = @() - - } # End of PSData hashtable - - } # End of PrivateData hashtable - - # HelpInfo URI of this module - # HelpInfoURI = '' - - # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. - # DefaultCommandPrefix = '' - + PSData = @{ + Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'ImageBuilder' + LicenseUri = 'https://aka.ms/azps-license' + ProjectUri = 'https://github.com/Azure/azure-powershell' + ReleaseNotes = '' + } } - - \ No newline at end of file +} diff --git a/src/ImageBuilder/README.md b/src/ImageBuilder/README.md index 51e105d69363..318418eb2e02 100644 --- a/src/ImageBuilder/README.md +++ b/src/ImageBuilder/README.md @@ -17,7 +17,7 @@ This directory contains the PowerShell module for the ImageBuilder service. This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension. ## Module Requirements -- [Az.Accounts module](https://www.powershellgallery.com/packages/Az.Accounts/), version 1.8.1 or greater +- [Az.Accounts module](https://www.powershellgallery.com/packages/Az.Accounts/), version 2.7.5 or greater ## Authentication AutoRest does not generate authentication code for the module. Authentication is handled via Az.Accounts by altering the HTTP payload before it is sent. @@ -50,66 +50,95 @@ In this directory, run AutoRest: require: - $(this-folder)/../readme.azure.noprofile.md input-file: - - $(repo)/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2020-02-14/imagebuilder.json -branch: 94ec975d860d4f62525c2381d1cbf7de3e24df2b + - $(repo)/specification/imagebuilder/resource-manager/Microsoft.VirtualMachineImages/stable/2022-02-14/imagebuilder.json +branch: 9f3ac7b135ac83007b7f3f68ca8ca9705284cff9 title: ImageBuilder module-version: 0.1.0 -subject-prefix: '' +subject-prefix: $(service-name) identity-correction-for-post: true +resourcegroup-append: true directive: + # 1. Remove the unexpanded parameter set + # 2. For New-* cmdlets, ViaIdentity is not required, so CreateViaIdentityExpanded is removed as well - where: - verb: Set|Update - subject: VirtualMachineImageTemplate + variant: ^Create$|^CreateViaIdentity$|^CreateViaIdentityExpanded$ remove: true + # Remove the set-* cmdlet - where: - subject: VirtualMachineImageTemplateRunOutput - set: - subject: ImageBuilderRunOutput + verb: Set + remove: true + # Rename *-AzImageBuildVirtualMachineImage(.*) -> *-AzImageBuild(.*) - where: - subject: VirtualMachineImageTemplate + subject: (.*)Image(.*) set: - subject: ImageBuilderTemplate + subject: $2 + # Update/Upgrade of image template is not supported - where: - verb: New - subject: ImageBuilderTemplate - hide: true + verb: Update + subject: Template + remove: true + # Rename ImageTemplateName -> Name and keep ImageTemplateName as alias in *-AzImageBuildTemplate - where: - subject: ImageBuilderTemplate + subject: Template parameter-name: ImageTemplateName set: - alias: Name - # - where: - # variant: ^Create$|^CreateViaIdentity$|^CreateViaIdentityExpanded$|^Update$|^UpdateViaIdentity$ - # remove: true + parameter-name: Name + alias: ImageTemplateName + # Rename RunOutputName -> Name and keep RunOutputName as alias in *-AzImageBuildTemplateRunOutput - where: - variant: ^CreateExpanded$|^CreateViaIdentityExpanded$ - remove: true + subject: TemplateRunOutput + parameter-name: RunOutputName + set: + parameter-name: Name + alias: RunOutputName + # Rename ValidateInVMValidation to Validator + - where: + parameter-name: ValidateInVMValidation + set: + parameter-name: Validator + # Rename IdentityUserAssignedIdentity to UserAssignedIdentity + - where: + parameter-name: IdentityUserAssignedIdentity + set: + parameter-name: UserAssignedIdentity + # Collapse model with discriminator + - no-inline: + - ImageTemplateCustomizer + - ImageTemplateDistributor + - ImageTemplateSource + - ImageTemplateInVMValidator + # - model-cmdlet: + ############ ImageTemplateCustomizer ############ + # Combine as 1 cmdlet named New-AzImageBuilderTemplateCustomizerObject + # # - ImageTemplateCustomizer + # - ImageTemplateShellCustomizer + # - ImageTemplateRestartCustomizer + # - ImageTemplateWindowsUpdateCustomizer + # - ImageTemplatePowerShellCustomizer + # - ImageTemplateFileCustomizer + ########### ImageTemplateDistributor ########### + # Combine as 1 cmdlet named New-AzImageBuilderTemplateDistributorObject + # # - ImageTemplateDistributor + # - ImageTemplateManagedImageDistributor + # - ImageTemplateSharedImageDistributor + # - ImageTemplateVhdDistributor + ############## ImageTemplateSource ############## + # Combine as 1 cmdlet named New-AzImageBuilderTemplateSourceObject + # # - ImageTemplateSource + # - ImageTemplatePlatformImageSource + # - ImageTemplateManagedImageSource + # - ImageTemplateSharedImageVersionSource + ########### ImageTemplateInVMValidator ########### + # Combine as 1 cmdlet named New-AzImageBuilderTemplateValidatorObject + # # - ImageTemplateInVMValidator + # - ImageTemplateShellValidator + # - ImageTemplatePowerShellValidator - from: source-file-csharp where: $ transform: $ = $.replace(/internal partial interface/, 'public partial interface'); - from: source-file-csharp where: $ transform: $ = $.replace(/Azure-AsyncOperation/g, 'azure-asyncoperation'); - - from: swagger-document - where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}/run"].post.responses - transform: >- - return { - "200": { - "description": "The operation was successful." - }, - "204": { - "description": "The operation was successful." - }, - "202": { - "description": "The operation will be completed asynchronously." - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "#/definitions/ApiError" - } - } - } ``` diff --git a/src/ImageBuilder/custom/New-AzImageBuilderCustomizerObject.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderCustomizerObject.ps1 deleted file mode 100644 index 651b661f2466..000000000000 --- a/src/ImageBuilder/custom/New-AzImageBuilderCustomizerObject.ps1 +++ /dev/null @@ -1,171 +0,0 @@ -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Describes a unit of image customization -.Description -Describes a unit of image customization - -.Link -https://docs.microsoft.com/powershell/module/az.imagebuilder/new-AzImageBuilderCustomizerObject -#> -function New-AzImageBuilderCustomizerObject { - [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateCustomizer')] - [CmdletBinding(PositionalBinding=$false, DefaultParameterSetName="ShellCustomizer")] - Param( - #region CustomizerCommon - [Parameter(Mandatory, HelpMessage="Friendly Name to provide context on what this customization step does.")] - [Alias('Name')] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${CustomizerName}, - [Parameter(ParameterSetName='ShellCustomizer', HelpMessage="Array of shell commands to execute.")] - [Parameter(ParameterSetName='PowerShellCustomizer', HelpMessage="Array of shell commands to execute.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string[]] - ${Inline}, - [Parameter(ParameterSetName='PowerShellCustomizer', HelpMessage="URI of the shell script to be run for customizing. It can be a github link, SAS URI for Azure Storage, etc.")] - [Parameter(ParameterSetName='ShellCustomizer', HelpMessage="URI of the shell script to be run for customizing. It can be a github link, SAS URI for Azure Storage, etc.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${ScriptUri}, - [Parameter(ParameterSetName='ShellCustomizer', HelpMessage="SHA256 checksum of the shell script provided in the scriptUri field.")] - [Parameter(ParameterSetName='FileCustomizer', HelpMessage="SHA256 checksum of the shell script provided in the scriptUri field.")] - [Parameter(ParameterSetName='PowerShellCustomizer', HelpMessage="SHA256 checksum of the shell script provided in the scriptUri field.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${Sha256Checksum}, - #endregion CustomizerCommon - - #region FileCustomizer - [Parameter(ParameterSetName='FileCustomizer', Mandatory, HelpMessage="Uploads files to VMs (Linux, Windows). Corresponds to Packer file provisioner.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Switch] - ${FileCustomizer}, - [Parameter(ParameterSetName='FileCustomizer', HelpMessage="The absolute path to a file (with nested directory structures already created) where the file (from sourceUri) will be uploaded to in the VM.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${Destination}, - [Parameter(ParameterSetName='FileCustomizer', HelpMessage="The URI of the file to be uploaded for customizing the VM. It can be a github link, SAS URI for Azure Storage, etc.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${SourceUri}, - #endregion FileCustomizer - - #region ShellCustomizer - [Parameter(ParameterSetName='ShellCustomizer', Mandatory, HelpMessage="Runs a shell script during the customization phase (Linux). Corresponds to Packer shell provisioner. Exactly one of 'scriptUri' or 'inline' can be specified.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Switch] - ${ShellCustomizer}, - #endregion ShellCustomizer - - #region PowerShellCustomizer - [Parameter(ParameterSetName='PowerShellCustomizer', Mandatory, HelpMessage="Runs the specified PowerShell on the VM (Windows). Corresponds to Packer powershell provisioner. Exactly one of 'scriptUri' or 'inline' can be specified.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Switch] - ${PowerShellCustomizer}, - [Parameter(ParameterSetName='PowerShellCustomizer', HelpMessage="If specified, the PowerShell script will be run with elevated privileges.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Boolean] - ${RunElevated}, - [Parameter(ParameterSetName='PowerShellCustomizer', HelpMessage="If specified, the PowerShell script will be run with elevated privileges using the Local System user. Can only be true when the runElevated field above is set to true.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Boolean] - ${RunAsSystem}, - [Parameter(ParameterSetName='PowerShellCustomizer', HelpMessage="Valid exit codes for the PowerShell script. [Default: 0].")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [int[]] - ${ValidExitCode}, - #endregion PowerShellCustomizer - - #region WindowsUpdateCustomizer - [Parameter(ParameterSetName='WindowsUpdateCustomizer', Mandatory, HelpMessage="Installs Windows Updates. Corresponds to Packer Windows Update Provisioner (https://github.com/rgl/packer-provisioner-windows-update).")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Switch] - ${WindowsUpdateCustomizer}, - [Parameter(ParameterSetName='WindowsUpdateCustomizer', HelpMessage="Array of filters to select updates to apply. Omit or specify empty array to use the default (no filter). Refer to above link for examples and detailed description of this field.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string[]] - ${Filter}, - [Parameter(ParameterSetName='WindowsUpdateCustomizer', HelpMessage="Criteria to search updates. Omit or specify empty string to use the default (search all). Refer to above link for examples and detailed description of this field.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${SearchCriterion}, - [Parameter(ParameterSetName='WindowsUpdateCustomizer', HelpMessage="Maximum number of updates to apply at a time. Omit or specify 0 to use the default (1000).")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [int] - ${UpdateLimit}, - #endregion WindowsUpdateCustomizer - - #region RestartCustomizer - [Parameter(ParameterSetName='RestartCustomizer', Mandatory, HelpMessage="Reboots a VM and waits for it to come back online (Windows). Corresponds to Packer windows-restart provisioner.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Switch] - ${RestartCustomizer}, - [Parameter(ParameterSetName='RestartCustomizer', HelpMessage="Command to check if restart succeeded [Default: ''].")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${RestartCheckCommand}, - [Parameter(ParameterSetName='RestartCustomizer', HelpMessage="Command to execute the restart [Default: 'shutdown /r /f /t 0 /c packer restart']")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${RestartCommand}, - [Parameter(ParameterSetName='RestartCustomizer', HelpMessage="Restart timeout specified as a string of magnitude and unit, e.g. '5m' (5 minutes) or '2h' (2 hours) [Default: '5m'].")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${RestartTimeout} - #endregion RestartCustomizer - ) - - process { - if ($PSBoundParameters.ContainsKey('PowerShellCustomizer')) { - $Customizer = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplatePowerShellCustomizer]::New() - $Customizer.Type = "PowerShell" - $Customizer.Inline = $Inline - $Customizer.RunElevated = $RunElevated - $Customizer.RunAsSystem = $RunAsSystem - $Customizer.ScriptUri = $ScriptUri - $Customizer.Sha256Checksum = $Sha256Checksum - $Customizer.ValidExitCode = $ValidExitCode - } elseif ($PSBoundParameters.ContainsKey('RestartCustomizer')) { - $Customizer = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateRestartCustomizer]::New() - $Customizer.Type = "WindowsRestart" - $Customizer.RestartCheckCommand = $RestartCheckCommand - $Customizer.RestartCommand = $RestartCommand - $Customizer.RestartTimeout = $RestartTimeout - } elseif ($PSBoundParameters.ContainsKey('WindowsUpdateCustomizer')) { - $Customizer = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateWindowsUpdateCustomizer]::New() - $Customizer.Type = "WindowsUpdate" - $Customizer.Filter = $Filter - $Customizer.SearchCriterion = $SearchCriterion - $Customizer.UpdateLimit = $UpdateLimit - } elseif ($PSBoundParameters.ContainsKey('ShellCustomizer')) { - $Customizer = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateShellCustomizer]::New() - $Customizer.Type = "Shell" - $Customizer.Inline = $Inline - $Customizer.ScriptUri = $ScriptUri - $Customizer.Sha256Checksum = $Sha256Checksum - } elseif ($PSBoundParameters.ContainsKey('FileCustomizer')) { - $Customizer = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateFileCustomizer]::New() - $Customizer.Type = "File" - $Customizer.Destination = $Destination - $Customizer.Sha256Checksum = $Sha256Checksum - $Customizer.SourceUri = $SourceUri - } - $Customizer.Name = $CustomizerName - - return $Customizer - } -} \ No newline at end of file diff --git a/src/ImageBuilder/custom/New-AzImageBuilderDistributorObject.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderDistributorObject.ps1 deleted file mode 100644 index ec7fd9f8c654..000000000000 --- a/src/ImageBuilder/custom/New-AzImageBuilderDistributorObject.ps1 +++ /dev/null @@ -1,109 +0,0 @@ -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Generic distribution object -.Description -Generic distribution object - -.Link -https://docs.microsoft.com/powershell/module/az.imagebuilder/new-AzImageBuilderDistributorObject -#> -function New-AzImageBuilderDistributorObject { - [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateDistributor')] - [CmdletBinding(PositionalBinding=$false, DefaultParameterSetName="ManagedImageDistributor")] - Param( - #region DistributorCommon - [Parameter(Mandatory, HelpMessage="Tags that will be applied to the artifact once it has been created/updated by the distributor.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [System.Collections.Hashtable] - ${ArtifactTag}, - [Parameter(Mandatory, HelpMessage="The name to be used for the associated RunOutput.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${RunOutputName}, - #endregion DistributorCommon - - - #region VhdDistributor - [Parameter(ParameterSetName='VhdDistributor', Mandatory, HelpMessage="Distribute via VHD in a storage account.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Switch] - ${VhdDistributor}, - #endregion VhdDistributor - - #region ManagedImageDistributor - [Parameter(ParameterSetName='ManagedImageDistributor', Mandatory, HelpMessage="Distribute as a Managed Disk Image.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Switch] - ${ManagedImageDistributor}, - [Parameter(ParameterSetName='ManagedImageDistributor', Mandatory, HelpMessage="Resource Id of the Managed Disk Image.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${ImageId}, - [Parameter(ParameterSetName='ManagedImageDistributor', Mandatory, HelpMessage="Azure location for the image, should match if image already exists.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${Location}, - #endregion ManagedImageDistributor - - #region SharedImageDistributor - [Parameter(ParameterSetName='SharedImageDistributor', Mandatory, HelpMessage="Distribute via Shared Image Gallery.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Switch] - ${SharedImageDistributor}, - [Parameter(ParameterSetName='SharedImageDistributor', Mandatory, HelpMessage="Flag that indicates whether created image version should be excluded from latest. Omit to use the default (false).")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Boolean] - ${ExcludeFromLatest}, - [Parameter(ParameterSetName='SharedImageDistributor', Mandatory, HelpMessage="A list of regions that the image will be replicated to.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string[]] - ${ReplicationRegion}, - [Parameter(ParameterSetName='SharedImageDistributor', Mandatory, HelpMessage="Resource Id of the Shared Image Gallery image.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${GalleryImageId}, - [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.SharedImageStorageAccountType])] - [Parameter(ParameterSetName='SharedImageDistributor', HelpMessage="Storage account type to be used to store the shared image. Omit to use the default (Standard_LRS).")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.SharedImageStorageAccountType] - ${StorageAccountType} - #endregion SharedImageDistributor - ) - - process { - if ($PSBoundParameters.ContainsKey('VhdDistributor')) { - $Distributor = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateVhdDistributor]::New() - $Distributor.Type = "VHD" - } elseif ($PSBoundParameters.ContainsKey('ManagedImageDistributor')) { - $Distributor = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateManagedImageDistributor]::New() - $Distributor.Type = "ManagedImage" - $Distributor.ImageId = $ImageId - $Distributor.Location = $Location - } elseif ($PSBoundParameters.ContainsKey('SharedImageDistributor')) { - $Distributor = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateSharedImageDistributor]::New() - $Distributor.Type = "SharedImage" - $Distributor.ExcludeFromLatest = $ExcludeFromLatest - $Distributor.GalleryImageId = $GalleryImageId - $Distributor.ReplicationRegion = $ReplicationRegion - $Distributor.StorageAccountType = $StorageAccountType - } - $Distributor.ArtifactTag = $ArtifactTag - $Distributor.RunOutputName = $RunOutputName - - return $Distributor - } -} \ No newline at end of file diff --git a/src/ImageBuilder/custom/New-AzImageBuilderSourceObject.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderSourceObject.ps1 deleted file mode 100644 index 43d77392ebac..000000000000 --- a/src/ImageBuilder/custom/New-AzImageBuilderSourceObject.ps1 +++ /dev/null @@ -1,117 +0,0 @@ -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Describes a virtual machine image source for building, customizing and distributing. -.Description -Describes a virtual machine image source for building, customizing and distributing. - -.Link -https://docs.microsoft.com/powershell/module/az.imagebuilder/New-AzImageBuilderSourceObject -#> -function New-AzImageBuilderSourceObject { - [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateSource')] - [CmdletBinding(PositionalBinding=$false, DefaultParameterSetName="ManagedImage")] - Param( - #region SourceType-PlatformImage - [Parameter(ParameterSetName='PlatformImage', Mandatory, HelpMessage="Describes an image source from [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages).")] - [Parameter(ParameterSetName='PlatformImagePlanInfo', Mandatory, HelpMessage="Describes an image source from [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages).")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Switch] - ${SourceTypePlatformImage}, - [Parameter(ParameterSetName='PlatformImage', HelpMessage="Image offer from the [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages).")] - [Parameter(ParameterSetName='PlatformImagePlanInfo', HelpMessage="Image offer from the [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages).")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${Offer}, - [Parameter(ParameterSetName='PlatformImagePlanInfo', Mandatory, HelpMessage="Name of the purchase plan.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${PlanName}, - [Parameter(ParameterSetName='PlatformImagePlanInfo', Mandatory, HelpMessage="Product of the purchase plan.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${PlanProduct}, - [Parameter(ParameterSetName='PlatformImagePlanInfo', Mandatory, HelpMessage="Publisher of the purchase plan.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${PlanPublisher}, - [Parameter(ParameterSetName='PlatformImage', HelpMessage="Image Publisher in [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages).")] - [Parameter(ParameterSetName='PlatformImagePlanInfo', HelpMessage="Image Publisher in [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages).")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${Publisher}, - [Parameter(ParameterSetName='PlatformImage', HelpMessage="Image sku from the [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages).")] - [Parameter(ParameterSetName='PlatformImagePlanInfo', HelpMessage="Image sku from the [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages).")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${Sku}, - [Parameter(ParameterSetName='PlatformImage', HelpMessage="Image version from the [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages).")] - [Parameter(ParameterSetName='PlatformImagePlanInfo', HelpMessage="Image version from the [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages).")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${Version}, - #endregion SourceType-PlatformImage - - #region SourceType-ManagedImage - [Parameter(ParameterSetName='ManagedImage', Mandatory, HelpMessage="Describes an image source that is a managed image in customer subscription.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Switch] - ${SourceTypeManagedImage}, - [Parameter(ParameterSetName='ManagedImage', HelpMessage="ARM resource id of the managed image in customer subscription.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${ImageId}, - #endregion SourceType-ManagedImage - - #region SourceType-SharedImageVersion - [Parameter(ParameterSetName='SharedImageVersion', Mandatory, HelpMessage="Describes an image source that is an image version in a shared image gallery.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Switch] - ${SourceTypeSharedImageVersion}, - [Parameter(ParameterSetName='SharedImageVersion', HelpMessage="ARM resource id of the image version in the shared image gallery.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [string] - ${ImageVersionId} - #endregion SourceType-SharedImageVersion - ) - - - process { - if ($PSBoundParameters.ContainsKey('SourceTypePlatformImage')) { - $Source = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplatePlatformImageSource]::New() - $Source.Type = "PlatformImage" - $Source.Offer = $Offer - if ($PSBoundParameters.ContainsKey('PlanName')) { - $Source.PlanInfoPlanName = $PlanName - $Source.PlanInfoPlanProduct = $PlanProduct - $Source.PlanInfoPlanPublisher = $PlanPublisher - } - $Source.Publisher = $Publisher - $Source.Sku = $Sku - $Source.Version = $Version - } elseif ($PSBoundParameters.ContainsKey('SourceTypeManagedImage')) { - $Source = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateManagedImageSource]::New() - $Source.Type = "ManagedImage" - $Source.ImageId = $ImageId - } elseif ($PSBoundParameters.ContainsKey('SourceTypeSharedImageVersion')) { - $Source = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateSharedImageVersionSource]::New() - $Source.Type = "SharedImageVersion" - $Source.ImageVersionId = $ImageVersionId - } - - return $Source - } -} \ No newline at end of file diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplate/ImageBuilder.cs b/src/ImageBuilder/custom/New-AzImageBuilderTemplate/ImageBuilder.cs new file mode 100644 index 000000000000..f751cac89380 --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplate/ImageBuilder.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder +{ + using static Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Extensions; + + /// + /// Low-level API implementation for the ImageBuilder service. + /// Virtual Machine Image Template + /// + public partial class ImageBuilder + { + /// Create or update a virtual machine image template + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription + /// Id forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the image Template + /// Json string supplied to the CreateImageTemplate operation + /// a delegate that is called when the remote service returns 200 (OK). + /// a delegate that is called when the remote service returns default (any response code not handled + /// elsewhere). + /// an instance that will receive events. + /// an instance of an Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.ISendAsync pipeline to use to make the request. + /// + /// A that will be complete when handling of the response is completed. + /// + public async global::System.Threading.Tasks.Task VirtualMachineImageTemplatesCreateOrUpdateViaJsonString(string subscriptionId, string resourceGroupName, string imageTemplateName, string jsonString, global::System.Func, global::System.Threading.Tasks.Task> onOk, global::System.Func, global::System.Threading.Tasks.Task> onDefault, Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener eventListener, Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.ISendAsync sender) + { + var apiVersion = @"2022-02-14"; + // Constant Parameters + using( NoSynchronizationContext ) + { + // construct URL + var pathAndQuery = global::System.Text.RegularExpressions.Regex.Replace( + "/subscriptions/" + + global::System.Uri.EscapeDataString(subscriptionId) + + "/resourceGroups/" + + global::System.Uri.EscapeDataString(resourceGroupName) + + "/providers/Microsoft.VirtualMachineImages/imageTemplates/" + + global::System.Uri.EscapeDataString(imageTemplateName) + + "?" + + "api-version=" + global::System.Uri.EscapeDataString(apiVersion) + ,"\\?&*$|&*$|(\\?)&+|(&)&+","$1$2"); + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.URLCreated, pathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + + // generate request object + var _url = new global::System.Uri($"https://management.azure.com{pathAndQuery}"); + var request = new global::System.Net.Http.HttpRequestMessage(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Method.Put, _url); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.RequestCreated, request.RequestUri.PathAndQuery); if( eventListener.Token.IsCancellationRequested ) { return; } + + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.HeaderParametersAdded); if( eventListener.Token.IsCancellationRequested ) { return; } + // set body content + request.Content = new global::System.Net.Http.StringContent(jsonString, global::System.Text.Encoding.UTF8); + request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + await eventListener.Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.BodyContentSet); if( eventListener.Token.IsCancellationRequested ) { return; } + // make the call + await this.VirtualMachineImageTemplatesCreateOrUpdate_Call(request,onOk,onDefault,eventListener,sender); + } + } + } +} \ No newline at end of file diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplate/New-AzImageBuilderTemplate_JsonTemplatePath.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplate/New-AzImageBuilderTemplate_JsonTemplatePath.ps1 new file mode 100644 index 000000000000..b081805080c0 --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplate/New-AzImageBuilderTemplate_JsonTemplatePath.ps1 @@ -0,0 +1,159 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create or update a virtual machine image template +.Description +Create or update a virtual machine image template +.Example +$srcPlatform = New-AzImageBuilderSourceObject -SourceTypePlatformImage -Publisher 'Canonical' -Offer 'UbuntuServer' -Sku '18.04-LTS' -Version 'latest' +$disSharedImg = New-AzImageBuilderDistributorObject -SharedImageDistributor -ArtifactTag @{tag='dis-share'} -GalleryImageId '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/testsharedgallery/images/imagedefinition-linux/versions/1.0.0' -ReplicationRegion 'eastus2' -RunOutputName 'runoutput-01' -ExcludeFromLatest $false +$customizer = New-AzImageBuilderCustomizerObject -ShellCustomizer -CustomizerName 'CheckSumCompareShellScript' -ScriptUri 'https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh' -Sha256Checksum 'ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93' +$userAssignedIdentity = '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/wyunchi-imagebuilder/providers/Microsoft.ManagedIdentity/userAssignedIdentities/image-builder-user-assign-identity' +New-AzImageBuilderTemplate -ImageTemplateName platform-shared-img -ResourceGroupName wyunchi-imagebuilder -Source $srcPlatform -Distribute $disSharedImg -Customize $customizer -Location eastus -UserAssignedIdentityId $userAssignedIdentity + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplate +.Notes +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + +CUSTOMIZE : Specifies the properties used to describe the customization steps of the image, like Image source etc + Type : The type of customization tool you want to use on the Image. For example, "Shell" can be shell customizer + [Name ]: Friendly Name to provide context on what this customization step does + +DISTRIBUTE : The distribution targets where the image output needs to go to. + RunOutputName : The name to be used for the associated RunOutput. + Type : Type of distribution. + [ArtifactTag ]: Tags that will be applied to the artifact once it has been created/updated by the distributor. + [(Any) ]: This indicates any property can be added to this object. + +VALIDATEINVMVALIDATION : List of validations to be performed. + Type : The type of validation you want to use on the Image. For example, "Shell" can be shell validation + [Name ]: Friendly Name to provide context on what this validation step does +.Link +https://docs.microsoft.com/powershell/module/az.imagebuilder/new-azimagebuildertemplate +#> +function New-AzImageBuilderTemplate_JsonTemplatePath { +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplate])] +[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] +param( + [Parameter(Mandatory)] + [Alias('ImageTemplateName')] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Path')] + [System.String] + # The name of the image Template + ${Name}, + + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Path')] + [System.String] + # The name of the resource group. + ${ResourceGroupName}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Path')] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] + [System.String] + # Subscription credentials which uniquely identify Microsoft Azure subscription. + # The subscription Id forms part of the URI for every service call. + ${SubscriptionId}, + + [Parameter(Mandatory)] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] + [System.String] + ${JsonTemplatePath}, + + [Parameter()] + [Alias('AzureRMContext', 'AzureCredential')] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Azure')] + [System.Management.Automation.PSObject] + # The credentials, account, tenant, and subscription used for communication with Azure. + ${DefaultProfile}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Run the command as a job + ${AsJob}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Wait for .NET debugger to attach + ${Break}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be appended to the front of the pipeline + ${HttpPipelineAppend}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.SendAsyncStep[]] + # SendAsync Pipeline Steps to be prepended to the front of the pipeline + ${HttpPipelinePrepend}, + + [Parameter()] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Run the command asynchronously + ${NoWait}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] + [System.Uri] + # The URI for the proxy server to use + ${Proxy}, + + [Parameter(DontShow)] + [ValidateNotNull()] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] + [System.Management.Automation.PSCredential] + # Credentials for a proxy server to use for the remote call + ${ProxyCredential}, + + [Parameter(DontShow)] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] + [System.Management.Automation.SwitchParameter] + # Use the default credentials for the proxy + ${ProxyUseDefaultCredentials} +) + process { + try { + if (-not (Test-Path $JsonTemplatePath)) + { + Write-Error "Cannot find file $JsonTemplatePath. Please make sure it exists!" + exit 1 + } + $JsonString = Get-Content $JsonTemplatePath -Raw + Write-Host $JsonString + $null = $PSBoundParameters.Add("JsonString", $JsonString) + $null = $PSBoundParameters.Remove("JsonTemplatePath") + Az.ImageBuilder.private\New-AzImageBuilderTemplate_CreateViaJsonString @PSBoundParameters + } catch { + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() + throw + } + + } +} diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplate/NewAzImageBuilderTemplate_CreateViaJsonString.cs b/src/ImageBuilder/custom/New-AzImageBuilderTemplate/NewAzImageBuilderTemplate_CreateViaJsonString.cs new file mode 100644 index 000000000000..7cb3ae125b3b --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplate/NewAzImageBuilderTemplate_CreateViaJsonString.cs @@ -0,0 +1,493 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Cmdlets +{ + using static Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Extensions; + using System; + + /// Create or update a virtual machine image template + /// + /// [OpenAPI] CreateOrUpdate=>PUT:"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.VirtualMachineImages/imageTemplates/{imageTemplateName}" + /// + [global::System.Management.Automation.Cmdlet(global::System.Management.Automation.VerbsCommon.New, @"AzImageBuilderTemplate_CreateViaJsonString", SupportsShouldProcess = true)] + [global::System.Management.Automation.OutputType(typeof(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplate))] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Description(@"Create or update a virtual machine image template")] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Generated] + public partial class NewAzImageBuilderTemplate_CreateViaJsonString : global::System.Management.Automation.PSCmdlet, + Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener + { + /// A unique id generatd for the this cmdlet when it is instantiated. + private string __correlationId = System.Guid.NewGuid().ToString(); + + /// A copy of the Invocation Info (necessary to allow asJob to clone this cmdlet) + private global::System.Management.Automation.InvocationInfo __invocationInfo; + + /// A unique id generatd for the this cmdlet when ProcessRecord() is called. + private string __processRecordId; + + /// + /// The for this operation. + /// + private global::System.Threading.CancellationTokenSource _cancellationTokenSource = new global::System.Threading.CancellationTokenSource(); + + /// when specified, runs this cmdlet as a PowerShell job + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command as a job")] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter AsJob { get; set; } + + /// Wait for .NET debugger to attach + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Wait for .NET debugger to attach")] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter Break { get; set; } + + /// The reference to the client API class. + public Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ImageBuilder Client => Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Module.Instance.ClientAPI; + + /// + /// The credentials, account, tenant, and subscription used for communication with Azure + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] + [global::System.Management.Automation.ValidateNotNull] + [global::System.Management.Automation.Alias("AzureRMContext", "AzureCredential")] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Azure)] + public global::System.Management.Automation.PSObject DefaultProfile { get; set; } + + /// SendAsync Pipeline Steps to be appended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be appended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.SendAsyncStep[] HttpPipelineAppend { get; set; } + + /// SendAsync Pipeline Steps to be prepended to the front of the pipeline + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "SendAsync Pipeline Steps to be prepended to the front of the pipeline")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Runtime)] + public Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.SendAsyncStep[] HttpPipelinePrepend { get; set; } + + /// Accessor for our copy of the InvocationInfo. + public global::System.Management.Automation.InvocationInfo InvocationInformation { get => __invocationInfo = __invocationInfo ?? this.MyInvocation ; set { __invocationInfo = value; } } + + /// + /// cancellation delegate. Stops the cmdlet when called. + /// + global::System.Action Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener.Cancel => _cancellationTokenSource.Cancel; + + /// cancellation token. + global::System.Threading.CancellationToken Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener.Token => _cancellationTokenSource.Token; + + /// Backing field for property. + private string _name; + + /// The name of the image Template + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the image Template")] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the image Template", + SerializedName = @"imageTemplateName", + PossibleTypes = new [] { typeof(string) })] + [global::System.Management.Automation.Alias("ImageTemplateName")] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Path)] + public string Name { get => this._name; set => this._name = value; } + + /// + /// when specified, will make the remote call, and return an AsyncOperationResponse, letting the remote operation continue + /// asynchronously. + /// + [global::System.Management.Automation.Parameter(Mandatory = false, HelpMessage = "Run the command asynchronously")] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter NoWait { get; set; } + + /// + /// The instance of the that the remote call will use. + /// + private Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.HttpPipeline Pipeline { get; set; } + + /// The URI for the proxy server to use + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "The URI for the proxy server to use")] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Runtime)] + public global::System.Uri Proxy { get; set; } + + /// Credentials for a proxy server to use for the remote call + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Credentials for a proxy server to use for the remote call")] + [global::System.Management.Automation.ValidateNotNull] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Runtime)] + public global::System.Management.Automation.PSCredential ProxyCredential { get; set; } + + /// Use the default credentials for the proxy + [global::System.Management.Automation.Parameter(Mandatory = false, DontShow = true, HelpMessage = "Use the default credentials for the proxy")] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Runtime)] + public global::System.Management.Automation.SwitchParameter ProxyUseDefaultCredentials { get; set; } + + /// Backing field for property. + private string _resourceGroupName; + + /// The name of the resource group. + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "The name of the resource group.")] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"The name of the resource group.", + SerializedName = @"resourceGroupName", + PossibleTypes = new [] { typeof(string) })] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Path)] + public string ResourceGroupName { get => this._resourceGroupName; set => this._resourceGroupName = value; } + + /// Backing field for property. + private string _subscriptionId; + + /// + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription Id forms part of the URI + /// for every service call. + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription Id forms part of the URI for every service call.")] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription Id forms part of the URI for every service call.", + SerializedName = @"subscriptionId", + PossibleTypes = new [] { typeof(string) })] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.DefaultInfo( + Name = @"", + Description =@"", + Script = @"(Get-AzContext).Subscription.Id")] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Path)] + public string SubscriptionId { get => this._subscriptionId; set => this._subscriptionId = value; } + + /// + /// Json string + /// + [global::System.Management.Automation.Parameter(Mandatory = true, HelpMessage = "Json string.")] + [global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category(global::Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ParameterCategory.Runtime)] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Info( + Required = true, + ReadOnly = false, + Description = @"Json string", + PossibleTypes = new [] { typeof(string) })] + public string JsonString { get => this._jsonString; set => this._jsonString = value; } + + /// Backing field for property. + private string _jsonString; + + /// + /// overrideOnDefault will be called before the regular onDefault has been processed, allowing customization of what + /// happens on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ICloudError + /// from the remote call + /// /// Determines if the rest of the onDefault method should be processed, or if the method should + /// return immediately (set to true to skip further processing ) + + partial void overrideOnDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// overrideOnOk will be called before the regular onOk has been processed, allowing customization of what happens + /// on that response. Implement this method in a partial class to enable this behavior + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplate + /// from the remote call + /// /// Determines if the rest of the onOk method should be processed, or if the method should return + /// immediately (set to true to skip further processing ) + + partial void overrideOnOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response, ref global::System.Threading.Tasks.Task returnNow); + + /// + /// (overrides the default BeginProcessing method in global::System.Management.Automation.PSCmdlet) + /// + protected override void BeginProcessing() + { + var telemetryId = Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Module.Instance.GetTelemetryId.Invoke(); + if (telemetryId != "" && telemetryId != "internal") + { + __correlationId = telemetryId; + } + Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials); + if (Break) + { + Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.AttachDebugger.Break(); + } + ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.CmdletBeginProcessing).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + + /// Creates a duplicate instance of this cmdlet (via JSON serialization). + /// a duplicate instance of NewAzImageBuilderTemplate_CreateViaJsonString + public Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Cmdlets.NewAzImageBuilderTemplate_CreateViaJsonString Clone() + { + var clone = new NewAzImageBuilderTemplate_CreateViaJsonString(); + clone.__correlationId = this.__correlationId; + clone.__processRecordId = this.__processRecordId; + clone.DefaultProfile = this.DefaultProfile; + clone.InvocationInformation = this.InvocationInformation; + clone.Proxy = this.Proxy; + clone.Pipeline = this.Pipeline; + clone.AsJob = this.AsJob; + clone.Break = this.Break; + clone.ProxyCredential = this.ProxyCredential; + clone.ProxyUseDefaultCredentials = this.ProxyUseDefaultCredentials; + clone.HttpPipelinePrepend = this.HttpPipelinePrepend; + clone.HttpPipelineAppend = this.HttpPipelineAppend; + clone.SubscriptionId = this.SubscriptionId; + clone.ResourceGroupName = this.ResourceGroupName; + clone.JsonString = this.JsonString; + clone.Name = this.Name; + return clone; + } + + /// Performs clean-up after the command execution + protected override void EndProcessing() + { + + } + + /// Handles/Dispatches events during the call to the REST service. + /// The message id + /// The message cancellation token. When this call is cancelled, this should be true + /// Detailed message data for the message event. + /// + /// A that will be complete when handling of the message is completed. + /// + async global::System.Threading.Tasks.Task Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener.Signal(string id, global::System.Threading.CancellationToken token, global::System.Func messageData) + { + using( NoSynchronizationContext ) + { + if (token.IsCancellationRequested) + { + return ; + } + + switch ( id ) + { + case Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.Verbose: + { + WriteVerbose($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.Warning: + { + WriteWarning($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.Information: + { + // When an operation supports asjob, Information messages must go thru verbose. + WriteVerbose($"INFORMATION: {(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.Debug: + { + WriteDebug($"{(messageData().Message ?? global::System.String.Empty)}"); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.Error: + { + WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) ); + return ; + } + case Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.DelayBeforePolling: + { + if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")) + { + var data = messageData(); + if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response) + { + var asyncOperation = response.GetFirstHeader(@"azure-asyncoperation"); + var location = response.GetFirstHeader(@"Location"); + var uri = global::System.String.IsNullOrEmpty(asyncOperation) ? global::System.String.IsNullOrEmpty(location) ? response.RequestMessage.RequestUri.AbsoluteUri : location : asyncOperation; + WriteObject(new Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.PowerShell.AsyncOperationResponse { Target = uri }); + // do nothing more. + data.Cancel(); + return; + } + } + break; + } + } + await Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Module.Instance.Signal(id, token, messageData, (i,t,m) => ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Signal(i,t,()=> Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.EventDataConverter.ConvertFrom( m() ) as Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.EventData ), InvocationInformation, this.ParameterSetName, __correlationId, __processRecordId, null ); + if (token.IsCancellationRequested) + { + return ; + } + WriteDebug($"{id}: {(messageData().Message ?? global::System.String.Empty)}"); + } + } + + /// + /// Intializes a new instance of the cmdlet class. + /// + public NewAzImageBuilderTemplate_CreateViaJsonString() + { + + } + + /// Performs execution of the command. + protected override void ProcessRecord() + { + ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.CmdletProcessRecordStart).Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + __processRecordId = System.Guid.NewGuid().ToString(); + try + { + // work + if (ShouldProcess($"Call remote 'NewAzImageBuilderTemplate_CreateViaJsonString' operation")) + { + if (true == MyInvocation?.BoundParameters?.ContainsKey("AsJob")) + { + var instance = this.Clone(); + var job = new Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.PowerShell.AsyncJob(instance, this.MyInvocation.Line, this.MyInvocation.MyCommand.Name, this._cancellationTokenSource.Token, this._cancellationTokenSource.Cancel); + JobRepository.Add(job); + var task = instance.ProcessRecordAsync(); + job.Monitor(task); + WriteObject(job); + } + else + { + using( var asyncCommandRuntime = new Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.PowerShell.AsyncCommandRuntime(this, ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Token) ) + { + asyncCommandRuntime.Wait( ProcessRecordAsync(),((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Token); + } + } + } + } + catch (global::System.AggregateException aggregateException) + { + // unroll the inner exceptions to get the root cause + foreach( var innerException in aggregateException.Flatten().InnerExceptions ) + { + ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.CmdletException, $"{innerException.GetType().Name} - {innerException.Message} : {innerException.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(innerException,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + } + catch (global::System.Exception exception) when ((exception as System.Management.Automation.PipelineStoppedException)== null || (exception as System.Management.Automation.PipelineStoppedException).InnerException != null) + { + ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.CmdletException, $"{exception.GetType().Name} - {exception.Message} : {exception.StackTrace}").Wait(); if( ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Write exception out to error channel. + WriteError( new global::System.Management.Automation.ErrorRecord(exception,string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null) ); + } + finally + { + ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.CmdletProcessRecordEnd).Wait(); + } + } + + /// Performs execution of the command, working asynchronously if required. + /// + /// A that will be complete when handling of the method is completed. + /// + protected async global::System.Threading.Tasks.Task ProcessRecordAsync() + { + using( NoSynchronizationContext ) + { + await ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.CmdletGetPipeline); if( ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + Pipeline = Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Module.Instance.CreatePipeline(InvocationInformation, __correlationId, __processRecordId, this.ParameterSetName); + if (null != HttpPipelinePrepend) + { + Pipeline.Prepend((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelinePrepend) ?? HttpPipelinePrepend); + } + if (null != HttpPipelineAppend) + { + Pipeline.Append((this.CommandRuntime as Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(HttpPipelineAppend) ?? HttpPipelineAppend); + } + // get the client instance + try + { + await ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.CmdletBeforeAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + // Customization: CreateOrUpdateViaJsonString + await this.Client.VirtualMachineImageTemplatesCreateOrUpdateViaJsonString(SubscriptionId, ResourceGroupName, Name, JsonString, onOk, onDefault, this, Pipeline); + await ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.CmdletAfterAPICall); if( ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Token.IsCancellationRequested ) { return; } + } + catch (Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.UndeclaredResponseException urexception) + { + // Customization: Write error based on JsonString + WriteError(new global::System.Management.Automation.ErrorRecord(urexception, urexception.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId,ResourceGroupName=ResourceGroupName,Name=Name,JsonString=JsonString}) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(urexception.Message) { RecommendedAction = urexception.Action } + }); + } + finally + { + await ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Signal(Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Events.CmdletProcessRecordAsyncEnd); + } + } + } + + /// Interrupts currently running code within the command. + protected override void StopProcessing() + { + ((Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.IEventListener)this).Cancel(); + base.StopProcessing(); + } + + /// + /// a delegate that is called when the remote service returns default (any response code not handled elsewhere). + /// + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ICloudError + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onDefault(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnDefault(responseMessage, response, ref _returnNow); + // if overrideOnDefault has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // Error Response : default + var code = (await response)?.Code; + var message = (await response)?.Message; + if ((null == code || null == message)) + { + // Unrecognized Response. Create an error record based on what we have. + var ex = new Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.RestException(responseMessage, await response); + // Customization: Write error based on JsonString + WriteError( new global::System.Management.Automation.ErrorRecord(ex, ex.Code, global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId, ResourceGroupName=ResourceGroupName, Name=Name, JsonString=JsonString }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(ex.Message) { RecommendedAction = ex.Action } + }); + } + else + { + // Customization: Write error based on JsonString + WriteError( new global::System.Management.Automation.ErrorRecord(new global::System.Exception($"[{code}] : {message}"), code?.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { SubscriptionId=SubscriptionId, ResourceGroupName=ResourceGroupName, Name=Name, JsonString=JsonString }) + { + ErrorDetails = new global::System.Management.Automation.ErrorDetails(message) { RecommendedAction = global::System.String.Empty } + }); + } + } + } + + /// a delegate that is called when the remote service returns 200 (OK). + /// the raw response message as an global::System.Net.Http.HttpResponseMessage. + /// the body result as a Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplate + /// from the remote call + /// + /// A that will be complete when handling of the method is completed. + /// + private async global::System.Threading.Tasks.Task onOk(global::System.Net.Http.HttpResponseMessage responseMessage, global::System.Threading.Tasks.Task response) + { + using( NoSynchronizationContext ) + { + var _returnNow = global::System.Threading.Tasks.Task.FromResult(false); + overrideOnOk(responseMessage, response, ref _returnNow); + // if overrideOnOk has returned true, then return right away. + if ((null != _returnNow && await _returnNow)) + { + return ; + } + // onOk - response for 200 / application/json + // (await response) // should be Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplate + WriteObject((await response)); + } + } + } +} \ No newline at end of file diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_FileCustomizer.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_FileCustomizer.ps1 new file mode 100644 index 000000000000..ea0940a96873 --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_FileCustomizer.ps1 @@ -0,0 +1,75 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateCustomizer. +.Description +Create an in-memory object for ImageTemplateCustomizer. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateFileCustomizer +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatecustomizerobject +#> +function New-AzImageBuilderTemplateCustomizerObject_FileCustomizer { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateFileCustomizer')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(HelpMessage="The absolute path to a file (with nested directory structures already created) where the file (from sourceUri) will be uploaded to in the VM.")] + [string] + $Destination, + [Parameter(HelpMessage="SHA256 checksum of the file provided in the sourceUri field above.")] + [string] + $Sha256Checksum, + [Parameter(HelpMessage="The URI of the file to be uploaded for customizing the VM. It can be a github link, SAS URI for Azure Storage, etc.")] + [string] + $SourceUri, + [Parameter(HelpMessage="Friendly Name to provide context on what this customization step does.")] + [string] + $Name, + # Change it to switch parameter + # [Parameter(Mandatory, HelpMessage="The type of customization tool you want to use on the Image. For example, `"Shell`" can be shell customizer.")] + # [string] + # $Type + [Parameter(Mandatory, HelpMessage="Uploads files to VMs (Linux, Windows). Corresponds to Packer file provisioner.")] + [Switch] + $FileCustomizer + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateFileCustomizer]::New() + + if ($PSBoundParameters.ContainsKey('Destination')) { + $Object.Destination = $Destination + } + if ($PSBoundParameters.ContainsKey('Sha256Checksum')) { + $Object.Sha256Checksum = $Sha256Checksum + } + if ($PSBoundParameters.ContainsKey('SourceUri')) { + $Object.SourceUri = $SourceUri + } + if ($PSBoundParameters.ContainsKey('Name')) { + $Object.Name = $Name + } + if ($FileCustomizer.IsPresent) { + $Object.Type = "File" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_PowerShellCustomizer.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_PowerShellCustomizer.ps1 new file mode 100644 index 000000000000..8fdac3546762 --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_PowerShellCustomizer.ps1 @@ -0,0 +1,93 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateCustomizer. +.Description +Create an in-memory object for ImageTemplateCustomizer. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplatePowerShellCustomizer +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatecustomizerobject +#> +function New-AzImageBuilderTemplateCustomizerObject_PowerShellCustomizer { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplatePowerShellCustomizer')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(HelpMessage="Array of PowerShell commands to execute.")] + [string[]] + $Inline, + [Parameter(HelpMessage="If specified, the PowerShell script will be run with elevated privileges using the Local System user. Can only be true when the runElevated field above is set to true.")] + [bool] + $RunAsSystem, + [Parameter(HelpMessage="If specified, the PowerShell script will be run with elevated privileges.")] + [bool] + $RunElevated, + [Parameter(HelpMessage="URI of the PowerShell script to be run for customizing. It can be a github link, SAS URI for Azure Storage, etc.")] + [string] + $ScriptUri, + [Parameter(HelpMessage="SHA256 checksum of the power shell script provided in the scriptUri field above.")] + [string] + $Sha256Checksum, + [Parameter(HelpMessage="Valid exit codes for the PowerShell script. [Default: 0].")] + [int[]] + $ValidExitCode, + [Parameter(HelpMessage="Friendly Name to provide context on what this customization step does.")] + [string] + $Name, + # Change it to switch parameter + # [Parameter(Mandatory, HelpMessage="The type of customization tool you want to use on the Image. For example, `"Shell`" can be shell customizer.")] + # [string] + # $Type + [Parameter(Mandatory, HelpMessage="Runs the specified PowerShell on the VM (Windows). Corresponds to Packer powershell provisioner. Exactly one of 'scriptUri' or 'inline' can be specified.")] + [Switch] + $PowerShellCustomizer + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplatePowerShellCustomizer]::New() + + if ($PSBoundParameters.ContainsKey('Inline')) { + $Object.Inline = $Inline + } + if ($PSBoundParameters.ContainsKey('RunAsSystem')) { + $Object.RunAsSystem = $RunAsSystem + } + if ($PSBoundParameters.ContainsKey('RunElevated')) { + $Object.RunElevated = $RunElevated + } + if ($PSBoundParameters.ContainsKey('ScriptUri')) { + $Object.ScriptUri = $ScriptUri + } + if ($PSBoundParameters.ContainsKey('Sha256Checksum')) { + $Object.Sha256Checksum = $Sha256Checksum + } + if ($PSBoundParameters.ContainsKey('ValidExitCode')) { + $Object.ValidExitCode = $ValidExitCode + } + if ($PSBoundParameters.ContainsKey('Name')) { + $Object.Name = $Name + } + if ($PowerShellCustomizer.IsPresent) { + $Object.Type = "PowerShell" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_RestartCustomizer.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_RestartCustomizer.ps1 new file mode 100644 index 000000000000..9930f88687a4 --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_RestartCustomizer.ps1 @@ -0,0 +1,75 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateCustomizer. +.Description +Create an in-memory object for ImageTemplateCustomizer. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateRestartCustomizer +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatecustomizerobject +#> +function New-AzImageBuilderTemplateCustomizerObject_RestartCustomizer { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateRestartCustomizer')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(HelpMessage="Command to check if restart succeeded [Default: ''].")] + [string] + $RestartCheckCommand, + [Parameter(HelpMessage="Command to execute the restart [Default: 'shutdown /r /f /t 0 /c `"packer restart`"'].")] + [string] + $RestartCommand, + [Parameter(HelpMessage="Restart timeout specified as a string of magnitude and unit, e.g. '5m' (5 minutes) or '2h' (2 hours) [Default: '5m'].")] + [string] + $RestartTimeout, + [Parameter(HelpMessage="Friendly Name to provide context on what this customization step does.")] + [string] + $Name, + # Change it to switch parameter + # [Parameter(Mandatory, HelpMessage="The type of customization tool you want to use on the Image. For example, `"Shell`" can be shell customizer.")] + # [string] + # $Type + [Parameter(Mandatory, HelpMessage="Reboots a VM and waits for it to come back online (Windows). Corresponds to Packer windows-restart provisioner")] + [Switch] + $RestartCustomizer + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateRestartCustomizer]::New() + + if ($PSBoundParameters.ContainsKey('RestartCheckCommand')) { + $Object.RestartCheckCommand = $RestartCheckCommand + } + if ($PSBoundParameters.ContainsKey('RestartCommand')) { + $Object.RestartCommand = $RestartCommand + } + if ($PSBoundParameters.ContainsKey('RestartTimeout')) { + $Object.RestartTimeout = $RestartTimeout + } + if ($PSBoundParameters.ContainsKey('Name')) { + $Object.Name = $Name + } + if ($RestartCustomizer.IsPresent) { + $Object.Type = "WindowsRestart" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_ShellCustomizer.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_ShellCustomizer.ps1 new file mode 100644 index 000000000000..8c8dc516493d --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_ShellCustomizer.ps1 @@ -0,0 +1,75 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateCustomizer. +.Description +Create an in-memory object for ImageTemplateCustomizer. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateShellCustomizer +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatecustomizerobject +#> +function New-AzImageBuilderTemplateCustomizerObject_ShellCustomizer { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateShellCustomizer')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(HelpMessage="Array of shell commands to execute.")] + [string[]] + $Inline, + [Parameter(HelpMessage="URI of the shell script to be run for customizing. It can be a github link, SAS URI for Azure Storage, etc.")] + [string] + $ScriptUri, + [Parameter(HelpMessage="SHA256 checksum of the shell script provided in the scriptUri field.")] + [string] + $Sha256Checksum, + [Parameter(HelpMessage="Friendly Name to provide context on what this customization step does.")] + [string] + $Name, + # Change it to switch parameter + # [Parameter(Mandatory, HelpMessage="The type of customization tool you want to use on the Image. For example, `"Shell`" can be shell customizer.")] + # [string] + # $Type + [Parameter(Mandatory, HelpMessage="Runs a shell script during the customization phase (Linux). Corresponds to Packer shell provisioner. Exactly one of 'scriptUri' or 'inline' can be specified.")] + [Switch] + $ShellCustomizer + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateShellCustomizer]::New() + + if ($PSBoundParameters.ContainsKey('Inline')) { + $Object.Inline = $Inline + } + if ($PSBoundParameters.ContainsKey('ScriptUri')) { + $Object.ScriptUri = $ScriptUri + } + if ($PSBoundParameters.ContainsKey('Sha256Checksum')) { + $Object.Sha256Checksum = $Sha256Checksum + } + if ($PSBoundParameters.ContainsKey('Name')) { + $Object.Name = $Name + } + if ($ShellCustomizer.IsPresent) { + $Object.Type = "Shell" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_WindowsUpdateCustomizer.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_WindowsUpdateCustomizer.ps1 new file mode 100644 index 000000000000..8686f819750d --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateCustomizerObject/New-AzImageBuilderTemplateCustomizerObject_WindowsUpdateCustomizer.ps1 @@ -0,0 +1,75 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateCustomizer. +.Description +Create an in-memory object for ImageTemplateCustomizer. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateWindowsUpdateCustomizer +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatecustomizerobject +#> +function New-AzImageBuilderTemplateCustomizerObject_WindowsUpdateCustomizer { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateWindowsUpdateCustomizer')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(HelpMessage="Array of filters to select updates to apply. Omit or specify empty array to use the default (no filter). Refer to above link for examples and detailed description of this field.")] + [string[]] + $Filter, + [Parameter(HelpMessage="Criteria to search updates. Omit or specify empty string to use the default (search all). Refer to above link for examples and detailed description of this field.")] + [string] + $SearchCriterion, + [Parameter(HelpMessage="Maximum number of updates to apply at a time. Omit or specify 0 to use the default (1000).")] + [int] + $UpdateLimit, + [Parameter(HelpMessage="Friendly Name to provide context on what this customization step does.")] + [string] + $Name, + # Change it to switch parameter + # [Parameter(Mandatory, HelpMessage="The type of customization tool you want to use on the Image. For example, `"Shell`" can be shell customizer.")] + # [string] + # $Type + [Parameter(Mandatory, HelpMessage="Installs Windows Updates. Corresponds to Packer Windows Update Provisioner (https://github.com/rgl/packer-provisioner-windows-update)")] + [Switch] + $WindowsUpdateCustomizer + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateWindowsUpdateCustomizer]::New() + + if ($PSBoundParameters.ContainsKey('Filter')) { + $Object.Filter = $Filter + } + if ($PSBoundParameters.ContainsKey('SearchCriterion')) { + $Object.SearchCriterion = $SearchCriterion + } + if ($PSBoundParameters.ContainsKey('UpdateLimit')) { + $Object.UpdateLimit = $UpdateLimit + } + if ($PSBoundParameters.ContainsKey('Name')) { + $Object.Name = $Name + } + if ($WindowsUpdateCustomizer.IsPresent) { + $Object.Type = "WindowsUpdate" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateDistributorObject/New-AzImageBuilderTemplateDistributorObject_ManagedImageDistributor.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateDistributorObject/New-AzImageBuilderTemplateDistributorObject_ManagedImageDistributor.ps1 new file mode 100644 index 000000000000..e1ca8021bd9e --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateDistributorObject/New-AzImageBuilderTemplateDistributorObject_ManagedImageDistributor.ps1 @@ -0,0 +1,75 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateDistributor. +.Description +Create an in-memory object for ImageTemplateDistributor. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateManagedImageDistributor +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatedistributorobject +#> +function New-AzImageBuilderTemplateDistributorObject_ManagedImageDistributor { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateManagedImageDistributor')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(Mandatory, HelpMessage="Resource Id of the Managed Disk Image.")] + [string] + $ImageId, + [Parameter(Mandatory, HelpMessage="Azure location for the image, should match if image already exists.")] + [string] + $Location, + [Parameter(HelpMessage="Tags that will be applied to the artifact once it has been created/updated by the distributor.")] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplateDistributorArtifactTags] + $ArtifactTag, + [Parameter(Mandatory, HelpMessage="The name to be used for the associated RunOutput.")] + [string] + $RunOutputName, + # Change it to switch parameter + # [Parameter(Mandatory, HelpMessage="Type of distribution.")] + # [string] + # $Type + [Parameter(Mandatory, HelpMessage="Distribute as a Managed Disk Image.")] + [Switch] + $ManagedImageDistributor + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateManagedImageDistributor]::New() + + if ($PSBoundParameters.ContainsKey('ImageId')) { + $Object.ImageId = $ImageId + } + if ($PSBoundParameters.ContainsKey('Location')) { + $Object.Location = $Location + } + if ($PSBoundParameters.ContainsKey('ArtifactTag')) { + $Object.ArtifactTag = $ArtifactTag + } + if ($PSBoundParameters.ContainsKey('RunOutputName')) { + $Object.RunOutputName = $RunOutputName + } + if ($ManagedImageDistributor.IsPresent) { + $Object.Type = "ManagedImage" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateDistributorObject/New-AzImageBuilderTemplateDistributorObject_SharedImageDistributor.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateDistributorObject/New-AzImageBuilderTemplateDistributorObject_SharedImageDistributor.ps1 new file mode 100644 index 000000000000..7c2633a7d9dc --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateDistributorObject/New-AzImageBuilderTemplateDistributorObject_SharedImageDistributor.ps1 @@ -0,0 +1,88 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateDistributor. +.Description +Create an in-memory object for ImageTemplateDistributor. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateSharedImageDistributor +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatedistributorobject +#> +function New-AzImageBuilderTemplateDistributorObject_SharedImageDistributor { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateSharedImageDistributor')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(HelpMessage="Flag that indicates whether created image version should be excluded from latest. Omit to use the default (false).")] + [bool] + $ExcludeFromLatest, + [Parameter(Mandatory, HelpMessage="Resource Id of the Shared Image Gallery image.")] + [string] + $GalleryImageId, + [Parameter(Mandatory, HelpMessage="A list of regions that the image will be replicated to.")] + [string[]] + $ReplicationRegion, + [Parameter(HelpMessage="Storage account type to be used to store the shared image. Omit to use the default (Standard_LRS).")] + [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.SharedImageStorageAccountType])] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.SharedImageStorageAccountType] + $StorageAccountType, + [Parameter(HelpMessage="Tags that will be applied to the artifact once it has been created/updated by the distributor.")] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplateDistributorArtifactTags] + $ArtifactTag, + [Parameter(Mandatory, HelpMessage="The name to be used for the associated RunOutput.")] + [string] + $RunOutputName, + # Change it to switch parameter + # [Parameter(Mandatory, HelpMessage="Type of distribution.")] + # [string] + # $Type + [Parameter(Mandatory, HelpMessage="Distribute via Shared Image Gallery.")] + [Switch] + $SharedImageDistributor + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateSharedImageDistributor]::New() + + if ($PSBoundParameters.ContainsKey('ExcludeFromLatest')) { + $Object.ExcludeFromLatest = $ExcludeFromLatest + } + if ($PSBoundParameters.ContainsKey('GalleryImageId')) { + $Object.GalleryImageId = $GalleryImageId + } + if ($PSBoundParameters.ContainsKey('ReplicationRegion')) { + $Object.ReplicationRegion = $ReplicationRegion + } + if ($PSBoundParameters.ContainsKey('StorageAccountType')) { + $Object.StorageAccountType = $StorageAccountType + } + if ($PSBoundParameters.ContainsKey('ArtifactTag')) { + $Object.ArtifactTag = $ArtifactTag + } + if ($PSBoundParameters.ContainsKey('RunOutputName')) { + $Object.RunOutputName = $RunOutputName + } + if ($SharedImageDistributor.IsPresent) { + $Object.Type = "SharedImage" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateDistributorObject/New-AzImageBuilderTemplateDistributorObject_VhdDistributor.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateDistributorObject/New-AzImageBuilderTemplateDistributorObject_VhdDistributor.ps1 new file mode 100644 index 000000000000..ee3507b57b70 --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateDistributorObject/New-AzImageBuilderTemplateDistributorObject_VhdDistributor.ps1 @@ -0,0 +1,63 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateDistributor. +.Description +Create an in-memory object for ImageTemplateDistributor. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateVhdDistributor +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatedistributorobject +#> +function New-AzImageBuilderTemplateDistributorObject_VhdDistributor { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateVhdDistributor')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(HelpMessage="Tags that will be applied to the artifact once it has been created/updated by the distributor.")] + [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplateDistributorArtifactTags] + $ArtifactTag, + [Parameter(Mandatory, HelpMessage="The name to be used for the associated RunOutput.")] + [string] + $RunOutputName, + # Change it to switch parameter + # [Parameter(Mandatory, HelpMessage="Type of distribution.")] + # [string] + # $Type + [Parameter(Mandatory, HelpMessage="Distribute via VHD in a storage account.")] + [Switch] + $VhdDistributor + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateVhdDistributor]::New() + + if ($PSBoundParameters.ContainsKey('ArtifactTag')) { + $Object.ArtifactTag = $ArtifactTag + } + if ($PSBoundParameters.ContainsKey('RunOutputName')) { + $Object.RunOutputName = $RunOutputName + } + if ($VhdDistributor.IsPresent) { + $Object.Type = "VHD" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateSourceObject/New-AzImageBuilderTemplateSourceObject_ManagedImageSource.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateSourceObject/New-AzImageBuilderTemplateSourceObject_ManagedImageSource.ps1 new file mode 100644 index 000000000000..c2a358a636e2 --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateSourceObject/New-AzImageBuilderTemplateSourceObject_ManagedImageSource.ps1 @@ -0,0 +1,57 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateSource. +.Description +Create an in-memory object for ImageTemplateSource. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateManagedImageSource +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatesourceobject +#> +function New-AzImageBuilderTemplateSourceObject_ManagedImageSource { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateManagedImageSource')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(Mandatory, HelpMessage="ARM resource id of the managed image in customer subscription.")] + [string] + $ImageId, + # Change it to switch parameter + # [Parameter(Mandatory, HelpMessage="Specifies the type of source image you want to start with.")] + # [string] + # $Type + [Parameter(Mandatory, HelpMessage="Describes an image source that is a managed image in customer subscription. This image must reside in the same subscription and region as the Image Builder template.")] + [Switch] + $ManagedImageSource + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateManagedImageSource]::New() + + if ($PSBoundParameters.ContainsKey('ImageId')) { + $Object.ImageId = $ImageId + } + if ($ManagedImageSource.IsPresent) { + $Object.Type = "ManagedImage" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateSourceObject/New-AzImageBuilderTemplateSourceObject_PlatformImageSource.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateSourceObject/New-AzImageBuilderTemplateSourceObject_PlatformImageSource.ps1 new file mode 100644 index 000000000000..066a8890194c --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateSourceObject/New-AzImageBuilderTemplateSourceObject_PlatformImageSource.ps1 @@ -0,0 +1,93 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateSource. +.Description +Create an in-memory object for ImageTemplateSource. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplatePlatformImageSource +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatesourceobject +#> +function New-AzImageBuilderTemplateSourceObject_PlatformImageSource { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplatePlatformImageSource')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(HelpMessage="Image offer from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).")] + [string] + $Offer, + [Parameter(HelpMessage="Name of the purchase plan.")] + [string] + $PlanInfoPlanName, + [Parameter(HelpMessage="Product of the purchase plan.")] + [string] + $PlanInfoPlanProduct, + [Parameter(HelpMessage="Publisher of the purchase plan.")] + [string] + $PlanInfoPlanPublisher, + [Parameter(HelpMessage="Image Publisher in [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).")] + [string] + $Publisher, + [Parameter(HelpMessage="Image sku from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).")] + [string] + $Sku, + [Parameter(HelpMessage="Image version from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). If 'latest' is specified here, the version is evaluated when the image build takes place, not when the template is submitted.")] + [string] + $Version, + # Change it to switch parameter + # [Parameter(Mandatory, HelpMessage="Specifies the type of source image you want to start with.")] + # [string] + # $Type + [Parameter(Mandatory, HelpMessage="Describes an image source from [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages).")] + [Switch] + $PlatformImageSource + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplatePlatformImageSource]::New() + + if ($PSBoundParameters.ContainsKey('Offer')) { + $Object.Offer = $Offer + } + if ($PSBoundParameters.ContainsKey('PlanInfoPlanName')) { + $Object.PlanInfoPlanName = $PlanInfoPlanName + } + if ($PSBoundParameters.ContainsKey('PlanInfoPlanProduct')) { + $Object.PlanInfoPlanProduct = $PlanInfoPlanProduct + } + if ($PSBoundParameters.ContainsKey('PlanInfoPlanPublisher')) { + $Object.PlanInfoPlanPublisher = $PlanInfoPlanPublisher + } + if ($PSBoundParameters.ContainsKey('Publisher')) { + $Object.Publisher = $Publisher + } + if ($PSBoundParameters.ContainsKey('Sku')) { + $Object.Sku = $Sku + } + if ($PSBoundParameters.ContainsKey('Version')) { + $Object.Version = $Version + } + if ($PlatformImageSource.IsPresent) { + $Object.Type = "PlatformImage" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateSourceObject/New-AzImageBuilderTemplateSourceObject_SharedImageVersionSource.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateSourceObject/New-AzImageBuilderTemplateSourceObject_SharedImageVersionSource.ps1 new file mode 100644 index 000000000000..df2129d83ae3 --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateSourceObject/New-AzImageBuilderTemplateSourceObject_SharedImageVersionSource.ps1 @@ -0,0 +1,57 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateSource. +.Description +Create an in-memory object for ImageTemplateSource. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateSharedImageVersionSource +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatesourceobject +#> +function New-AzImageBuilderTemplateSourceObject_SharedImageVersionSource { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateSharedImageVersionSource')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(Mandatory, HelpMessage="ARM resource id of the image version in the shared image gallery.")] + [string] + $ImageVersionId, + # [Parameter(Mandatory, HelpMessage="Specifies the type of source image you want to start with.")] + # [string] + # $Type + # Change it to switch parameter + [Parameter(Mandatory, HelpMessage="Describes an image source that is an image version in a shared image gallery.")] + [Switch] + $SharedImageVersionSource + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateSharedImageVersionSource]::New() + + if ($PSBoundParameters.ContainsKey('ImageVersionId')) { + $Object.ImageVersionId = $ImageVersionId + } + if ($SharedImageVersionSource.IsPresent) { + $Object.Type = "SharedImageVersion" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateValidatorObject/New-AzImageBuilderTemplateValidatorObject_PowerShellValidator.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateValidatorObject/New-AzImageBuilderTemplateValidatorObject_PowerShellValidator.ps1 new file mode 100644 index 000000000000..ddfd43203c33 --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateValidatorObject/New-AzImageBuilderTemplateValidatorObject_PowerShellValidator.ps1 @@ -0,0 +1,93 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateValidator. +.Description +Create an in-memory object for ImageTemplateValidator. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplatePowerShellValidator +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatevalidatorobject +#> +function New-AzImageBuilderTemplateValidatorObject_PowerShellValidator { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplatePowerShellValidator')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(HelpMessage="Array of PowerShell commands to execute.")] + [string[]] + $Inline, + [Parameter(HelpMessage="If specified, the PowerShell script will be run with elevated privileges using the Local System user. Can only be true when the runElevated field above is set to true.")] + [bool] + $RunAsSystem, + [Parameter(HelpMessage="If specified, the PowerShell script will be run with elevated privileges.")] + [bool] + $RunElevated, + [Parameter(HelpMessage="URI of the PowerShell script to be run for validation. It can be a github link, Azure Storage URI, etc.")] + [string] + $ScriptUri, + [Parameter(HelpMessage="SHA256 checksum of the power shell script provided in the scriptUri field above.")] + [string] + $Sha256Checksum, + [Parameter(HelpMessage="Valid exit codes for the PowerShell script. [Default: 0].")] + [int[]] + $ValidExitCode, + [Parameter(HelpMessage="Friendly Name to provide context on what this validation step does.")] + [string] + $Name, + # Change it to switch parameter + # [Parameter(Mandatory, HelpMessage="The type of validation you want to use on the Image. For example, `"Shell`" can be shell validation.")] + # [string] + # $Type + [Parameter(Mandatory, HelpMessage="Runs the specified PowerShell script during the validation phase (Windows). Corresponds to Packer powershell provisioner. Exactly one of 'scriptUri' or 'inline' can be specified.")] + [Switch] + $PowerShellValidator + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplatePowerShellValidator]::New() + + if ($PSBoundParameters.ContainsKey('Inline')) { + $Object.Inline = $Inline + } + if ($PSBoundParameters.ContainsKey('RunAsSystem')) { + $Object.RunAsSystem = $RunAsSystem + } + if ($PSBoundParameters.ContainsKey('RunElevated')) { + $Object.RunElevated = $RunElevated + } + if ($PSBoundParameters.ContainsKey('ScriptUri')) { + $Object.ScriptUri = $ScriptUri + } + if ($PSBoundParameters.ContainsKey('Sha256Checksum')) { + $Object.Sha256Checksum = $Sha256Checksum + } + if ($PSBoundParameters.ContainsKey('ValidExitCode')) { + $Object.ValidExitCode = $ValidExitCode + } + if ($PSBoundParameters.ContainsKey('Name')) { + $Object.Name = $Name + } + if ($PowerShellValidator.IsPresent) { + $Object.Type = "PowerShell" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImageBuilderTemplateValidatorObject/New-AzImageBuilderTemplateValidatorObject_ShellValidator.ps1 b/src/ImageBuilder/custom/New-AzImageBuilderTemplateValidatorObject/New-AzImageBuilderTemplateValidatorObject_ShellValidator.ps1 new file mode 100644 index 000000000000..41b3245115e9 --- /dev/null +++ b/src/ImageBuilder/custom/New-AzImageBuilderTemplateValidatorObject/New-AzImageBuilderTemplateValidatorObject_ShellValidator.ps1 @@ -0,0 +1,75 @@ + +# ---------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. +# ---------------------------------------------------------------------------------- + +<# +.Synopsis +Create an in-memory object for ImageTemplateValidator. +.Description +Create an in-memory object for ImageTemplateValidator. + +.Outputs +Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateShellValidator +.Link +https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatevalidatorobject +#> +function New-AzImageBuilderTemplateValidatorObject_ShellValidator { + [OutputType('Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateShellValidator')] + [CmdletBinding(PositionalBinding=$false)] + Param( + + [Parameter(HelpMessage="Array of shell commands to execute.")] + [string[]] + $Inline, + [Parameter(HelpMessage="URI of the shell script to be run for validation. It can be a github link, Azure Storage URI, etc.")] + [string] + $ScriptUri, + [Parameter(HelpMessage="SHA256 checksum of the shell script provided in the scriptUri field.")] + [string] + $Sha256Checksum, + [Parameter(HelpMessage="Friendly Name to provide context on what this validation step does.")] + [string] + $Name, + # Change it to switch parameter + # [Parameter(Mandatory, HelpMessage="The type of validation you want to use on the Image. For example, `"Shell`" can be shell validation.")] + # [string] + # $Type + [Parameter(Mandatory, HelpMessage="Runs the specified shell script during the validation phase (Linux). Corresponds to Packer shell provisioner. Exactly one of 'scriptUri' or 'inline' can be specified.")] + [Switch] + $ShellValidator + ) + + process { + $Object = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateShellValidator]::New() + + if ($PSBoundParameters.ContainsKey('Inline')) { + $Object.Inline = $Inline + } + if ($PSBoundParameters.ContainsKey('ScriptUri')) { + $Object.ScriptUri = $ScriptUri + } + if ($PSBoundParameters.ContainsKey('Sha256Checksum')) { + $Object.Sha256Checksum = $Sha256Checksum + } + if ($PSBoundParameters.ContainsKey('Name')) { + $Object.Name = $Name + } + if ($ShellValidator.IsPresent) { + $Object.Type = "Shell" + } + return $Object + } +} + diff --git a/src/ImageBuilder/custom/New-AzImagerBuilderTemplate.ps1 b/src/ImageBuilder/custom/New-AzImagerBuilderTemplate.ps1 deleted file mode 100644 index e964295fc16d..000000000000 --- a/src/ImageBuilder/custom/New-AzImagerBuilderTemplate.ps1 +++ /dev/null @@ -1,403 +0,0 @@ - -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.Synopsis -Create a virtual machine image template -.Description -Create a virtual machine image template - -.Link -https://docs.microsoft.com/powershell/module/az.imagebuilder/New-AzImageBuilderTemplate -#> -function New-AzImageBuilderTemplate { - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplate])] - [CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium', DefaultParameterSetName="FlattenParameterSet")] - param( - [Parameter(Mandatory, HelpMessage="The name of the image Template.")] - [Alias('Name')] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Path')] - [System.String] - # The name of the image Template - ${ImageTemplateName}, - - [Parameter(Mandatory, HelpMessage="The name of the resource group.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Path')] - [System.String] - # The name of the resource group. - ${ResourceGroupName}, - - [Parameter(HelpMessage="Subscription credentials which uniquely identify Microsoft Azure subscription.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Path')] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] - [System.String] - # Subscription credentials which uniquely identify Microsoft Azure subscription. - # The subscription Id forms part of the URI for every service call. - ${SubscriptionId}, - - [Parameter(ParameterSetName='JsonTemplate', HelpMessage="Path of json formated image template file.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [System.String] - ${JsonTemplatePath}, - - [Parameter(ParameterSetName='FlattenParameterSet', HelpMessage="Resource location.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [System.String] - # Resource location - ${Location}, - - [Parameter(ParameterSetName='FlattenParameterSet', HelpMessage="Maximum duration to wait while building the image template. Omit or specify 0 to use the default (4 hours).")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [System.Int32] - # Maximum duration to wait while building the image template. - # Omit or specify 0 to use the default (4 hours). - ${BuildTimeoutInMinute}, - - [Parameter(ParameterSetName='FlattenParameterSet', HelpMessage="Specifies the properties used to describe the customization steps of the image, like Image source etc.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateCustomizer[]] - # Specifies the properties used to describe the customization steps of the image, like Image source etc - # To construct, see NOTES section for CUSTOMIZE properties and create a hash table. - ${Customize}, - - [Parameter(Mandatory, ParameterSetName='FlattenParameterSet', HelpMessage="The distribution targets where the image output needs to go to.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateDistributor[]] - # The distribution targets where the image output needs to go to. - # To construct, see NOTES section for DISTRIBUTE properties and create a hash table. - ${Distribute}, - - [Parameter(Mandatory, ParameterSetName='FlattenParameterSet', HelpMessage="Describes a virtual machine image source for building, customizing and distributing.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateSource] - ${Source}, - - [Parameter(Mandatory, ParameterSetName='FlattenParameterSet', HelpMessage="The id of user assigned identity.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateIdentityUserAssignedIdentities]))] - [System.String] - # The id of user assigned identity. - # The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - ${UserAssignedIdentityId}, - - [Parameter(ParameterSetName='FlattenParameterSet', HelpMessage="Resource tags.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IResourceTags]))] - [System.Collections.Hashtable] - # Resource tags - ${Tag}, - - [Parameter(ParameterSetName='FlattenParameterSet', HelpMessage="Size of the OS disk in GB. Omit or specify 0 to use Azure's default OS disk size.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [System.Int32] - # Size of the OS disk in GB. - # Omit or specify 0 to use Azure's default OS disk size. - ${VMProfileOsdiskSizeInGb}, - - [Parameter(ParameterSetName='FlattenParameterSet', HelpMessage="Size of the virtual machine used to build, customize and capture images. Omit or specify empty string to use the default (Standard_D1_v2).")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [System.String] - # Size of the virtual machine used to build, customize and capture images. - # Omit or specify empty string to use the default (Standard_D1_v2). - ${VMProfileVmSize}, - - [Parameter(ParameterSetName='FlattenParameterSet', HelpMessage="Resource id of a pre-existing subnet.")] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] - [System.String] - # Resource id of a pre-existing subnet. - ${VnetConfigSubnetId}, - - #region HideParameter - [Parameter()] - [Alias('AzureRMContext', 'AzureCredential')] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Azure')] - [System.Management.Automation.PSObject] - # The credentials, account, tenant, and subscription used for communication with Azure. - ${DefaultProfile}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Run the command as a job - ${AsJob}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Wait for .NET debugger to attach - ${Break}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be appended to the front of the pipeline - ${HttpPipelineAppend}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.SendAsyncStep[]] - # SendAsync Pipeline Steps to be prepended to the front of the pipeline - ${HttpPipelinePrepend}, - - [Parameter()] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Run the command asynchronously - ${NoWait}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] - [System.Uri] - # The URI for the proxy server to use - ${Proxy}, - - [Parameter(DontShow)] - [ValidateNotNull()] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] - [System.Management.Automation.PSCredential] - # Credentials for a proxy server to use for the remote call - ${ProxyCredential}, - - [Parameter(DontShow)] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] - [System.Management.Automation.SwitchParameter] - # Use the default credentials for the proxy - ${ProxyUseDefaultCredentials} - #endregion HideParameter - ) - - process { - try { - $Parameter = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplate]::New() - - if ($PSBoundParameters.ContainsKey('JsonTemplatePath')) - { - if (-not (Test-Path $JsonTemplatePath)) - { - Write-Error "Cannot find file $JsonTemplatePath. Please make sure it exists!" - exit 1 - } - $TemplateContent = Get-Content $JsonTemplatePath | ConvertFrom-Json - $Parameter.Location = $TemplateContent.Location - $Parameter.BuildTimeoutInMinute = $TemplateContent.properties.buildTimeoutInMinutes - $Parameter.Source = New-SourceObjectFromJson $TemplateContent.properties.source - $Parameter.Customize = New-CustomizeArrayFromJson $TemplateContent.properties.customize - $Parameter.Distribute = New-DistributeArrayFromJson $TemplateContent.properties.distribute - $Parameter.Identity = New-IdentityObjectFromJson $TemplateContent.identity - $Parameter.VMProfile = New-VMProfileObjectFromJson $TemplateContent.properties.vmProfile - $Null = $PSBoundParameters.Remove('JsonTemplatePath') - $Tag = @{} - foreach ($property in $TemplateContent.tags.PSObject.Properties) { - $Tag[$property.Name] = $property.Value - } - $Parameter.Tag = $Tag - } - else - { - $Parameter.Source = $Source - $Null = $PSBoundParameters.Remove('Source') - - if ($PSBoundParameters.ContainsKey('Location')) { - $Parameter.Location = $Location - $Null = $PSBoundParameters.Remove('Location') - } - if ($PSBoundParameters.ContainsKey('Tag')) { - $Parameter.Tag = $Tag - $Null = $PSBoundParameters.Remove('Tag') - } - if ($PSBoundParameters.ContainsKey('BuildTimeoutInMinute')) { - $Parameter.BuildTimeoutInMinute = $BuildTimeoutInMinute - $Null = $PSBoundParameters.Remove('BuildTimeoutInMinute') - } - if ($PSBoundParameters.ContainsKey('Customize')) { - $Parameter.Customize = $Customize - $Null = $PSBoundParameters.Remove('Customize') - } - if ($PSBoundParameters.ContainsKey('Distribute')) { - $Parameter.Distribute = $Distribute - $Null = $PSBoundParameters.Remove('Distribute') - } - $Parameter.IdentityType = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.ResourceIdentityType]::UserAssigned - $UserAssignedIdentities = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateIdentityUserAssignedIdentities]::new() - $UserassignedidentitiesAdditionalproperties = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ComponentsVrq145SchemasImagetemplateidentityPropertiesUserassignedidentitiesAdditionalproperties](@{}) - $UserAssignedIdentities.Add($UserAssignedIdentityId, $UserassignedidentitiesAdditionalproperties) - $Parameter.IdentityUserAssignedIdentity = $UserAssignedIdentities - $Null = $PSBoundParameters.Remove('UserAssignedIdentityId') - - if ($PSBoundParameters.ContainsKey('VMProfileOsdiskSizeInGb')) { - $Parameter.VMProfileOsdiskSizeGb = $VMProfileOsdiskSizeInGb - $null = $PSBoundParameters.Remove('VMProfileOsdiskSizeInGb') - } - if ($PSBoundParameters.ContainsKey('VMProfileVmSize')) { - $Parameter.VMProfileVmsize = $VMProfileVmSize - $Null = $PSBoundParameters.Remove('VMProfileVmSize') - } - if ($PSBoundParameters.ContainsKey('VnetConfigSubnetId')) { - $Parameter.VnetConfigSubnetId = $VnetConfigSubnetId - $Null = $PSBoundParameters.Remove('VnetConfigSubnetId') - } - } - - $PSBoundParameters.Add("Parameter", $Parameter) - Az.ImageBuilder.internal\New-AzImageBuilderTemplate @PSBoundParameters - } catch { - throw - } - } -} - -function New-SourceObjectFromJson -{ - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateSource])] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.DoNotExportAttribute()] - param( - [Parameter()] - [object] - ${Source} - ) - if ($Source.type -eq 'PlatformImage') - { - return [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplatePlatformImageSource]::DeserializeFromPSObject($Source) - } - elseif ($Source.type -eq 'ManagedImage') - { - return [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateManagedImageSource]::DeserializeFromPSObject($Source) - } - elseif ($Source.type -eq 'SharedImageVersion') - { - return [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateSharedImageVersionSource]::DeserializeFromPSObject($Source) - } - $ErrorMessage = "Unkown type: " + $Source.type + " for source!" - Write-Error $ErrorMessage -} - -function New-CustomizeArrayFromJson -{ - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateCustomizer[]])] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.DoNotExportAttribute()] - param( - [Parameter()] - [object] - ${Customize} - ) - $result = @() - - foreach ($item in $Customize) - { - if ($item.type -eq 'PowerShell') - { - $result += [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplatePowerShellCustomizer]::DeserializeFromPSObject($item) - } - elseif ($item.type -eq 'WindowsRestart') - { - $result += [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateRestartCustomizer]::DeserializeFromPSObject($item) - } - elseif ($item.type -eq 'WindowsUpdate') - { - $result += [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateWindowsUpdateCustomizer]::DeserializeFromPSObject($item) - } - elseif ($item.type -eq 'Shell') - { - $result += [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateShellCustomizer]::DeserializeFromPSObject($item) - } - elseif ($item.type -eq 'File') - { - $result += [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateFileCustomizer]::DeserializeFromPSObject($item) - } - else - { - $ErrorMessage = "Unkown type: " + $item.type + " for customizer!" - Write-Error $ErrorMessage - } - } - - return $result -} - -function New-DistributeArrayFromJson -{ - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateDistributor[]])] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.DoNotExportAttribute()] - param( - [Parameter()] - [object] - ${DistributerList} - ) - $result = @() - - foreach ($Distributer in $DistributerList) - { - if ($Distributer.type -eq 'VHD') - { - $item = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateVhdDistributor]::DeserializeFromPSObject($Distributer) - } - elseif ($Distributer.type -eq 'ManagedImage') - { - $item = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateManagedImageDistributor]::DeserializeFromPSObject($Distributer) - } - elseif ($Distributer.type -eq 'SharedImage') - { - $item = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateSharedImageDistributor]::DeserializeFromPSObject($Distributer) - } - else - { - $ErrorMessage = "Unkown type: " + $item.type + " for distributer!" - Write-Error $ErrorMessage - } - $item.ArtifactTag = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateDistributorArtifactTags]::new() - $item.ArtifactTag.CopyFrom($Distributer.artifactTags) - $result += $item - } - - return $result -} - -function New-IdentityObjectFromJson -{ - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateIdentity])] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.DoNotExportAttribute()] - param( - [Parameter()] - [object] - ${Identity} - ) - $Result = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateIdentity]::DeserializeFromPSObject($Identity) - - foreach ($property in $Identity.userAssignedIdentities.PSObject.Properties) { - $obj = @{ - ClientId = $property.Value.ClientId; - PrincipalId = $property.Value.PrincipalId - } - $Result.UserAssignedIdentity.Add($property.Name, $obj) - } - return $Result -} - -function New-VMProfileObjectFromJson -{ - [OutputType([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateVMProfile])] - [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.DoNotExportAttribute()] - param( - [Parameter()] - [object] - ${VMProfile} - ) - $Result = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplateVMProfile]::DeserializeFromPSObject($VMProfile) - - return $Result -} \ No newline at end of file diff --git a/src/ImageBuilder/custom/README.md b/src/ImageBuilder/custom/README.md index 96e0d02a8511..8f5520867bcf 100644 --- a/src/ImageBuilder/custom/README.md +++ b/src/ImageBuilder/custom/README.md @@ -12,7 +12,7 @@ For `Az.ImageBuilder` to use custom cmdlets, it does this two different ways. We For C# cmdlets, they are compiled with the rest of the generated low-level cmdlets into the `./bin/Az.ImageBuilder.private.dll`. The names of the cmdlets (methods) and files must follow the `[cmdletName]_[variantName]` syntax used for generated cmdlets. The `variantName` is used as the `ParameterSetName`, so use something appropriate that doesn't clash with already created variant or parameter set names. You cannot use the `ParameterSetName` property in the `Parameter` attribute on C# cmdlets. Each cmdlet must be separated into variants using the same pattern as seen in the `generated/cmdlets` folder. -For script cmdlets, these are loaded via the `Az.ImageBuilder.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundemental difference is the script cmdlets use the `ParameterSetName` attribute and C# cmdlets do not. To create a script cmdlet variant of a generated cmdlet, simply decorate all parameters in the script with the new `ParameterSetName` in the `Parameter` attribute. This will appropriately treat each parameter set as a separate variant when processed to be exported during the build. +For script cmdlets, these are loaded via the `Az.ImageBuilder.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundamental difference is the script cmdlets use the `ParameterSetName` attribute and C# cmdlets do not. To create a script cmdlet variant of a generated cmdlet, simply decorate all parameters in the script with the new `ParameterSetName` in the `Parameter` attribute. This will appropriately treat each parameter set as a separate variant when processed to be exported during the build. ## Purpose This allows the modules to have cmdlets that were not defined in the REST specification. It also allows combining logic using generated cmdlets. This is a level of customization beyond what can be done using the [readme configuration options](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md) that are currently available. These custom cmdlets are then referenced by the cmdlets created at build-time in the `..\exports` folder. @@ -31,11 +31,11 @@ These provide functionality to our HTTP pipeline and other useful features. In s ### Attributes For processing the cmdlets, we've created some additional attributes: -- `Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.DescriptionAttribute` - - Used in C# cmdlets to provide a high-level description of the cmdlet. This is propegated to reference documentation via [help comments](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts. -- `Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.DoNotExportAttribute` +- `Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.DescriptionAttribute` + - Used in C# cmdlets to provide a high-level description of the cmdlet. This is propagated to reference documentation via [help comments](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts. +- `Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.DoNotExportAttribute` - Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Az.ImageBuilder`. -- `Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.InternalExportAttribute` - - Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.ImageBuilder`. For more information, see [readme.md](..\internal/readme.md) in the `..\internal` folder. -- `Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.ProfileAttribute` +- `Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.InternalExportAttribute` + - Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.ImageBuilder`. For more information, see [README.md](..\internal/README.md) in the `..\internal` folder. +- `Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.ProfileAttribute` - Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules. \ No newline at end of file diff --git a/src/ImageBuilder/custom/Update-AzImageBuilderTemplate.ps1 b/src/ImageBuilder/custom/Update-AzImageBuilderTemplate.ps1 deleted file mode 100644 index 9532b0697834..000000000000 --- a/src/ImageBuilder/custom/Update-AzImageBuilderTemplate.ps1 +++ /dev/null @@ -1,331 +0,0 @@ - -# # ---------------------------------------------------------------------------------- -# # -# # Copyright Microsoft Corporation -# # Licensed under the Apache License, Version 2.0 (the "License"); -# # you may not use this file except in compliance with the License. -# # You may obtain a copy of the License at -# # http://www.apache.org/licenses/LICENSE-2.0 -# # Unless required by applicable law or agreed to in writing, software -# # distributed under the License is distributed on an "AS IS" BASIS, -# # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# # See the License for the specific language governing permissions and -# # limitations under the License. -# # ---------------------------------------------------------------------------------- - -# <# -# .Synopsis -# Update a virtual machine image template -# .Description -# Update a virtual machine image template - -# .Link -# https://docs.microsoft.com/powershell/module/az.imagebuilder/update-AzImageBuilderTemplate -# #> -# function Update-AzImageBuilderTemplate { -# [OutputType([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplate])] -# [CmdletBinding(DefaultParameterSetName='Name', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] -# param( -# [Parameter(ParameterSetName='Name', Mandatory, HelpMessage="The name of the image Template.")] -# [Alias('Name')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Path')] -# [System.String] -# # The name of the image Template -# ${ImageTemplateName}, - -# [Parameter(ParameterSetName='Name', Mandatory, HelpMessage="The name of the resource group.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Path')] -# [System.String] -# # The name of the resource group. -# ${ResourceGroupName}, - -# [Parameter(ParameterSetName='Name', HelpMessage="Subscription credentials which uniquely identify Microsoft Azure subscription.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Path')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] -# [System.String] -# # Subscription credentials which uniquely identify Microsoft Azure subscription. -# # The subscription Id forms part of the URI for every service call. -# ${SubscriptionId}, - -# [Parameter(ParameterSetName='InputObject', Mandatory, ValueFromPipeline, HelpMessage="Identity Parameter.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Path')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.IImageBuilderIdentity] -# # Identity Parameter -# # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. -# ${InputObject}, - -# [Parameter(HelpMessage="Resource location.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [System.String] -# # Resource location -# ${Location}, - -# [Parameter(HelpMessage="Maximum duration to wait while building the image template. Omit or specify 0 to use the default (4 hours).")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [System.Int32] -# # Maximum duration to wait while building the image template. -# # Omit or specify 0 to use the default (4 hours). -# ${BuildTimeoutInMinute}, - -# [Parameter(HelpMessage="Specifies the properties used to describe the customization steps of the image, like Image source etc.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateCustomizer[]] -# # Specifies the properties used to describe the customization steps of the image, like Image source etc -# # To construct, see NOTES section for CUSTOMIZE properties and create a hash table. -# ${Customize}, - -# [Parameter(HelpMessage="The distribution targets where the image output needs to go to.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateDistributor[]] -# # The distribution targets where the image output needs to go to. -# # To construct, see NOTES section for DISTRIBUTE properties and create a hash table. -# ${Distribute}, - -# [Parameter(Mandatory, HelpMessage="Describes a virtual machine image source for building, customizing and distributing.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateSource] -# ${Source}, - -# [Parameter(HelpMessage="The type of identity used for the image template.")] -# [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.ResourceIdentityType])] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.ResourceIdentityType] -# # The type of identity used for the image template. -# # The type 'None' will remove any identities from the image template. -# ${IdentityType}, - -# [Parameter(HelpMessage="The list of user identities associated with the image template.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateIdentityUserAssignedIdentities]))] -# [System.Collections.Hashtable] -# # The list of user identities associated with the image template. -# # The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. -# ${UserAssignedIdentity}, - -# [Parameter(HelpMessage="End time of the last run (UTC).")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [System.DateTime] -# # End time of the last run (UTC) -# ${LastRunStatusEndTime}, - -# [Parameter(HelpMessage="Verbose information about the last run state.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [System.String] -# # Verbose information about the last run state -# ${LastRunStatusMessage}, - -# [Parameter(HelpMessage="State of the last run.")] -# [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.RunState])] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.RunState] -# # State of the last run -# ${LastRunStatusRunState}, - -# [Parameter(HelpMessage="Sub-state of the last run.")] -# [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.RunSubState])] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.RunSubState] -# # Sub-state of the last run -# ${LastRunStatusRunSubState}, - -# [Parameter(HelpMessage="Start time of the last run (UTC).")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [System.DateTime] -# # Start time of the last run (UTC) -# ${LastRunStatusStartTime}, - -# [Parameter(HelpMessage="Error code of the provisioning failure.")] -# [ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.ProvisioningErrorCode])] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.ProvisioningErrorCode] -# # Error code of the provisioning failure -# ${ProvisioningErrorCode}, - -# [Parameter(HelpMessage="Verbose error message about the provisioning failure.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [System.String] -# # Verbose error message about the provisioning failure -# ${ProvisioningErrorMessage}, - -# [Parameter(HelpMessage="Specifies the type of source image you want to start with.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [System.String] -# # Specifies the type of source image you want to start with. -# ${SourceType}, - -# [Parameter(HelpMessage="Resource tags.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IResourceTags]))] -# [System.Collections.Hashtable] -# # Resource tags -# ${Tag}, - -# [Parameter(HelpMessage="Size of the OS disk in GB. Omit or specify 0 to use Azure's default OS disk size.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [System.Int32] -# # Size of the OS disk in GB. -# # Omit or specify 0 to use Azure's default OS disk size. -# ${VMProfileOsdiskSizeInGb}, - -# [Parameter(HelpMessage="Size of the virtual machine used to build, customize and capture images. Omit or specify empty string to use the default (Standard_D1_v2).")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [System.String] -# # Size of the virtual machine used to build, customize and capture images. -# # Omit or specify empty string to use the default (Standard_D1_v2). -# ${VMProfileVmSize}, - -# [Parameter(HelpMessage="Resource id of a pre-existing subnet.")] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Body')] -# [System.String] -# # Resource id of a pre-existing subnet. -# ${VnetConfigSubnetId}, - -# #region HideParameter -# [Parameter()] -# [Alias('AzureRMContext', 'AzureCredential')] -# [ValidateNotNull()] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Azure')] -# [System.Management.Automation.PSObject] -# # The credentials, account, tenant, and subscription used for communication with Azure. -# ${DefaultProfile}, - -# [Parameter()] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] -# [System.Management.Automation.SwitchParameter] -# # Run the command as a job -# ${AsJob}, - -# [Parameter(DontShow)] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] -# [System.Management.Automation.SwitchParameter] -# # Wait for .NET debugger to attach -# ${Break}, - -# [Parameter(DontShow)] -# [ValidateNotNull()] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.SendAsyncStep[]] -# # SendAsync Pipeline Steps to be appended to the front of the pipeline -# ${HttpPipelineAppend}, - -# [Parameter(DontShow)] -# [ValidateNotNull()] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Runtime.SendAsyncStep[]] -# # SendAsync Pipeline Steps to be prepended to the front of the pipeline -# ${HttpPipelinePrepend}, - -# [Parameter()] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] -# [System.Management.Automation.SwitchParameter] -# # Run the command asynchronously -# ${NoWait}, - -# [Parameter(DontShow)] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] -# [System.Uri] -# # The URI for the proxy server to use -# ${Proxy}, - -# [Parameter(DontShow)] -# [ValidateNotNull()] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] -# [System.Management.Automation.PSCredential] -# # Credentials for a proxy server to use for the remote call -# ${ProxyCredential}, - -# [Parameter(DontShow)] -# [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Category('Runtime')] -# [System.Management.Automation.SwitchParameter] -# # Use the default credentials for the proxy -# ${ProxyUseDefaultCredentials} -# #endregion HideParameter -# ) - -# process { -# try { -# $Parameter = [Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.ImageTemplate]::New() - -# $Parameter.Source = $Source -# $Null = $PSBoundParameters.Remove('Source') - -# if ($PSBoundParameters.ContainsKey('Location')) { -# $Parameter.Location = $Location -# $Null = $PSBoundParameters.Remove('Location') -# } -# if ($PSBoundParameters.ContainsKey('Tag')) { -# $Parameter.Tag = $Tag -# $Null = $PSBoundParameters.Remove('Tag') -# } -# if ($PSBoundParameters.ContainsKey('BuildTimeoutInMinute')) { -# $Parameter.BuildTimeoutInMinute = $BuildTimeoutInMinute -# $Null = $PSBoundParameters.Remove('BuildTimeoutInMinute') -# } -# if ($PSBoundParameters.ContainsKey('Customize')) { -# $Parameter.Customize = $Customize -# $Null = $PSBoundParameters.Remove('Customize') -# } -# if ($PSBoundParameters.ContainsKey('Distribute')) { -# $Parameter.Distribute = $Distribute -# $Null = $PSBoundParameters.Remove('Distribute') -# } -# if ($PSBoundParameters.ContainsKey('IdentityType')) { -# $Parameter.IdentityType = $IdentityType -# $Null = $PSBoundParameters.Remove('IdentityType') -# } -# if ($PSBoundParameters.ContainsKey('UserAssignedIdentity')) { -# $Parameter.IdentityUserAssignedIdentity = $UserAssignedIdentity -# $Null = $PSBoundParameters.Remove('UserAssignedIdentity') -# } -# if ($PSBoundParameters.ContainsKey('LastRunStatus')) { -# $Parameter.LastRunStatus = $LastRunStatus -# $Null = $PSBoundParameters.Remove('LastRunStatus') -# } -# if ($PSBoundParameters.ContainsKey('LastRunStatusEndTime')) { -# $Parameter.LastRunStatusEndTime = $LastRunStatusEndTime -# $Null = $PSBoundParameters.Remove('LastRunStatusEndTime') -# } -# if ($PSBoundParameters.ContainsKey('LastRunStatusMessage')) { -# $Parameter.LastRunStatusMessage = $LastRunStatusMessage -# $Null = $PSBoundParameters.Remove('LastRunStatusMessage') -# } -# if ($PSBoundParameters.ContainsKey('LastRunStatusRunState')) { -# $Parameter.LastRunStatusRunState = $LastRunStatusRunState -# $Null = $PSBoundParameters.Remove('LastRunStatusRunState') -# } -# if ($PSBoundParameters.ContainsKey('LastRunStatusRunSubState')) { -# $Parameter.LastRunStatusRunSubState = $LastRunStatusRunSubState -# $Null = $PSBoundParameters.Remove('LastRunStatusRunSubState') -# } -# if ($PSBoundParameters.ContainsKey('LastRunStatusStartTime')) { -# $Parameter.LastRunStatusStartTime = $LastRunStatusStartTime -# $Null = $PSBoundParameters.Remove('LastRunStatusStartTime') -# } -# if ($PSBoundParameters.ContainsKey('ProvisioningErrorCode')) { -# $Parameter.ProvisioningErrorCode = $ProvisioningErrorCode -# $Null = $PSBoundParameters.Remove('ProvisioningErrorCode') -# } -# if ($PSBoundParameters.ContainsKey('ProvisioningState')) { -# $Parameter.ProvisioningState = $ProvisioningState -# $Null = $PSBoundParameters.Remove('ProvisioningState') -# } -# if ($PSBoundParameters.ContainsKey('VMProfileOsdiskSizeInGb')) { -# $Parameter.VMProfileOsdiskSizeGb = $VMProfileOsdiskSizeInGb -# $null = $PSBoundParameters.Remove('VMProfileOsdiskSizeInGb') -# } -# if ($PSBoundParameters.ContainsKey('VMProfileVmSize')) { -# $Parameter.VMProfileVmsize = $VMProfileVmSize -# $Null = $PSBoundParameters.Remove('VMProfileVmSize') -# } -# if ($PSBoundParameters.ContainsKey('VnetConfigSubnetId')) { -# $Parameter.VnetConfigSubnetId = $VnetConfigSubnetId -# $Null = $PSBoundParameters.Remove('VnetConfigSubnetId') -# } -# $PSBoundParameters.Add("Parameter", $Parameter) -# Az.ImageBuilder.internal\Update-AzImageBuilderTemplate @PSBoundParameters -# } catch { -# throw -# } -# } -# } - \ No newline at end of file diff --git a/src/ImageBuilder/docs/Az.ImageBuilder.md b/src/ImageBuilder/docs/Az.ImageBuilder.md index 69d0d876ef9a..614d0ff37f98 100644 --- a/src/ImageBuilder/docs/Az.ImageBuilder.md +++ b/src/ImageBuilder/docs/Az.ImageBuilder.md @@ -1,6 +1,6 @@ --- Module Name: Az.ImageBuilder -Module Guid: 3c1721fe-5c8f-4a7f-b3fc-d8ef960fbce1 +Module Guid: bdedc683-d9b6-41ea-b310-d068b8c72305 Download Help Link: https://docs.microsoft.com/powershell/module/az.imagebuilder Help Version: 1.0.0.0 Locale: en-US @@ -11,23 +11,26 @@ Locale: en-US Microsoft Azure PowerShell: ImageBuilder cmdlets ## Az.ImageBuilder Cmdlets -### [Get-AzImageBuilderRunOutput](Get-AzImageBuilderRunOutput.md) -Get the specified run output for the specified image template resource - ### [Get-AzImageBuilderTemplate](Get-AzImageBuilderTemplate.md) Get information about a virtual machine image template -### [New-AzImageBuilderCustomizerObject](New-AzImageBuilderCustomizerObject.md) -Describes a unit of image customization +### [Get-AzImageBuilderTemplateRunOutput](Get-AzImageBuilderTemplateRunOutput.md) +Get the specified run output for the specified image template resource -### [New-AzImageBuilderDistributorObject](New-AzImageBuilderDistributorObject.md) -Generic distribution object +### [New-AzImageBuilderTemplate](New-AzImageBuilderTemplate.md) +Create or update a virtual machine image template -### [New-AzImageBuilderSourceObject](New-AzImageBuilderSourceObject.md) -Describes a virtual machine image source for building, customizing and distributing. +### [New-AzImageBuilderTemplateCustomizerObject](New-AzImageBuilderTemplateCustomizerObject.md) +Create an in-memory object for ImageTemplateCustomizer. -### [New-AzImageBuilderTemplate](New-AzImageBuilderTemplate.md) -Create a virtual machine image template +### [New-AzImageBuilderTemplateDistributorObject](New-AzImageBuilderTemplateDistributorObject.md) +Create an in-memory object for ImageTemplateDistributor. + +### [New-AzImageBuilderTemplateSourceObject](New-AzImageBuilderTemplateSourceObject.md) +Create an in-memory object for ImageTemplateSource. + +### [New-AzImageBuilderTemplateValidatorObject](New-AzImageBuilderTemplateValidatorObject.md) +Create an in-memory object for ImageTemplateValidator. ### [Remove-AzImageBuilderTemplate](Remove-AzImageBuilderTemplate.md) Delete a virtual machine image template diff --git a/src/ImageBuilder/docs/Get-AzImageBuilderTemplate.md b/src/ImageBuilder/docs/Get-AzImageBuilderTemplate.md index 6c8d047d779c..c04d0276a29c 100644 --- a/src/ImageBuilder/docs/Get-AzImageBuilderTemplate.md +++ b/src/ImageBuilder/docs/Get-AzImageBuilderTemplate.md @@ -19,8 +19,8 @@ Get-AzImageBuilderTemplate [-SubscriptionId ] [-DefaultProfile -ResourceGroupName - [-SubscriptionId ] [-DefaultProfile ] [] +Get-AzImageBuilderTemplate -Name -ResourceGroupName [-SubscriptionId ] + [-DefaultProfile ] [] ``` ### GetViaIdentity @@ -46,59 +46,41 @@ Get-AzImageBuilderTemplate ``` ```output -Location Name Type --------- ---- ---- -eastus HelloImageTemplateLinux01 Microsoft.VirtualMachineImages/imageTemplates -eastus lucas-imagetemplate Microsoft.VirtualMachineImages/imageTemplates -eastus test-imagebuilder Microsoft.VirtualMachineImages/imageTemplates +Location Name SystemDataCreatedAt SystemDataCreatedBy SystemDataCreatedByType SystemDataLastModifiedAt SystemDataLastModifiedBy SystemDataLastModifiedByType +-------- ---- ------------------- ------------------- ----------------------- ------------------------ ------------------------ ---------------------------- +eastus bez-test-img-temp +eastus bez-test-img-temp12 +eastus bez-test-img-temp13 +eastus test-img-temp ``` This command lists all template under a subscription. ### Example 2: List all template under a resource group ```powershell -Get-AzImageBuilderTemplate -ResourceGroupName wyunchi-imagebuilder +Get-AzImageBuilderTemplate -ResourceGroupName bez-rg ``` ```output -Location Name Type --------- ---- ---- -eastus HelloImageTemplateLinux01 Microsoft.VirtualMachineImages/imageTemplates -eastus template-name-ax01b7 Microsoft.VirtualMachineImages/imageTemplates -eastus template-name-ep5z7v Microsoft.VirtualMachineImages/imageTemplates -eastus template-name-klcuav Microsoft.VirtualMachineImages/imageTemplates -eastus template-name-u7gjqx Microsoft.VirtualMachineImages/imageTemplates -eastus test-imagebuilder Microsoft.VirtualMachineImages/imageTemplates -eastus tmpl-managedimg-managedimg Microsoft.VirtualMachineImages/imageTemplates -eastus tmpl-platform-managed Microsoft.VirtualMachineImages/imageTemplates -eastus tmpl-shareimg-managedimg Microsoft.VirtualMachineImages/imageTemplates +Location Name SystemDataCreatedAt SystemDataCreatedBy SystemDataCreatedByType SystemDataLastModifiedAt SystemDataLastModifiedBy SystemDataLastModifiedByType +-------- ---- ------------------- ------------------- ----------------------- ------------------------ ------------------------ ---------------------------- +eastus bez-test-img-temp +eastus bez-test-img-temp12 +eastus bez-test-img-temp13 +eastus test-img-temp ``` This command lists all template under a resource group. ### Example 3: Get a template under a resource group ```powershell -Get-AzImageBuilderTemplate -ImageTemplateName lucas-imagetemplate -ResourceGroupName wyunchi-imagebuilder -``` - -```output -Location Name Type --------- ---- ---- -eastus lucas-imagetemplate Microsoft.VirtualMachineImages/imageTemplates -``` - -This command gets a template under a resource group. - -### Example 4: Get a template under a resource group -```powershell -$template = Get-AzImageBuilderTemplate -ResourceGroupName wyunchi-imagebuilder -ImageTemplateName template-name-ep5z7v -Get-AzImageBuilderTemplate -InputObject $template +Get-AzImageBuilderTemplate -Name test-img-temp -ResourceGroupName bez-rg ``` ```output -Location Name Type --------- ---- ---- -eastus template-name-ep5z7v Microsoft.VirtualMachineImages/imageTemplates +Location Name SystemDataCreatedAt SystemDataCreatedBy SystemDataCreatedByType SystemDataLastModifiedAt SystemDataLastModifiedBy +-------- ---- ------------------- ------------------- ----------------------- ------------------------ ------------------ +eastus test-img-temp ``` This command gets a template under a resource group. @@ -120,34 +102,34 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ImageTemplateName -The name of the image Template +### -InputObject +Identity Parameter +To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ```yaml -Type: System.String -Parameter Sets: Get -Aliases: Name +Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.IImageBuilderIdentity +Parameter Sets: GetViaIdentity +Aliases: Required: True Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` -### -InputObject -Identity Parameter -To construct, see NOTES section for INPUTOBJECT properties and create a hash table. +### -Name +The name of the image Template ```yaml -Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.IImageBuilderIdentity -Parameter Sets: GetViaIdentity -Aliases: +Type: System.String +Parameter Sets: Get +Aliases: ImageTemplateName Required: True Position: Named Default value: None -Accept pipeline input: True (ByValue) +Accept pipeline input: False Accept wildcard characters: False ``` @@ -191,7 +173,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS -### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplate +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplate ## NOTES @@ -202,7 +184,7 @@ COMPLEX PARAMETER PROPERTIES To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. -INPUTOBJECT : Identity Parameter +`INPUTOBJECT `: Identity Parameter - `[Id ]`: Resource identity path - `[ImageTemplateName ]`: The name of the image Template - `[ResourceGroupName ]`: The name of the resource group. diff --git a/src/ImageBuilder/docs/Get-AzImageBuilderRunOutput.md b/src/ImageBuilder/docs/Get-AzImageBuilderTemplateRunOutput.md similarity index 72% rename from src/ImageBuilder/docs/Get-AzImageBuilderRunOutput.md rename to src/ImageBuilder/docs/Get-AzImageBuilderTemplateRunOutput.md index 79e7ecb42752..ad381e931754 100644 --- a/src/ImageBuilder/docs/Get-AzImageBuilderRunOutput.md +++ b/src/ImageBuilder/docs/Get-AzImageBuilderTemplateRunOutput.md @@ -1,11 +1,11 @@ --- external help file: Module Name: Az.ImageBuilder -online version: https://docs.microsoft.com/powershell/module/az.imagebuilder/get-azimagebuilderrunoutput +online version: https://docs.microsoft.com/powershell/module/az.imagebuilder/get-azimagebuildertemplaterunoutput schema: 2.0.0 --- -# Get-AzImageBuilderRunOutput +# Get-AzImageBuilderTemplateRunOutput ## SYNOPSIS Get the specified run output for the specified image template resource @@ -14,19 +14,19 @@ Get the specified run output for the specified image template resource ### List (Default) ``` -Get-AzImageBuilderRunOutput -ImageTemplateName -ResourceGroupName +Get-AzImageBuilderTemplateRunOutput -ImageTemplateName -ResourceGroupName [-SubscriptionId ] [-DefaultProfile ] [] ``` ### Get ``` -Get-AzImageBuilderRunOutput -ImageTemplateName -ResourceGroupName -RunOutputName +Get-AzImageBuilderTemplateRunOutput -ImageTemplateName -Name -ResourceGroupName [-SubscriptionId ] [-DefaultProfile ] [] ``` ### GetViaIdentity ``` -Get-AzImageBuilderRunOutput -InputObject [-DefaultProfile ] +Get-AzImageBuilderTemplateRunOutput -InputObject [-DefaultProfile ] [] ``` @@ -37,40 +37,26 @@ Get the specified run output for the specified image template resource ### Example 1: List all run results under a template ```powershell -Get-AzImageBuilderRunOutput -ImageTemplateName lucas-imagetemplate -ResourceGroupName wyunchi-imagebuilder +Get-AzImageBuilderTemplateRunOutput -ImageTemplateName test-img-temp -ResourceGroupName bez-rg ``` ```output -Name Type ----- ---- -image_lucas_1 Microsoft.VirtualMachineImages/imageTemplates/runOutputs +Name +---- +image_lucas_1 ``` This command lists all run results under a template. ### Example 2: Get a run result under a template ```powershell -Get-AzImageBuilderRunOutput -ImageTemplateName template-name-u7gjqx -ResourceGroupName wyunchi-imagebuilder -RunOutputName runout-template-name-u7gjqx +Get-AzImageBuilderTemplateRunOutput -ImageTemplateName test-img-temp -ResourceGroupName bez-rg -Name runout-template-name-u7gjq ``` ```output -Name Type ----- ---- -runout-template-name-u7gjqx Microsoft.VirtualMachineImages/imageTemplates/runOutputs -``` - -This command gets a run result under a template. - -### Example 3: Get a run result under a template -```powershell -$result = Get-AzImageBuilderRunOutput -ImageTemplateName template-name-u7gjqx -ResourceGroupName wyunchi-imagebuilder -RunOutputName runout-template-name-u7gjqx -Get-AzImageBuilderRunOutput -InputObject $result -``` - -```output -Name Type ----- ---- -runout-template-name-u7gjqx Microsoft.VirtualMachineImages/imageTemplates/runOutputs +Name +---- +runout-template-name-u7gjqx ``` This command gets a run result under a template. @@ -123,13 +109,13 @@ Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` -### -ResourceGroupName -The name of the resource group. +### -Name +The name of the run output ```yaml Type: System.String -Parameter Sets: Get, List -Aliases: +Parameter Sets: Get +Aliases: RunOutputName Required: True Position: Named @@ -138,12 +124,12 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -RunOutputName -The name of the run output +### -ResourceGroupName +The name of the resource group. ```yaml Type: System.String -Parameter Sets: Get +Parameter Sets: Get, List Aliases: Required: True @@ -178,7 +164,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS -### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IRunOutput +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IRunOutput ## NOTES @@ -189,7 +175,7 @@ COMPLEX PARAMETER PROPERTIES To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. -INPUTOBJECT : Identity Parameter +`INPUTOBJECT `: Identity Parameter - `[Id ]`: Resource identity path - `[ImageTemplateName ]`: The name of the image Template - `[ResourceGroupName ]`: The name of the resource group. diff --git a/src/ImageBuilder/docs/New-AzImageBuilderTemplate.md b/src/ImageBuilder/docs/New-AzImageBuilderTemplate.md index ca2aefdace40..257f9a8b6b02 100644 --- a/src/ImageBuilder/docs/New-AzImageBuilderTemplate.md +++ b/src/ImageBuilder/docs/New-AzImageBuilderTemplate.md @@ -1,59 +1,70 @@ --- external help file: Module Name: Az.ImageBuilder -online version: https://docs.microsoft.com/powershell/module/az.imagebuilder/New-AzImageBuilderTemplate +online version: https://docs.microsoft.com/powershell/module/az.imagebuilder/new-azimagebuildertemplate schema: 2.0.0 --- # New-AzImageBuilderTemplate ## SYNOPSIS -Create a virtual machine image template +Create or update a virtual machine image template ## SYNTAX -### FlattenParameterSet (Default) +### CreateExpanded (Default) ``` -New-AzImageBuilderTemplate -ImageTemplateName -ResourceGroupName - -Distribute -Source -UserAssignedIdentityId +New-AzImageBuilderTemplate -Name -ResourceGroupName -Location [-SubscriptionId ] [-BuildTimeoutInMinute ] [-Customize ] - [-Location ] [-Tag ] [-VMProfileOsdiskSizeInGb ] [-VMProfileVmSize ] + [-Distribute ] [-IdentityType ] + [-Source ] [-StagingResourceGroup ] [-Tag ] + [-UserAssignedIdentity ] [-ValidateContinueDistributeOnFailure] [-ValidateSourceValidationOnly] + [-Validator ] [-VMProfileOsdiskSizeGb ] + [-VMProfileUserAssignedIdentity ] [-VMProfileVmsize ] [-VnetConfigProxyVMSize ] [-VnetConfigSubnetId ] [-DefaultProfile ] [-AsJob] [-NoWait] [-Confirm] [-WhatIf] [] ``` -### JsonTemplate +### CreateViaJsonString ``` -New-AzImageBuilderTemplate -ImageTemplateName -ResourceGroupName [-SubscriptionId ] - [-JsonTemplatePath ] [-DefaultProfile ] [-AsJob] [-NoWait] [-Confirm] [-WhatIf] +New-AzImageBuilderTemplate -Name -ResourceGroupName -JsonString + [-SubscriptionId ] [-DefaultProfile ] [-AsJob] [-NoWait] [-Confirm] [-WhatIf] + [] +``` + +### JsonTemplatePath +``` +New-AzImageBuilderTemplate -Name -ResourceGroupName -JsonTemplatePath + [-SubscriptionId ] [-DefaultProfile ] [-AsJob] [-NoWait] [-Confirm] [-WhatIf] [] ``` ## DESCRIPTION -Create a virtual machine image template +Create or update a virtual machine image template ## EXAMPLES -### Example 1: Create a virtual machine image template +### Example 1: {{ Add title here }} ```powershell -$srcPlatform = New-AzImageBuilderSourceObject -SourceTypePlatformImage -Publisher 'Canonical' -Offer 'UbuntuServer' -Sku '18.04-LTS' -Version 'latest' -$disSharedImg = New-AzImageBuilderDistributorObject -SharedImageDistributor -ArtifactTag @{tag='dis-share'} -GalleryImageId '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/testsharedgallery/images/imagedefinition-linux/versions/1.0.0' -ReplicationRegion 'eastus2' -RunOutputName 'runoutput-01' -ExcludeFromLatest $false -$customizer = New-AzImageBuilderCustomizerObject -ShellCustomizer -CustomizerName 'CheckSumCompareShellScript' -ScriptUri 'https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh' -Sha256Checksum 'ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93' -$userAssignedIdentity = '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/wyunchi-imagebuilder/providers/Microsoft.ManagedIdentity/userAssignedIdentities/image-builder-user-assign-identity' -New-AzImageBuilderTemplate -ImageTemplateName platform-shared-img -ResourceGroupName wyunchi-imagebuilder -Source $srcPlatform -Distribute $disSharedImg -Customize $customizer -Location eastus -UserAssignedIdentityId $userAssignedIdentity +{{ Add code here }} ``` ```output -Location Name Type --------- ---- ---- -PlanInfoPlanName : -PlanInfoPlanPublisher : -Sku : 18.04-LTS -Version : latest -PlanInfo : Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.PlatformImagePurchasePlan +{{ Add output here }} ``` -This commands creates a virtual machine image template. +{{ Add description here }} + +### Example 2: {{ Add title here }} +```powershell +{{ Add code here }} +``` + +```output +{{ Add output here }} +``` + +{{ Add description here }} ## PARAMETERS @@ -73,12 +84,12 @@ Accept wildcard characters: False ``` ### -BuildTimeoutInMinute -Maximum duration to wait while building the image template. +Maximum duration to wait while building the image template (includes all customizations, validations, and distributions). Omit or specify 0 to use the default (4 hours). ```yaml Type: System.Int32 -Parameter Sets: FlattenParameterSet +Parameter Sets: CreateExpanded Aliases: Required: False @@ -89,12 +100,12 @@ Accept wildcard characters: False ``` ### -Customize -Specifies the properties used to describe the customization steps of the image, like Image source etc. +Specifies the properties used to describe the customization steps of the image, like Image source etc To construct, see NOTES section for CUSTOMIZE properties and create a hash table. ```yaml -Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateCustomizer[] -Parameter Sets: FlattenParameterSet +Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplateCustomizer[] +Parameter Sets: CreateExpanded Aliases: Required: False @@ -105,8 +116,7 @@ Accept wildcard characters: False ``` ### -DefaultProfile -region HideParameter - The credentials, account, tenant, and subscription used for communication with Azure. +The credentials, account, tenant, and subscription used for communication with Azure. ```yaml Type: System.Management.Automation.PSObject @@ -125,24 +135,40 @@ The distribution targets where the image output needs to go to. To construct, see NOTES section for DISTRIBUTE properties and create a hash table. ```yaml -Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateDistributor[] -Parameter Sets: FlattenParameterSet +Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplateDistributor[] +Parameter Sets: CreateExpanded Aliases: -Required: True +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -IdentityType +The type of identity used for the image template. +The type 'None' will remove any identities from the image template. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Support.ResourceIdentityType +Parameter Sets: CreateExpanded +Aliases: + +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -ImageTemplateName -The name of the image Template. +### -JsonString +Json string. ```yaml Type: System.String -Parameter Sets: (All) -Aliases: Name +Parameter Sets: CreateViaJsonString +Aliases: Required: True Position: Named @@ -152,14 +178,14 @@ Accept wildcard characters: False ``` ### -JsonTemplatePath -Path of json formated image template file. + ```yaml Type: System.String -Parameter Sets: JsonTemplate +Parameter Sets: JsonTemplatePath Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False @@ -167,14 +193,29 @@ Accept wildcard characters: False ``` ### -Location -Resource location. +The geo-location where the resource lives ```yaml Type: System.String -Parameter Sets: FlattenParameterSet +Parameter Sets: CreateExpanded Aliases: -Required: False +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +The name of the image Template + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: ImageTemplateName + +Required: True Position: Named Default value: None Accept pipeline input: False @@ -212,15 +253,34 @@ Accept wildcard characters: False ``` ### -Source -Describes a virtual machine image source for building, customizing and distributing. +Specifies the properties used to describe the source image. To construct, see NOTES section for SOURCE properties and create a hash table. ```yaml -Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateSource -Parameter Sets: FlattenParameterSet +Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplateSource +Parameter Sets: CreateExpanded Aliases: -Required: True +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -StagingResourceGroup +The staging resource group id in the same subscription as the image template that will be used to build the image. +If this field is empty, a resource group with a random name will be created. +If the resource group specified in this field doesn't exist, it will be created with the same name. +If the resource group specified exists, it must be empty and in the same region as the image template. +The resource group created will be deleted during template deletion if this field is empty or the resource group specified doesn't exist, but if the resource group specified exists the resources created in the resource group will be deleted during template deletion and the resource group itself will remain. + +```yaml +Type: System.String +Parameter Sets: CreateExpanded +Aliases: + +Required: False Position: Named Default value: None Accept pipeline input: False @@ -229,6 +289,7 @@ Accept wildcard characters: False ### -SubscriptionId Subscription credentials which uniquely identify Microsoft Azure subscription. +The subscription Id forms part of the URI for every service call. ```yaml Type: System.String @@ -247,7 +308,7 @@ Resource tags. ```yaml Type: System.Collections.Hashtable -Parameter Sets: FlattenParameterSet +Parameter Sets: CreateExpanded Aliases: Required: False @@ -257,28 +318,97 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -UserAssignedIdentityId -The id of user assigned identity. +### -UserAssignedIdentity +The list of user identities associated with the image template. +The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. ```yaml -Type: System.String -Parameter Sets: FlattenParameterSet +Type: System.Collections.Hashtable +Parameter Sets: CreateExpanded Aliases: -Required: True +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ValidateContinueDistributeOnFailure +If validation fails and this field is set to false, output image(s) will not be distributed. +This is the default behavior. +If validation fails and this field is set to true, output image(s) will still be distributed. +Please use this option with caution as it may result in bad images being distributed for use. +In either case (true or false), the end to end image run will be reported as having failed in case of a validation failure. +[Note: This field has no effect if validation succeeds.] + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: CreateExpanded +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ValidateSourceValidationOnly +If this field is set to true, the image specified in the 'source' section will directly be validated. +No separate build will be run to generate and then validate a customized image. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: CreateExpanded +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Validator +List of validations to be performed. +To construct, see NOTES section for VALIDATOR properties and create a hash table. + +```yaml +Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplateInVMValidator[] +Parameter Sets: CreateExpanded +Aliases: + +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -VMProfileOsdiskSizeInGb +### -VMProfileOsdiskSizeGb Size of the OS disk in GB. Omit or specify 0 to use Azure's default OS disk size. ```yaml Type: System.Int32 -Parameter Sets: FlattenParameterSet +Parameter Sets: CreateExpanded +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -VMProfileUserAssignedIdentity +Optional array of resource IDs of user assigned managed identities to be configured on the build VM and validation VM. +This may include the identity of the image template. + +```yaml +Type: System.String[] +Parameter Sets: CreateExpanded Aliases: Required: False @@ -288,13 +418,29 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -VMProfileVmSize +### -VMProfileVmsize Size of the virtual machine used to build, customize and capture images. -Omit or specify empty string to use the default (Standard_D1_v2). +Omit or specify empty string to use the default (Standard_D1_v2 for Gen1 images and Standard_D2ds_v4 for Gen2 images). ```yaml Type: System.String -Parameter Sets: FlattenParameterSet +Parameter Sets: CreateExpanded +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -VnetConfigProxyVMSize +Size of the proxy virtual machine used to pass traffic to the build VM and validation VM. +Omit or specify empty string to use the default (Standard_A1_v2). + +```yaml +Type: System.String +Parameter Sets: CreateExpanded Aliases: Required: False @@ -309,7 +455,7 @@ Resource id of a pre-existing subnet. ```yaml Type: System.String -Parameter Sets: FlattenParameterSet +Parameter Sets: CreateExpanded Aliases: Required: False @@ -357,7 +503,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS -### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplate +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplate ## NOTES @@ -368,18 +514,22 @@ COMPLEX PARAMETER PROPERTIES To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. -CUSTOMIZE : Specifies the properties used to describe the customization steps of the image, like Image source etc. +`CUSTOMIZE `: Specifies the properties used to describe the customization steps of the image, like Image source etc - `Type `: The type of customization tool you want to use on the Image. For example, "Shell" can be shell customizer - `[Name ]`: Friendly Name to provide context on what this customization step does -DISTRIBUTE : The distribution targets where the image output needs to go to. +`DISTRIBUTE `: The distribution targets where the image output needs to go to. - `RunOutputName `: The name to be used for the associated RunOutput. - `Type `: Type of distribution. - `[ArtifactTag ]`: Tags that will be applied to the artifact once it has been created/updated by the distributor. - `[(Any) ]`: This indicates any property can be added to this object. -SOURCE : Describes a virtual machine image source for building, customizing and distributing. +`SOURCE `: Specifies the properties used to describe the source image. - `Type `: Specifies the type of source image you want to start with. +`VALIDATOR `: List of validations to be performed. + - `Type `: The type of validation you want to use on the Image. For example, "Shell" can be shell validation + - `[Name ]`: Friendly Name to provide context on what this validation step does + ## RELATED LINKS diff --git a/src/ImageBuilder/docs/New-AzImageBuilderCustomizerObject.md b/src/ImageBuilder/docs/New-AzImageBuilderTemplateCustomizerObject.md similarity index 65% rename from src/ImageBuilder/docs/New-AzImageBuilderCustomizerObject.md rename to src/ImageBuilder/docs/New-AzImageBuilderTemplateCustomizerObject.md index fb534dfd4713..b7bf6d19c033 100644 --- a/src/ImageBuilder/docs/New-AzImageBuilderCustomizerObject.md +++ b/src/ImageBuilder/docs/New-AzImageBuilderTemplateCustomizerObject.md @@ -1,136 +1,120 @@ --- external help file: Module Name: Az.ImageBuilder -online version: https://docs.microsoft.com/powershell/module/az.imagebuilder/new-AzImageBuilderCustomizerObject +online version: https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatecustomizerobject schema: 2.0.0 --- -# New-AzImageBuilderCustomizerObject +# New-AzImageBuilderTemplateCustomizerObject ## SYNOPSIS -Describes a unit of image customization +Create an in-memory object for ImageTemplateCustomizer. ## SYNTAX -### ShellCustomizer (Default) +### FileCustomizer (Default) ``` -New-AzImageBuilderCustomizerObject -CustomizerName -ShellCustomizer [-Inline ] - [-ScriptUri ] [-Sha256Checksum ] [] -``` - -### FileCustomizer -``` -New-AzImageBuilderCustomizerObject -CustomizerName -FileCustomizer [-Destination ] +New-AzImageBuilderTemplateCustomizerObject -FileCustomizer [-Destination ] [-Name ] [-Sha256Checksum ] [-SourceUri ] [] ``` ### PowerShellCustomizer ``` -New-AzImageBuilderCustomizerObject -CustomizerName -PowerShellCustomizer [-Inline ] +New-AzImageBuilderTemplateCustomizerObject -PowerShellCustomizer [-Inline ] [-Name ] [-RunAsSystem ] [-RunElevated ] [-ScriptUri ] [-Sha256Checksum ] [-ValidExitCode ] [] ``` ### RestartCustomizer ``` -New-AzImageBuilderCustomizerObject -CustomizerName -RestartCustomizer [-RestartCheckCommand ] +New-AzImageBuilderTemplateCustomizerObject -RestartCustomizer [-Name ] [-RestartCheckCommand ] [-RestartCommand ] [-RestartTimeout ] [] ``` +### ShellCustomizer +``` +New-AzImageBuilderTemplateCustomizerObject -ShellCustomizer [-Inline ] [-Name ] + [-ScriptUri ] [-Sha256Checksum ] [] +``` + ### WindowsUpdateCustomizer ``` -New-AzImageBuilderCustomizerObject -CustomizerName -WindowsUpdateCustomizer [-Filter ] +New-AzImageBuilderTemplateCustomizerObject -WindowsUpdateCustomizer [-Filter ] [-Name ] [-SearchCriterion ] [-UpdateLimit ] [] ``` ## DESCRIPTION -Describes a unit of image customization +Create an in-memory object for ImageTemplateCustomizer. ## EXAMPLES ### Example 1: Create a windows update customizer ```powershell -New-AzImageBuilderCustomizerObject -WindowsUpdateCustomizer -Filter ("BrowseOnly", "IsInstalled") -SearchCriterion "BrowseOnly=0 and IsInstalled=0" -UpdateLimit 100 -CustomizerName 'WindUpdate' +New-AzImageBuilderTemplateCustomizerObject -WindowsUpdateCustomizer -Name 'WindUpdate' -Filter ("BrowseOnly", "IsInstalled") -SearchCriterion "BrowseOnly=0 and IsInstalled=0" -UpdateLimit 100 ``` ```output -Name Type Filter SearchCriterion UpdateLimit ----- ---- ------ --------------- ----------- -WindUpdate WindowsUpdate {BrowseOnly, IsInstalled} BrowseOnly=0 and IsInstalled=0 100 +Name Filter SearchCriterion UpdateLimit +---- ------ --------------- ----------- +WindUpdate {BrowseOnly, IsInstalled} BrowseOnly=0 and IsInstalled=0 100 ``` This command creates a windows update customizer. ### Example 2: Create a file customizer ```powershell -New-AzImageBuilderCustomizerObject -FileCustomizer -CustomizerName 'filecus' -Destination 'c:\\buildArtifacts\\index.html' -SourceUri 'https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html' +New-AzImageBuilderTemplateCustomizerObject -FileCustomizer -Name 'filecus' -Destination 'c:\\buildArtifacts\\index.html' -SourceUri 'https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html' ``` ```output -Name Type Destination Sha256Checksum SourceUri ----- ---- ----------- -------------- --------- -filecus File c:\\buildArtifacts\\index.html https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/… +Name Destination Sha256Checksum SourceUri +---- ----------- -------------- --------- +filecus c:\\buildArtifacts\\index.html https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html ``` This command creates a file customizer. ### Example 3: Create a powershell customizer ```powershell -$inline = @("mkdir c:\\buildActions", "echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt") -New-AzImageBuilderCustomizerObject -PowerShellCustomizer -CustomizerName settingUpMgmtAgtPath -RunElevated $false -Inline $inline +New-AzImageBuilderTemplateCustomizerObject -PowerShellCustomizer -Name settingUpMgmtAgtPath -RunElevated $false -Inline "mkdir c:\\buildActions", "echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt" ``` ```output -Name Type Inline RunElevated ScriptUri Sha256Checksum ----- ---- ------ ----------- --------- -------------- -settingUpMgmtAgtPath PowerShell {mkdir c:\\buildActions, echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt} False +Name Inline RunAsSystem +---- ------ ----------- +settingUpMgmtAgtPath {mkdir c:\\buildActions, echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt} ``` This command creates a powershell customizer. ### Example 4: Create a restart customizer ```powershell -New-AzImageBuilderCustomizerObject -RestartCustomizer -CustomizerName 'restcus' -RestartCommand 'shutdown /f /r /t 0 /c \"packer restart\"' -RestartCheckCommand 'powershell -command "& {Write-Output "restarted."}"' -RestartTimeout '10m' +New-AzImageBuilderTemplateCustomizerObject -RestartCustomizer -Name 'restcus' -RestartCommand 'shutdown /f /r /t 0 /c \"packer restart\"' -RestartCheckCommand 'powershell -command "& {Write-Output "restarted."}"' -RestartTimeout '10m' ``` ```output -Name Type RestartCheckCommand RestartCommand RestartTimeout ----- ---- ------------------- -------------- -------------- -restcus WindowsRestart powershell -command "& {Write-Output "restarted."}" shutdown /f /r /t 0 /c \"packer restart\" 10m +Name RestartCheckCommand RestartCommand RestartTimeout +---- ------------------- -------------- -------------- +restcus powershell -command "& {Write-Output "restarted."}" shutdown /f /r /t 0 /c \"packer restart\" 10m ``` This command creates a restart customizer. ### Example 5: Create a shell customizer ```powershell -New-AzImageBuilderCustomizerObject -ShellCustomizer -CustomizerName downloadBuildArtifacts -ScriptUri "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh" +New-AzImageBuilderTemplateCustomizerObject -ShellCustomizer -Name downloadBuildArtifacts -ScriptUri "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh" ``` ```output -Name Type Inline ScriptUri Sha256Checksum ----- ---- ------ --------- -------------- -downloadBuildArtifacts Shell https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh +Name Inline ScriptUri +---- ------ --------- +downloadBuildArtifacts https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/cus… ``` This command creates a shell customizer. ## PARAMETERS -### -CustomizerName -Friendly Name to provide context on what this customization step does. - -```yaml -Type: System.String -Parameter Sets: (All) -Aliases: Name - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -Destination The absolute path to a file (with nested directory structures already created) where the file (from sourceUri) will be uploaded to in the VM. @@ -180,7 +164,7 @@ Accept wildcard characters: False ``` ### -Inline -Array of shell commands to execute. +Array of PowerShell commands to execute. ```yaml Type: System.String[] @@ -194,6 +178,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Name +Friendly Name to provide context on what this customization step does. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -PowerShellCustomizer Runs the specified PowerShell on the VM (Windows). Corresponds to Packer powershell provisioner. @@ -227,7 +226,7 @@ Accept wildcard characters: False ``` ### -RestartCommand -Command to execute the restart [Default: 'shutdown /r /f /t 0 /c packer restart'] +Command to execute the restart [Default: 'shutdown /r /f /t 0 /c "packer restart"']. ```yaml Type: System.String @@ -243,7 +242,7 @@ Accept wildcard characters: False ### -RestartCustomizer Reboots a VM and waits for it to come back online (Windows). -Corresponds to Packer windows-restart provisioner. +Corresponds to Packer windows-restart provisioner ```yaml Type: System.Management.Automation.SwitchParameter @@ -305,7 +304,7 @@ Accept wildcard characters: False ``` ### -ScriptUri -URI of the shell script to be run for customizing. +URI of the PowerShell script to be run for customizing. It can be a github link, SAS URI for Azure Storage, etc. ```yaml @@ -338,7 +337,7 @@ Accept wildcard characters: False ``` ### -Sha256Checksum -SHA256 checksum of the shell script provided in the scriptUri field. +SHA256 checksum of the file provided in the sourceUri field above. ```yaml Type: System.String @@ -419,7 +418,7 @@ Accept wildcard characters: False ### -WindowsUpdateCustomizer Installs Windows Updates. -Corresponds to Packer Windows Update Provisioner (https://github.com/rgl/packer-provisioner-windows-update). +Corresponds to Packer Windows Update Provisioner (https://github.com/rgl/packer-provisioner-windows-update) ```yaml Type: System.Management.Automation.SwitchParameter @@ -440,7 +439,15 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS -### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateCustomizer +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateFileCustomizer + +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplatePowerShellCustomizer + +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateRestartCustomizer + +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateShellCustomizer + +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateWindowsUpdateCustomizer ## NOTES diff --git a/src/ImageBuilder/docs/New-AzImageBuilderDistributorObject.md b/src/ImageBuilder/docs/New-AzImageBuilderTemplateDistributorObject.md similarity index 56% rename from src/ImageBuilder/docs/New-AzImageBuilderDistributorObject.md rename to src/ImageBuilder/docs/New-AzImageBuilderTemplateDistributorObject.md index fa5c18ed13e3..ae1e8a9dd4b4 100644 --- a/src/ImageBuilder/docs/New-AzImageBuilderDistributorObject.md +++ b/src/ImageBuilder/docs/New-AzImageBuilderTemplateDistributorObject.md @@ -1,77 +1,76 @@ --- external help file: Module Name: Az.ImageBuilder -online version: https://docs.microsoft.com/powershell/module/az.imagebuilder/new-AzImageBuilderDistributorObject +online version: https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatedistributorobject schema: 2.0.0 --- -# New-AzImageBuilderDistributorObject +# New-AzImageBuilderTemplateDistributorObject ## SYNOPSIS -Generic distribution object +Create an in-memory object for ImageTemplateDistributor. ## SYNTAX -### ManagedImageDistributor (Default) +### VhdDistributor (Default) ``` -New-AzImageBuilderDistributorObject -ArtifactTag -ImageId -Location - -ManagedImageDistributor -RunOutputName [] +New-AzImageBuilderTemplateDistributorObject -RunOutputName -VhdDistributor + [-ArtifactTag ] [] ``` -### SharedImageDistributor +### ManagedImageDistributor ``` -New-AzImageBuilderDistributorObject -ArtifactTag -ExcludeFromLatest - -GalleryImageId -ReplicationRegion -RunOutputName -SharedImageDistributor - [-StorageAccountType ] [] +New-AzImageBuilderTemplateDistributorObject -ImageId -Location -ManagedImageDistributor + -RunOutputName [-ArtifactTag ] [] ``` -### VhdDistributor +### SharedImageDistributor ``` -New-AzImageBuilderDistributorObject -ArtifactTag -RunOutputName -VhdDistributor - [] +New-AzImageBuilderTemplateDistributorObject -GalleryImageId -ReplicationRegion + -RunOutputName -SharedImageDistributor [-ArtifactTag ] + [-ExcludeFromLatest ] [-StorageAccountType ] [] ``` ## DESCRIPTION -Generic distribution object +Create an in-memory object for ImageTemplateDistributor. ## EXAMPLES ### Example 1: Create a managed image distributor ```powershell -New-AzImageBuilderDistributorObject -ManagedImageDistributor -ArtifactTag @{tag='lucasManage'} -ImageId /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/lucas-linux-imageshare -RunOutputName luacas-runout -Location eastus +New-AzImageBuilderTemplateDistributorObject -ManagedImageDistributor -ArtifactTag @{tag='lucasManage'} -ImageId /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/lucas-linux-imageshare -RunOutputName luacas-runout -Location eastus ``` ```output -RunOutputName Type ImageId Location -------------- ---- ------- -------- -luacas-runout ManagedImage /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/lucas-linux-imageshare eastus +RunOutputName ImageId +------------- ------- +luacas-runout /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Co… ``` This command creates a managed image distributor. ### Example 2: Create a VHD distributor ```powershell -New-AzImageBuilderDistributorObject -ArtifactTag @{tag='vhd'} -VhdDistributor -RunOutputName image-vhd +New-AzImageBuilderTemplateDistributorObject -ArtifactTag @{tag='vhd'} -VhdDistributor -RunOutputName image-vhd ``` ```output -RunOutputName Type -------------- ---- -image-vhd Vhd +RunOutputName +------------- +image-vhd ``` This command creates a VHD distributor. ### Example 3: Create a shared image distributor ```powershell -New-AzImageBuilderDistributorObject -SharedImageDistributor -ArtifactTag @{tag='dis-share'} -GalleryImageId '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/myimagegallery/images/lcuas-linux-share' -ReplicationRegion eastus2 -RunOutputName 'outname' -ExcludeFromLatest $false +New-AzImageBuilderTemplateDistributorObject -SharedImageDistributor -ArtifactTag @{tag='dis-share'} -GalleryImageId '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/myimagegallery/images/lcuas-linux-share' -ReplicationRegion eastus2 -RunOutputName 'outname' -ExcludeFromLatest $false ``` ```output -RunOutputName Type ExcludeFromLatest GalleryImageId ReplicationRegi - on -------------- ---- ----------------- -------------- --------------- -outname SharedImage False /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/myimagegallery/images/lcuas-linux-share {eastus2} +RunOutputName ExcludeFromLatest GalleryImageId +------------- ----------------- -------------- +outname False /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/prov… ``` This command creates a shared image distributor. @@ -80,13 +79,14 @@ This command creates a shared image distributor. ### -ArtifactTag Tags that will be applied to the artifact once it has been created/updated by the distributor. +To construct, see NOTES section for ARTIFACTTAG properties and create a hash table. ```yaml -Type: System.Collections.Hashtable +Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.IImageTemplateDistributorArtifactTags Parameter Sets: (All) Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -102,7 +102,7 @@ Type: System.Boolean Parameter Sets: SharedImageDistributor Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -252,11 +252,23 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS -### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateDistributor +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateManagedImageDistributor + +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateSharedImageDistributor + +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateVhdDistributor ## NOTES ALIASES +COMPLEX PARAMETER PROPERTIES + +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. + + +`ARTIFACTTAG `: Tags that will be applied to the artifact once it has been created/updated by the distributor. + - `[(Any) ]`: This indicates any property can be added to this object. + ## RELATED LINKS diff --git a/src/ImageBuilder/docs/New-AzImageBuilderSourceObject.md b/src/ImageBuilder/docs/New-AzImageBuilderTemplateSourceObject.md similarity index 56% rename from src/ImageBuilder/docs/New-AzImageBuilderSourceObject.md rename to src/ImageBuilder/docs/New-AzImageBuilderTemplateSourceObject.md index c34ee19e867e..285cbc2755bb 100644 --- a/src/ImageBuilder/docs/New-AzImageBuilderSourceObject.md +++ b/src/ImageBuilder/docs/New-AzImageBuilderTemplateSourceObject.md @@ -1,81 +1,75 @@ --- external help file: Module Name: Az.ImageBuilder -online version: https://docs.microsoft.com/powershell/module/az.imagebuilder/New-AzImageBuilderSourceObject +online version: https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatesourceobject schema: 2.0.0 --- -# New-AzImageBuilderSourceObject +# New-AzImageBuilderTemplateSourceObject ## SYNOPSIS -Describes a virtual machine image source for building, customizing and distributing. +Create an in-memory object for ImageTemplateSource. ## SYNTAX -### ManagedImage (Default) +### PlatformImageSource (Default) ``` -New-AzImageBuilderSourceObject -SourceTypeManagedImage [-ImageId ] [] +New-AzImageBuilderTemplateSourceObject -PlatformImageSource [-Offer ] [-PlanInfoPlanName ] + [-PlanInfoPlanProduct ] [-PlanInfoPlanPublisher ] [-Publisher ] [-Sku ] + [-Version ] [] ``` -### PlatformImage +### ManagedImageSource ``` -New-AzImageBuilderSourceObject -SourceTypePlatformImage [-Offer ] [-Publisher ] - [-Sku ] [-Version ] [] +New-AzImageBuilderTemplateSourceObject -ImageId -ManagedImageSource [] ``` -### PlatformImagePlanInfo +### SharedImageVersionSource ``` -New-AzImageBuilderSourceObject -PlanName -PlanProduct -PlanPublisher - -SourceTypePlatformImage [-Offer ] [-Publisher ] [-Sku ] [-Version ] - [] -``` - -### SharedImageVersion -``` -New-AzImageBuilderSourceObject -SourceTypeSharedImageVersion [-ImageVersionId ] [] +New-AzImageBuilderTemplateSourceObject -ImageVersionId -SharedImageVersionSource [] ``` ## DESCRIPTION -Describes a virtual machine image source for building, customizing and distributing. +Create an in-memory object for ImageTemplateSource. ## EXAMPLES ### Example 1: Create a managed image source ```powershell $imageid = '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/test-linux-image' -New-AzImageBuilderSourceObject -SourceTypeManagedImage -ImageId $imageid +New-AzImageBuilderTemplateSourceObject -ManagedImageSource -ImageId $imageid ``` ```output -Type ImageId ----- ------- -ManagedImage /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/test-linux-image +ImageId +------- +/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/test-linux-… ``` This command creates a managed image source. ### Example 2: Create a shared image source ```powershell -New-AzImageBuilderSourceObject -SourceTypeSharedImageVersion -ImageVersionId /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/lucasimagegallery/images/myimagedefinition/versions/1.0.0 +New-AzImageBuilderTemplateSourceObject -SharedImageVersionSource -ImageVersionId /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/lucasimagegallery/images/myimagedefinition/versions/1.0.0 ``` ```output -Type ImageVersionId ----- -------------- -SharedImageVersion /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/lucasimagegallery/images/myimagedefinition/versions/1.0.0 +ImageVersionId +-------------- +/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/gallerie… ``` This command creates a shared image source. ### Example 3: Create a platfrom image source ```powershell -New-AzImageBuilderSourceObject -SourceTypePlatformImage -Publisher 'Canonical' -Offer 'UbuntuServer' -Sku '18.04-LTS' -Version 'latest' +New-AzImageBuilderTemplateSourceObject -PlatformImageSource -Publisher 'Canonical' -Offer 'UbuntuServer' -Sku '18.04-LTS' -Version 'latest' ``` ```output -Type Offer Publisher Sku Version ----- ----- --------- --- ------- -PlatformImage UbuntuServer Canonical 18.04-LTS latest +ExactVersion Offer Publisher Sku Version +------------ ----- --------- --- ------- + UbuntuServer Canonical 18.04-LTS latest ``` This command creates a platfrom image source. @@ -87,10 +81,10 @@ ARM resource id of the managed image in customer subscription. ```yaml Type: System.String -Parameter Sets: ManagedImage +Parameter Sets: ManagedImageSource Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False @@ -102,82 +96,83 @@ ARM resource id of the image version in the shared image gallery. ```yaml Type: System.String -Parameter Sets: SharedImageVersion +Parameter Sets: SharedImageVersionSource Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -Offer -Image offer from the [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages). +### -ManagedImageSource +Describes an image source that is a managed image in customer subscription. +This image must reside in the same subscription and region as the Image Builder template. ```yaml -Type: System.String -Parameter Sets: PlatformImage, PlatformImagePlanInfo +Type: System.Management.Automation.SwitchParameter +Parameter Sets: ManagedImageSource Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -PlanName -Name of the purchase plan. +### -Offer +Image offer from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). ```yaml Type: System.String -Parameter Sets: PlatformImagePlanInfo +Parameter Sets: PlatformImageSource Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -PlanProduct -Product of the purchase plan. +### -PlanInfoPlanName +Name of the purchase plan. ```yaml Type: System.String -Parameter Sets: PlatformImagePlanInfo +Parameter Sets: PlatformImageSource Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -PlanPublisher -Publisher of the purchase plan. +### -PlanInfoPlanProduct +Product of the purchase plan. ```yaml Type: System.String -Parameter Sets: PlatformImagePlanInfo +Parameter Sets: PlatformImageSource Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -Publisher -Image Publisher in [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages). +### -PlanInfoPlanPublisher +Publisher of the purchase plan. ```yaml Type: System.String -Parameter Sets: PlatformImage, PlatformImagePlanInfo +Parameter Sets: PlatformImageSource Aliases: Required: False @@ -187,42 +182,42 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Sku -Image sku from the [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages). +### -PlatformImageSource +Describes an image source from [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). ```yaml -Type: System.String -Parameter Sets: PlatformImage, PlatformImagePlanInfo +Type: System.Management.Automation.SwitchParameter +Parameter Sets: PlatformImageSource Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -SourceTypeManagedImage -Describes an image source that is a managed image in customer subscription. +### -Publisher +Image Publisher in [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). ```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: ManagedImage +Type: System.String +Parameter Sets: PlatformImageSource Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -SourceTypePlatformImage -Describes an image source from [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages). +### -SharedImageVersionSource +Describes an image source that is an image version in a shared image gallery. ```yaml Type: System.Management.Automation.SwitchParameter -Parameter Sets: PlatformImage, PlatformImagePlanInfo +Parameter Sets: SharedImageVersionSource Aliases: Required: True @@ -232,15 +227,15 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -SourceTypeSharedImageVersion -Describes an image source that is an image version in a shared image gallery. +### -Sku +Image sku from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). ```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: SharedImageVersion +Type: System.String +Parameter Sets: PlatformImageSource Aliases: -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False @@ -248,11 +243,12 @@ Accept wildcard characters: False ``` ### -Version -Image version from the [Azure Gallery Images](https://docs.microsoft.com/rest/api/compute/virtualmachineimages). +Image version from the [Azure Gallery Images](https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages). +If 'latest' is specified here, the version is evaluated when the image build takes place, not when the template is submitted. ```yaml Type: System.String -Parameter Sets: PlatformImage, PlatformImagePlanInfo +Parameter Sets: PlatformImageSource Aliases: Required: False @@ -269,7 +265,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS -### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.IImageTemplateSource +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateManagedImageSource + +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplatePlatformImageSource + +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateSharedImageVersionSource ## NOTES diff --git a/src/ImageBuilder/docs/New-AzImageBuilderTemplateValidatorObject.md b/src/ImageBuilder/docs/New-AzImageBuilderTemplateValidatorObject.md new file mode 100644 index 000000000000..4eb3469843f6 --- /dev/null +++ b/src/ImageBuilder/docs/New-AzImageBuilderTemplateValidatorObject.md @@ -0,0 +1,219 @@ +--- +external help file: +Module Name: Az.ImageBuilder +online version: https://docs.microsoft.com/powershell/module/az.ImageBuilder/new-azimagebuildertemplatevalidatorobject +schema: 2.0.0 +--- + +# New-AzImageBuilderTemplateValidatorObject + +## SYNOPSIS +Create an in-memory object for ImageTemplateValidator. + +## SYNTAX + +### PowerShellValidator (Default) +``` +New-AzImageBuilderTemplateValidatorObject -PowerShellValidator [-Inline ] [-Name ] + [-RunAsSystem ] [-RunElevated ] [-ScriptUri ] [-Sha256Checksum ] + [-ValidExitCode ] [] +``` + +### ShellValidator +``` +New-AzImageBuilderTemplateValidatorObject -ShellValidator [-Inline ] [-Name ] + [-ScriptUri ] [-Sha256Checksum ] [] +``` + +## DESCRIPTION +Create an in-memory object for ImageTemplateValidator. + +## EXAMPLES + +### Example 1: Create a PowerShell validator +```powershell +New-AzImageBuilderTemplateValidatorObject -PowerShellValidator -Name PowerShellValidator -ScriptUri "https://example.com/path/to/script.sh" +``` + +```output +Name Inline RunAsSystem RunElevated ScriptUri Sha256Checksum ValidExitCode +---- ------ ----------- ----------- --------- -------------- ------------- +PowerShellValidator https://example.com/path/to/script.sh +``` + +This command creates a powershell validator. + +### Example 2: Create a Shell validator +```powershell +New-AzImageBuilderTemplateValidatorObject -ShellValidator -Name ShellValidator -ScriptUri "https://example.com/path/to/script.sh" +``` + +```output +Name Inline ScriptUri Sha256Checksum +---- ------ --------- -------------- +ShellValidator https://example.com/path/to/script.sh +``` + +This command creates a shell validator. + +## PARAMETERS + +### -Inline +Array of PowerShell commands to execute. + +```yaml +Type: System.String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +Friendly Name to provide context on what this validation step does. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PowerShellValidator +Runs the specified PowerShell script during the validation phase (Windows). +Corresponds to Packer powershell provisioner. +Exactly one of 'scriptUri' or 'inline' can be specified. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: PowerShellValidator +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RunAsSystem +If specified, the PowerShell script will be run with elevated privileges using the Local System user. +Can only be true when the runElevated field above is set to true. + +```yaml +Type: System.Boolean +Parameter Sets: PowerShellValidator +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RunElevated +If specified, the PowerShell script will be run with elevated privileges. + +```yaml +Type: System.Boolean +Parameter Sets: PowerShellValidator +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ScriptUri +URI of the PowerShell script to be run for validation. +It can be a github link, Azure Storage URI, etc. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Sha256Checksum +SHA256 checksum of the power shell script provided in the scriptUri field above. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ShellValidator +Runs the specified shell script during the validation phase (Linux). +Corresponds to Packer shell provisioner. +Exactly one of 'scriptUri' or 'inline' can be specified. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: ShellValidator +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ValidExitCode +Valid exit codes for the PowerShell script. +[Default: 0]. + +```yaml +Type: System.Int32[] +Parameter Sets: PowerShellValidator +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplatePowerShellValidator + +### Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20220214.ImageTemplateShellValidator + +## NOTES + +ALIASES + +## RELATED LINKS + diff --git a/src/ImageBuilder/docs/README.md b/src/ImageBuilder/docs/README.md index 0b90db5e4b05..032ab758ed16 100644 --- a/src/ImageBuilder/docs/README.md +++ b/src/ImageBuilder/docs/README.md @@ -1,5 +1,5 @@ # Docs -This directory contains the documentation of the cmdlets for the `Az.ImageBuilder` module. To run documentation generation, use the `generate-help.ps1` script at the root module folder. Files in this folder will *always be overriden on regeneration*. To update documentation examples, please use the `..\examples` folder. +This directory contains the documentation of the cmdlets for the `Az.ImageBuilder` module. To run documentation generation, use the `generate-help.ps1` script at the root module folder. Files in this folder will *always be overridden on regeneration*. To update documentation examples, please use the `..\examples` folder. ## Info - Modifiable: no diff --git a/src/ImageBuilder/docs/Remove-AzImageBuilderTemplate.md b/src/ImageBuilder/docs/Remove-AzImageBuilderTemplate.md index 3aaedb04970c..232435f0beff 100644 --- a/src/ImageBuilder/docs/Remove-AzImageBuilderTemplate.md +++ b/src/ImageBuilder/docs/Remove-AzImageBuilderTemplate.md @@ -14,9 +14,8 @@ Delete a virtual machine image template ### Delete (Default) ``` -Remove-AzImageBuilderTemplate -ImageTemplateName -ResourceGroupName - [-SubscriptionId ] [-DefaultProfile ] [-AsJob] [-NoWait] [-PassThru] [-Confirm] [-WhatIf] - [] +Remove-AzImageBuilderTemplate -Name -ResourceGroupName [-SubscriptionId ] + [-DefaultProfile ] [-AsJob] [-NoWait] [-PassThru] [-Confirm] [-WhatIf] [] ``` ### DeleteViaIdentity @@ -32,15 +31,15 @@ Delete a virtual machine image template ### Example 1: Remove a image template ```powershell -Remove-AzImageBuilderTemplate -ImageTemplateName template-name-dmt6ze -ResourceGroupName wyunchi-imagebuilder +Remove-AzImageBuilderTemplate -Name bez-test-img-temp13 +-ResourceGroupName bez-rg ``` This command removes a image template. ### Example 2: Remove a image template ```powershell -$template = Get-AzImageBuilderTemplate -ImageTemplateName template-name-3uo8p6 -ResourceGroupName wyunchi-imagebuilder -Remove-AzImageBuilderTemplate -InputObject $template +Get-AzImageBuilderTemplate -Name bez-test-img-temp13 -ResourceGroupName bez-rg | Remove-AzImageBuilderTemplate ``` This command removes a image template. @@ -77,34 +76,34 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ImageTemplateName -The name of the image Template +### -InputObject +Identity Parameter +To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ```yaml -Type: System.String -Parameter Sets: Delete -Aliases: Name +Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.IImageBuilderIdentity +Parameter Sets: DeleteViaIdentity +Aliases: Required: True Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` -### -InputObject -Identity Parameter -To construct, see NOTES section for INPUTOBJECT properties and create a hash table. +### -Name +The name of the image Template ```yaml -Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.IImageBuilderIdentity -Parameter Sets: DeleteViaIdentity -Aliases: +Type: System.String +Parameter Sets: Delete +Aliases: ImageTemplateName Required: True Position: Named Default value: None -Accept pipeline input: True (ByValue) +Accept pipeline input: False Accept wildcard characters: False ``` @@ -220,7 +219,7 @@ COMPLEX PARAMETER PROPERTIES To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. -INPUTOBJECT : Identity Parameter +`INPUTOBJECT `: Identity Parameter - `[Id ]`: Resource identity path - `[ImageTemplateName ]`: The name of the image Template - `[ResourceGroupName ]`: The name of the resource group. diff --git a/src/ImageBuilder/docs/Start-AzImageBuilderTemplate.md b/src/ImageBuilder/docs/Start-AzImageBuilderTemplate.md index 028f9de055df..a41ecb635b31 100644 --- a/src/ImageBuilder/docs/Start-AzImageBuilderTemplate.md +++ b/src/ImageBuilder/docs/Start-AzImageBuilderTemplate.md @@ -14,9 +14,8 @@ Create artifacts from a existing image template ### Run (Default) ``` -Start-AzImageBuilderTemplate -ImageTemplateName -ResourceGroupName - [-SubscriptionId ] [-DefaultProfile ] [-AsJob] [-NoWait] [-PassThru] [-Confirm] [-WhatIf] - [] +Start-AzImageBuilderTemplate -Name -ResourceGroupName [-SubscriptionId ] + [-DefaultProfile ] [-AsJob] [-NoWait] [-PassThru] [-Confirm] [-WhatIf] [] ``` ### RunViaIdentity @@ -32,7 +31,7 @@ Create artifacts from a existing image template ### Example 1: Start an image template ```powershell -Start-AzImageBuilderTemplate -ResourceGroupName wyunchi-imagebuilder -Name template-name-sn78hg +Start-AzImageBuilderTemplate -Name bez-test-img-temp12 -ResourceGroupName bez-rg ``` ```output @@ -45,8 +44,7 @@ This command starts an image template. ### Example 2: Start an image template ```powershell -$template = Get-AzImageBuilderTemplate -ResourceGroupName wyunchi-imagebuilder -Name template-name-sn78hg -Start-AzImageBuilderTemplate -InputObject $template +Get-AzImageBuilderTemplate -Name bez-test-img-temp12 -ResourceGroupName bez-rg | Start-AzImageBuilderTemplate ``` This command starts an image template. @@ -83,34 +81,34 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ImageTemplateName -The name of the image Template +### -InputObject +Identity Parameter +To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ```yaml -Type: System.String -Parameter Sets: Run -Aliases: Name +Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.IImageBuilderIdentity +Parameter Sets: RunViaIdentity +Aliases: Required: True Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` -### -InputObject -Identity Parameter -To construct, see NOTES section for INPUTOBJECT properties and create a hash table. +### -Name +The name of the image Template ```yaml -Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.IImageBuilderIdentity -Parameter Sets: RunViaIdentity -Aliases: +Type: System.String +Parameter Sets: Run +Aliases: ImageTemplateName Required: True Position: Named Default value: None -Accept pipeline input: True (ByValue) +Accept pipeline input: False Accept wildcard characters: False ``` @@ -226,7 +224,7 @@ COMPLEX PARAMETER PROPERTIES To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. -INPUTOBJECT : Identity Parameter +`INPUTOBJECT `: Identity Parameter - `[Id ]`: Resource identity path - `[ImageTemplateName ]`: The name of the image Template - `[ResourceGroupName ]`: The name of the resource group. diff --git a/src/ImageBuilder/docs/Stop-AzImageBuilderTemplate.md b/src/ImageBuilder/docs/Stop-AzImageBuilderTemplate.md index 9a0a1ce20bcb..812f4c5839b6 100644 --- a/src/ImageBuilder/docs/Stop-AzImageBuilderTemplate.md +++ b/src/ImageBuilder/docs/Stop-AzImageBuilderTemplate.md @@ -14,7 +14,7 @@ Cancel the long running image build based on the image template ### Cancel (Default) ``` -Stop-AzImageBuilderTemplate -ImageTemplateName -ResourceGroupName [-SubscriptionId ] +Stop-AzImageBuilderTemplate -Name -ResourceGroupName [-SubscriptionId ] [-DefaultProfile ] [-AsJob] [-NoWait] [-PassThru] [-Confirm] [-WhatIf] [] ``` @@ -31,19 +31,14 @@ Cancel the long running image build based on the image template ### Example 1: Stop image template creation ```powershell -Start-AzImageBuilderTemplate -ImageTemplateName template-name-sn78hg -ResourceGroupName wyunchi-imagebuilder -AsJob - -Stop-AzImageBuilderTemplate -ImageTemplateName template-name-sn78hg -ResourceGroupName wyunchi-imagebuilder +Stop-AzImageBuilderTemplate -Name bez-test-img-temp12 -ResourceGroupName bez-rg ``` This command stops image template creation. ### Example 2: Stop image template creation ```powershell -Start-AzImageBuilderTemplate -ImageTemplateName template-name-sn78hg -ResourceGroupName wyunchi-imagebuilder -AsJob - -$template = Get-AzImageBuilderTemplate -ResourceGroupName wyunchi-imagebuilder -Name template-name-sn78hg -Stop-AzImageBuilderTemplate -InputObject $template +Get-AzImageBuilderTemplate -Name bez-test-img-temp12 -ResourceGroupName bez-rg | Stop-AzImageBuilderTemplate ``` This command stops image template creation. @@ -80,34 +75,34 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ImageTemplateName -The name of the image Template +### -InputObject +Identity Parameter +To construct, see NOTES section for INPUTOBJECT properties and create a hash table. ```yaml -Type: System.String -Parameter Sets: Cancel -Aliases: Name +Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.IImageBuilderIdentity +Parameter Sets: CancelViaIdentity +Aliases: Required: True Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` -### -InputObject -Identity Parameter -To construct, see NOTES section for INPUTOBJECT properties and create a hash table. +### -Name +The name of the image Template ```yaml -Type: Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.IImageBuilderIdentity -Parameter Sets: CancelViaIdentity -Aliases: +Type: System.String +Parameter Sets: Cancel +Aliases: ImageTemplateName Required: True Position: Named Default value: None -Accept pipeline input: True (ByValue) +Accept pipeline input: False Accept wildcard characters: False ``` @@ -223,7 +218,7 @@ COMPLEX PARAMETER PROPERTIES To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. -INPUTOBJECT : Identity Parameter +`INPUTOBJECT `: Identity Parameter - `[Id ]`: Resource identity path - `[ImageTemplateName ]`: The name of the image Template - `[ResourceGroupName ]`: The name of the resource group. diff --git a/src/ImageBuilder/examples/Get-AzImageBuilderRunOutput.md b/src/ImageBuilder/examples/Get-AzImageBuilderRunOutput.md deleted file mode 100644 index a5b5b8c68654..000000000000 --- a/src/ImageBuilder/examples/Get-AzImageBuilderRunOutput.md +++ /dev/null @@ -1,38 +0,0 @@ -### Example 1: List all run results under a template -```powershell -Get-AzImageBuilderRunOutput -ImageTemplateName lucas-imagetemplate -ResourceGroupName wyunchi-imagebuilder -``` - -```output -Name Type ----- ---- -image_lucas_1 Microsoft.VirtualMachineImages/imageTemplates/runOutputs -``` - -This command lists all run results under a template. - -### Example 2: Get a run result under a template -```powershell -Get-AzImageBuilderRunOutput -ImageTemplateName template-name-u7gjqx -ResourceGroupName wyunchi-imagebuilder -RunOutputName runout-template-name-u7gjqx -``` - -```output -Name Type ----- ---- -runout-template-name-u7gjqx Microsoft.VirtualMachineImages/imageTemplates/runOutputs -``` -This command gets a run result under a template. - -### Example 3: Get a run result under a template -```powershell -$result = Get-AzImageBuilderRunOutput -ImageTemplateName template-name-u7gjqx -ResourceGroupName wyunchi-imagebuilder -RunOutputName runout-template-name-u7gjqx -Get-AzImageBuilderRunOutput -InputObject $result -``` - -```output -Name Type ----- ---- -runout-template-name-u7gjqx Microsoft.VirtualMachineImages/imageTemplates/runOutputs -``` -This command gets a run result under a template. - diff --git a/src/ImageBuilder/examples/Get-AzImageBuilderTemplate.md b/src/ImageBuilder/examples/Get-AzImageBuilderTemplate.md index aa9963394436..b651297e4400 100644 --- a/src/ImageBuilder/examples/Get-AzImageBuilderTemplate.md +++ b/src/ImageBuilder/examples/Get-AzImageBuilderTemplate.md @@ -4,59 +4,41 @@ Get-AzImageBuilderTemplate ``` ```output -Location Name Type --------- ---- ---- -eastus HelloImageTemplateLinux01 Microsoft.VirtualMachineImages/imageTemplates -eastus lucas-imagetemplate Microsoft.VirtualMachineImages/imageTemplates -eastus test-imagebuilder Microsoft.VirtualMachineImages/imageTemplates +Location Name SystemDataCreatedAt SystemDataCreatedBy SystemDataCreatedByType SystemDataLastModifiedAt SystemDataLastModifiedBy SystemDataLastModifiedByType +-------- ---- ------------------- ------------------- ----------------------- ------------------------ ------------------------ ---------------------------- +eastus bez-test-img-temp +eastus bez-test-img-temp12 +eastus bez-test-img-temp13 +eastus test-img-temp ``` This command lists all template under a subscription. ### Example 2: List all template under a resource group ```powershell -Get-AzImageBuilderTemplate -ResourceGroupName wyunchi-imagebuilder +Get-AzImageBuilderTemplate -ResourceGroupName bez-rg ``` ```output -Location Name Type --------- ---- ---- -eastus HelloImageTemplateLinux01 Microsoft.VirtualMachineImages/imageTemplates -eastus template-name-ax01b7 Microsoft.VirtualMachineImages/imageTemplates -eastus template-name-ep5z7v Microsoft.VirtualMachineImages/imageTemplates -eastus template-name-klcuav Microsoft.VirtualMachineImages/imageTemplates -eastus template-name-u7gjqx Microsoft.VirtualMachineImages/imageTemplates -eastus test-imagebuilder Microsoft.VirtualMachineImages/imageTemplates -eastus tmpl-managedimg-managedimg Microsoft.VirtualMachineImages/imageTemplates -eastus tmpl-platform-managed Microsoft.VirtualMachineImages/imageTemplates -eastus tmpl-shareimg-managedimg Microsoft.VirtualMachineImages/imageTemplates +Location Name SystemDataCreatedAt SystemDataCreatedBy SystemDataCreatedByType SystemDataLastModifiedAt SystemDataLastModifiedBy SystemDataLastModifiedByType +-------- ---- ------------------- ------------------- ----------------------- ------------------------ ------------------------ ---------------------------- +eastus bez-test-img-temp +eastus bez-test-img-temp12 +eastus bez-test-img-temp13 +eastus test-img-temp ``` This command lists all template under a resource group. ### Example 3: Get a template under a resource group ```powershell -Get-AzImageBuilderTemplate -ImageTemplateName lucas-imagetemplate -ResourceGroupName wyunchi-imagebuilder +Get-AzImageBuilderTemplate -Name test-img-temp -ResourceGroupName bez-rg ``` ```output -Location Name Type --------- ---- ---- -eastus lucas-imagetemplate Microsoft.VirtualMachineImages/imageTemplates -``` - -This command gets a template under a resource group. - -### Example 4: Get a template under a resource group -```powershell -$template = Get-AzImageBuilderTemplate -ResourceGroupName wyunchi-imagebuilder -ImageTemplateName template-name-ep5z7v -Get-AzImageBuilderTemplate -InputObject $template -``` - -```output -Location Name Type --------- ---- ---- -eastus template-name-ep5z7v Microsoft.VirtualMachineImages/imageTemplates +Location Name SystemDataCreatedAt SystemDataCreatedBy SystemDataCreatedByType SystemDataLastModifiedAt SystemDataLastModifiedBy +-------- ---- ------------------- ------------------- ----------------------- ------------------------ ------------------ +eastus test-img-temp ``` This command gets a template under a resource group. diff --git a/src/ImageBuilder/examples/Get-AzImageBuilderTemplateRunOutput.md b/src/ImageBuilder/examples/Get-AzImageBuilderTemplateRunOutput.md new file mode 100644 index 000000000000..32abfadae5f1 --- /dev/null +++ b/src/ImageBuilder/examples/Get-AzImageBuilderTemplateRunOutput.md @@ -0,0 +1,25 @@ +### Example 1: List all run results under a template +```powershell +Get-AzImageBuilderTemplateRunOutput -ImageTemplateName test-img-temp -ResourceGroupName bez-rg +``` + +```output +Name +---- +image_lucas_1 +``` + +This command lists all run results under a template. + +### Example 2: Get a run result under a template +```powershell +Get-AzImageBuilderTemplateRunOutput -ImageTemplateName test-img-temp -ResourceGroupName bez-rg -Name runout-template-name-u7gjq +``` + +```output +Name +---- +runout-template-name-u7gjqx +``` +This command gets a run result under a template. + diff --git a/src/ImageBuilder/examples/New-AzImageBuilderCustomizerObject.md b/src/ImageBuilder/examples/New-AzImageBuilderCustomizerObject.md deleted file mode 100644 index 78db4a758f4c..000000000000 --- a/src/ImageBuilder/examples/New-AzImageBuilderCustomizerObject.md +++ /dev/null @@ -1,66 +0,0 @@ -### Example 1: Create a windows update customizer -```powershell -New-AzImageBuilderCustomizerObject -WindowsUpdateCustomizer -Filter ("BrowseOnly", "IsInstalled") -SearchCriterion "BrowseOnly=0 and IsInstalled=0" -UpdateLimit 100 -CustomizerName 'WindUpdate' -``` - -```output -Name Type Filter SearchCriterion UpdateLimit ----- ---- ------ --------------- ----------- -WindUpdate WindowsUpdate {BrowseOnly, IsInstalled} BrowseOnly=0 and IsInstalled=0 100 -``` - -This command creates a windows update customizer. - -### Example 2: Create a file customizer -```powershell -New-AzImageBuilderCustomizerObject -FileCustomizer -CustomizerName 'filecus' -Destination 'c:\\buildArtifacts\\index.html' -SourceUri 'https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html' -``` - -```output -Name Type Destination Sha256Checksum SourceUri ----- ---- ----------- -------------- --------- -filecus File c:\\buildArtifacts\\index.html https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/… -``` - -This command creates a file customizer. - -### Example 3: Create a powershell customizer -```powershell -$inline = @("mkdir c:\\buildActions", "echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt") -New-AzImageBuilderCustomizerObject -PowerShellCustomizer -CustomizerName settingUpMgmtAgtPath -RunElevated $false -Inline $inline -``` - -```output -Name Type Inline RunElevated ScriptUri Sha256Checksum ----- ---- ------ ----------- --------- -------------- -settingUpMgmtAgtPath PowerShell {mkdir c:\\buildActions, echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt} False -``` - -This command creates a powershell customizer. - -### Example 4: Create a restart customizer -```powershell -New-AzImageBuilderCustomizerObject -RestartCustomizer -CustomizerName 'restcus' -RestartCommand 'shutdown /f /r /t 0 /c \"packer restart\"' -RestartCheckCommand 'powershell -command "& {Write-Output "restarted."}"' -RestartTimeout '10m' -``` - -```output -Name Type RestartCheckCommand RestartCommand RestartTimeout ----- ---- ------------------- -------------- -------------- -restcus WindowsRestart powershell -command "& {Write-Output "restarted."}" shutdown /f /r /t 0 /c \"packer restart\" 10m -``` - -This command creates a restart customizer. - -### Example 5: Create a shell customizer -```powershell -New-AzImageBuilderCustomizerObject -ShellCustomizer -CustomizerName downloadBuildArtifacts -ScriptUri "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh" -``` - -```output -Name Type Inline ScriptUri Sha256Checksum ----- ---- ------ --------- -------------- -downloadBuildArtifacts Shell https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh -``` - -This command creates a shell customizer. - diff --git a/src/ImageBuilder/examples/New-AzImageBuilderDistributorObject.md b/src/ImageBuilder/examples/New-AzImageBuilderDistributorObject.md deleted file mode 100644 index 14b432a7c0dc..000000000000 --- a/src/ImageBuilder/examples/New-AzImageBuilderDistributorObject.md +++ /dev/null @@ -1,41 +0,0 @@ -### Example 1: Create a managed image distributor -```powershell -New-AzImageBuilderDistributorObject -ManagedImageDistributor -ArtifactTag @{tag='lucasManage'} -ImageId /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/lucas-linux-imageshare -RunOutputName luacas-runout -Location eastus -``` - -```output -RunOutputName Type ImageId Location -------------- ---- ------- -------- -luacas-runout ManagedImage /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/lucas-linux-imageshare eastus -``` - -This command creates a managed image distributor. - -### Example 2: Create a VHD distributor -```powershell -New-AzImageBuilderDistributorObject -ArtifactTag @{tag='vhd'} -VhdDistributor -RunOutputName image-vhd -``` - -```output -RunOutputName Type -------------- ---- -image-vhd Vhd -``` - -This command creates a VHD distributor. - -### Example 3: Create a shared image distributor -```powershell -New-AzImageBuilderDistributorObject -SharedImageDistributor -ArtifactTag @{tag='dis-share'} -GalleryImageId '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/myimagegallery/images/lcuas-linux-share' -ReplicationRegion eastus2 -RunOutputName 'outname' -ExcludeFromLatest $false -``` - -```output -RunOutputName Type ExcludeFromLatest GalleryImageId ReplicationRegi - on -------------- ---- ----------------- -------------- --------------- -outname SharedImage False /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/myimagegallery/images/lcuas-linux-share {eastus2} -``` - -This command creates a shared image distributor. - - diff --git a/src/ImageBuilder/examples/New-AzImageBuilderSourceObject.md b/src/ImageBuilder/examples/New-AzImageBuilderSourceObject.md deleted file mode 100644 index 1df9a553aaaf..000000000000 --- a/src/ImageBuilder/examples/New-AzImageBuilderSourceObject.md +++ /dev/null @@ -1,40 +0,0 @@ -### Example 1: Create a managed image source -```powershell -$imageid = '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/test-linux-image' -New-AzImageBuilderSourceObject -SourceTypeManagedImage -ImageId $imageid -``` - -```output -Type ImageId ----- ------- -ManagedImage /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/test-linux-image -``` - -This command creates a managed image source. - -### Example 2: Create a shared image source -```powershell -New-AzImageBuilderSourceObject -SourceTypeSharedImageVersion -ImageVersionId /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/lucasimagegallery/images/myimagedefinition/versions/1.0.0 -``` - -```output -Type ImageVersionId ----- -------------- -SharedImageVersion /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/lucasimagegallery/images/myimagedefinition/versions/1.0.0 -``` - -This command creates a shared image source. - -### Example 3: Create a platfrom image source -```powershell -New-AzImageBuilderSourceObject -SourceTypePlatformImage -Publisher 'Canonical' -Offer 'UbuntuServer' -Sku '18.04-LTS' -Version 'latest' -``` - -```output -Type Offer Publisher Sku Version ----- ----- --------- --- ------- -PlatformImage UbuntuServer Canonical 18.04-LTS latest -``` - -This command creates a platfrom image source. - diff --git a/src/ImageBuilder/examples/New-AzImageBuilderTemplate.md b/src/ImageBuilder/examples/New-AzImageBuilderTemplate.md index 568e881bcdbc..6ee1a83db970 100644 --- a/src/ImageBuilder/examples/New-AzImageBuilderTemplate.md +++ b/src/ImageBuilder/examples/New-AzImageBuilderTemplate.md @@ -1,21 +1,22 @@ -### Example 1: Create a virtual machine image template +### Example 1: {{ Add title here }} ```powershell -$srcPlatform = New-AzImageBuilderSourceObject -SourceTypePlatformImage -Publisher 'Canonical' -Offer 'UbuntuServer' -Sku '18.04-LTS' -Version 'latest' -$disSharedImg = New-AzImageBuilderDistributorObject -SharedImageDistributor -ArtifactTag @{tag='dis-share'} -GalleryImageId '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/testsharedgallery/images/imagedefinition-linux/versions/1.0.0' -ReplicationRegion 'eastus2' -RunOutputName 'runoutput-01' -ExcludeFromLatest $false -$customizer = New-AzImageBuilderCustomizerObject -ShellCustomizer -CustomizerName 'CheckSumCompareShellScript' -ScriptUri 'https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh' -Sha256Checksum 'ade4c5214c3c675e92c66e2d067a870c5b81b9844b3de3cc72c49ff36425fc93' -$userAssignedIdentity = '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/wyunchi-imagebuilder/providers/Microsoft.ManagedIdentity/userAssignedIdentities/image-builder-user-assign-identity' -New-AzImageBuilderTemplate -ImageTemplateName platform-shared-img -ResourceGroupName wyunchi-imagebuilder -Source $srcPlatform -Distribute $disSharedImg -Customize $customizer -Location eastus -UserAssignedIdentityId $userAssignedIdentity +{{ Add code here }} ``` ```output -Location Name Type --------- ---- ---- -PlanInfoPlanName : -PlanInfoPlanPublisher : -Sku : 18.04-LTS -Version : latest -PlanInfo : Microsoft.Azure.PowerShell.Cmdlets.ImageBuilder.Models.Api20200214.PlatformImagePurchasePlan +{{ Add output here }} ``` -This commands creates a virtual machine image template. +{{ Add description here }} + +### Example 2: {{ Add title here }} +```powershell +{{ Add code here }} +``` + +```output +{{ Add output here }} +``` + +{{ Add description here }} diff --git a/src/ImageBuilder/examples/New-AzImageBuilderTemplateCustomizerObject.md b/src/ImageBuilder/examples/New-AzImageBuilderTemplateCustomizerObject.md new file mode 100644 index 000000000000..7db7886c8cd8 --- /dev/null +++ b/src/ImageBuilder/examples/New-AzImageBuilderTemplateCustomizerObject.md @@ -0,0 +1,64 @@ +### Example 1: Create a windows update customizer +```powershell +New-AzImageBuilderTemplateCustomizerObject -WindowsUpdateCustomizer -Name 'WindUpdate' -Filter ("BrowseOnly", "IsInstalled") -SearchCriterion "BrowseOnly=0 and IsInstalled=0" -UpdateLimit 100 +``` + +```output +Name Filter SearchCriterion UpdateLimit +---- ------ --------------- ----------- +WindUpdate {BrowseOnly, IsInstalled} BrowseOnly=0 and IsInstalled=0 100 +``` + +This command creates a windows update customizer. + +### Example 2: Create a file customizer +```powershell +New-AzImageBuilderTemplateCustomizerObject -FileCustomizer -Name 'filecus' -Destination 'c:\\buildArtifacts\\index.html' -SourceUri 'https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html' +``` + +```output +Name Destination Sha256Checksum SourceUri +---- ----------- -------------- --------- +filecus c:\\buildArtifacts\\index.html https://github.com/danielsollondon/azvmimagebuilder/blob/master/quickquickstarts/exampleArtifacts/buildArtifacts/index.html +``` + +This command creates a file customizer. + +### Example 3: Create a powershell customizer +```powershell +New-AzImageBuilderTemplateCustomizerObject -PowerShellCustomizer -Name settingUpMgmtAgtPath -RunElevated $false -Inline "mkdir c:\\buildActions", "echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt" +``` + +```output +Name Inline RunAsSystem +---- ------ ----------- +settingUpMgmtAgtPath {mkdir c:\\buildActions, echo Azure-Image-Builder-Was-Here > c:\\buildActions\\buildActionsOutput.txt} +``` + +This command creates a powershell customizer. + +### Example 4: Create a restart customizer +```powershell +New-AzImageBuilderTemplateCustomizerObject -RestartCustomizer -Name 'restcus' -RestartCommand 'shutdown /f /r /t 0 /c \"packer restart\"' -RestartCheckCommand 'powershell -command "& {Write-Output "restarted."}"' -RestartTimeout '10m' +``` + +```output +Name RestartCheckCommand RestartCommand RestartTimeout +---- ------------------- -------------- -------------- +restcus powershell -command "& {Write-Output "restarted."}" shutdown /f /r /t 0 /c \"packer restart\" 10m +``` + +This command creates a restart customizer. + +### Example 5: Create a shell customizer +```powershell +New-AzImageBuilderTemplateCustomizerObject -ShellCustomizer -Name downloadBuildArtifacts -ScriptUri "https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/customizeScript2.sh" +``` + +```output +Name Inline ScriptUri +---- ------ --------- +downloadBuildArtifacts https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquickstarts/cus… +``` + +This command creates a shell customizer. \ No newline at end of file diff --git a/src/ImageBuilder/examples/New-AzImageBuilderTemplateDistributorObject.md b/src/ImageBuilder/examples/New-AzImageBuilderTemplateDistributorObject.md new file mode 100644 index 000000000000..e2d1f0f648c0 --- /dev/null +++ b/src/ImageBuilder/examples/New-AzImageBuilderTemplateDistributorObject.md @@ -0,0 +1,40 @@ +### Example 1: Create a managed image distributor +```powershell +New-AzImageBuilderTemplateDistributorObject -ManagedImageDistributor -ArtifactTag @{tag='lucasManage'} -ImageId /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/lucas-linux-imageshare -RunOutputName luacas-runout -Location eastus +``` + +```output +RunOutputName ImageId +------------- ------- +luacas-runout /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Co… +``` + +This command creates a managed image distributor. + +### Example 2: Create a VHD distributor +```powershell +New-AzImageBuilderTemplateDistributorObject -ArtifactTag @{tag='vhd'} -VhdDistributor -RunOutputName image-vhd +``` + +```output +RunOutputName +------------- +image-vhd +``` + +This command creates a VHD distributor. + +### Example 3: Create a shared image distributor +```powershell +New-AzImageBuilderTemplateDistributorObject -SharedImageDistributor -ArtifactTag @{tag='dis-share'} -GalleryImageId '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/myimagegallery/images/lcuas-linux-share' -ReplicationRegion eastus2 -RunOutputName 'outname' -ExcludeFromLatest $false +``` + +```output +RunOutputName ExcludeFromLatest GalleryImageId +------------- ----------------- -------------- +outname False /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/prov… +``` + +This command creates a shared image distributor. + + diff --git a/src/ImageBuilder/examples/New-AzImageBuilderTemplateSourceObject.md b/src/ImageBuilder/examples/New-AzImageBuilderTemplateSourceObject.md new file mode 100644 index 000000000000..c2bb0bb3b6ac --- /dev/null +++ b/src/ImageBuilder/examples/New-AzImageBuilderTemplateSourceObject.md @@ -0,0 +1,39 @@ +### Example 1: Create a managed image source +```powershell +$imageid = '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/test-linux-image' +New-AzImageBuilderTemplateSourceObject -ManagedImageSource -ImageId $imageid +``` + +```output +ImageId +------- +/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/images/test-linux-… +``` + +This command creates a managed image source. + +### Example 2: Create a shared image source +```powershell +New-AzImageBuilderTemplateSourceObject -SharedImageVersionSource -ImageVersionId /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/galleries/lucasimagegallery/images/myimagedefinition/versions/1.0.0 +``` + +```output +ImageVersionId +-------------- +/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/wyunchi-imagebuilder/providers/Microsoft.Compute/gallerie… +``` + +This command creates a shared image source. + +### Example 3: Create a platfrom image source +```powershell +New-AzImageBuilderTemplateSourceObject -PlatformImageSource -Publisher 'Canonical' -Offer 'UbuntuServer' -Sku '18.04-LTS' -Version 'latest' +``` + +```output +ExactVersion Offer Publisher Sku Version +------------ ----- --------- --- ------- + UbuntuServer Canonical 18.04-LTS latest +``` + +This command creates a platfrom image source. \ No newline at end of file diff --git a/src/ImageBuilder/examples/New-AzImageBuilderTemplateValidatorObject.md b/src/ImageBuilder/examples/New-AzImageBuilderTemplateValidatorObject.md new file mode 100644 index 000000000000..06461efdbaf1 --- /dev/null +++ b/src/ImageBuilder/examples/New-AzImageBuilderTemplateValidatorObject.md @@ -0,0 +1,26 @@ +### Example 1: Create a PowerShell validator +```powershell +New-AzImageBuilderTemplateValidatorObject -PowerShellValidator -Name PowerShellValidator -ScriptUri "https://example.com/path/to/script.sh" +``` + +```output +Name Inline RunAsSystem RunElevated ScriptUri Sha256Checksum ValidExitCode +---- ------ ----------- ----------- --------- -------------- ------------- +PowerShellValidator https://example.com/path/to/script.sh +``` + +This command creates a powershell validator. + +### Example 2: Create a Shell validator +```powershell +New-AzImageBuilderTemplateValidatorObject -ShellValidator -Name ShellValidator -ScriptUri "https://example.com/path/to/script.sh" +``` + +```output +Name Inline ScriptUri Sha256Checksum +---- ------ --------- -------------- +ShellValidator https://example.com/path/to/script.sh +``` + +This command creates a shell validator. + diff --git a/src/ImageBuilder/examples/Remove-AzImageBuilderTemplate.md b/src/ImageBuilder/examples/Remove-AzImageBuilderTemplate.md index 5e76a42ec92a..de054e8e03e1 100644 --- a/src/ImageBuilder/examples/Remove-AzImageBuilderTemplate.md +++ b/src/ImageBuilder/examples/Remove-AzImageBuilderTemplate.md @@ -1,14 +1,14 @@ ### Example 1: Remove a image template ```powershell -Remove-AzImageBuilderTemplate -ImageTemplateName template-name-dmt6ze -ResourceGroupName wyunchi-imagebuilder +Remove-AzImageBuilderTemplate -Name bez-test-img-temp13 +-ResourceGroupName bez-rg ``` This command removes a image template. ### Example 2: Remove a image template ```powershell -$template = Get-AzImageBuilderTemplate -ImageTemplateName template-name-3uo8p6 -ResourceGroupName wyunchi-imagebuilder -Remove-AzImageBuilderTemplate -InputObject $template +Get-AzImageBuilderTemplate -Name bez-test-img-temp13 -ResourceGroupName bez-rg | Remove-AzImageBuilderTemplate ``` This command removes a image template. diff --git a/src/ImageBuilder/examples/Start-AzImageBuilderTemplate.md b/src/ImageBuilder/examples/Start-AzImageBuilderTemplate.md index 61e9c09f913d..18d2c5a787fc 100644 --- a/src/ImageBuilder/examples/Start-AzImageBuilderTemplate.md +++ b/src/ImageBuilder/examples/Start-AzImageBuilderTemplate.md @@ -1,6 +1,6 @@ ### Example 1: Start an image template ```powershell -Start-AzImageBuilderTemplate -ResourceGroupName wyunchi-imagebuilder -Name template-name-sn78hg +Start-AzImageBuilderTemplate -Name bez-test-img-temp12 -ResourceGroupName bez-rg ``` ```output @@ -13,8 +13,7 @@ This command starts an image template. ### Example 2: Start an image template ```powershell -$template = Get-AzImageBuilderTemplate -ResourceGroupName wyunchi-imagebuilder -Name template-name-sn78hg -Start-AzImageBuilderTemplate -InputObject $template +Get-AzImageBuilderTemplate -Name bez-test-img-temp12 -ResourceGroupName bez-rg | Start-AzImageBuilderTemplate ``` This command starts an image template. diff --git a/src/ImageBuilder/examples/Stop-AzImageBuilderTemplate.md b/src/ImageBuilder/examples/Stop-AzImageBuilderTemplate.md index 456c25ac9dfb..d949492cd186 100644 --- a/src/ImageBuilder/examples/Stop-AzImageBuilderTemplate.md +++ b/src/ImageBuilder/examples/Stop-AzImageBuilderTemplate.md @@ -1,18 +1,13 @@ ### Example 1: Stop image template creation ```powershell -Start-AzImageBuilderTemplate -ImageTemplateName template-name-sn78hg -ResourceGroupName wyunchi-imagebuilder -AsJob - -Stop-AzImageBuilderTemplate -ImageTemplateName template-name-sn78hg -ResourceGroupName wyunchi-imagebuilder +Stop-AzImageBuilderTemplate -Name bez-test-img-temp12 -ResourceGroupName bez-rg ``` This command stops image template creation. ### Example 2: Stop image template creation ```powershell -Start-AzImageBuilderTemplate -ImageTemplateName template-name-sn78hg -ResourceGroupName wyunchi-imagebuilder -AsJob - -$template = Get-AzImageBuilderTemplate -ResourceGroupName wyunchi-imagebuilder -Name template-name-sn78hg -Stop-AzImageBuilderTemplate -InputObject $template +Get-AzImageBuilderTemplate -Name bez-test-img-temp12 -ResourceGroupName bez-rg | Stop-AzImageBuilderTemplate ``` This command stops image template creation. diff --git a/src/ImageBuilder/how-to.md b/src/ImageBuilder/how-to.md new file mode 100644 index 000000000000..730ca80780ab --- /dev/null +++ b/src/ImageBuilder/how-to.md @@ -0,0 +1,58 @@ +# How-To +This document describes how to develop for `Az.ImageBuilder`. + +## Building `Az.ImageBuilder` +To build, run the `build-module.ps1` at the root of the module directory. This will generate the proxy script cmdlets that are the cmdlets being exported by this module. After the build completes, the proxy script cmdlets will be output to the `exports` folder. To read more about the proxy script cmdlets, look at the [README.md](exports/README.md) in the `exports` folder. + +## Creating custom cmdlets +To add cmdlets that were not generated by the REST specification, use the `custom` folder. This folder allows you to add handwritten `.ps1` and `.cs` files. Currently, we support using `.ps1` scripts as new cmdlets or as additional low-level variants (via `ParameterSet`), and `.cs` files as low-level (variants) cmdlets that the exported script cmdlets call. We do not support exporting any `.cs` (dll) cmdlets directly. To read more about custom cmdlets, look at the [README.md](custom/README.md) in the `custom` folder. + +## Generating documentation +To generate documentation, the process is now integrated into the `build-module.ps1` script. If you don't want to run this process as part of `build-module.ps1`, you can provide the `-NoDocs` switch. If you want to run documentation generation after the build process, you may still run the `generate-help.ps1` script. Overall, the process will look at the documentation comments in the generated and custom cmdlets and types, and create `.md` files into the `docs` folder. Additionally, this pulls in any examples from the `examples` folder and adds them to the generated help markdown documents. To read more about examples, look at the [README.md](examples/README.md) in the `examples` folder. To read more about documentation, look at the [README.md](docs/README.md) in the `docs` folder. + +## Testing `Az.ImageBuilder` +To test the cmdlets, we use [Pester](https://github.com/pester/Pester). Tests scripts (`.ps1`) should be added to the `test` folder. To execute the Pester tests, run the `test-module.ps1` script. This will run all tests in `playback` mode within the `test` folder. To read more about testing cmdlets, look at the [README.md](examples/README.md) in the `examples` folder. + +## Packing `Az.ImageBuilder` +To pack `Az.ImageBuilder` for distribution, run the `pack-module.ps1` script. This will take the contents of multiple directories and certain root-folder files to create a `.nupkg`. The structure of the `.nupkg` is created so it can be loaded part of a [PSRepository](https://docs.microsoft.com/powershell/module/powershellget/register-psrepository). Additionally, this package is in a format for distribution to the [PSGallery](https://www.powershellgallery.com/). For signing an Azure module, please contact the [Azure PowerShell](https://github.com/Azure/azure-powershell) team. + +## Module Script Details +There are multiple scripts created for performing different actions for developing `Az.ImageBuilder`. +- `build-module.ps1` + - Builds the module DLL (`./bin/Az.ImageBuilder.private.dll`), creates the exported cmdlets and documentation, generates custom cmdlet test stubs and exported cmdlet example stubs, and updates `./Az.ImageBuilder.psd1` with Azure profile information. + - **Parameters**: [`Switch` parameters] + - `-Run`: After building, creates an isolated PowerShell session and loads `Az.ImageBuilder`. + - `-Test`: After building, runs the `Pester` tests defined in the `test` folder. + - `-Docs`: After building, generates the Markdown documents for the modules into the `docs` folder. + - `-Pack`: After building, packages the module into a `.nupkg`. + - `-Code`: After building, opens a VSCode window with the module's directory and runs (see `-Run`) the module. + - `-Release`: Builds the module in `Release` configuration (as opposed to `Debug` configuration). + - `-NoDocs`: Supresses writing the documentation markdown files as part of the cmdlet exporting process. + - `-Debugger`: Used when attaching the debugger in Visual Studio to the PowerShell session, and running the build process without recompiling the DLL. This suppresses running the script as an isolated process. +- `run-module.ps1` + - Creates an isolated PowerShell session and loads `Az.ImageBuilder` into the session. + - Same as `-Run` in `build-module.ps1`. + - **Parameters**: [`Switch` parameters] + - `-Code`: Opens a VSCode window with the module's directory. + - Same as `-Code` in `build-module.ps1`. +- `generate-help.ps1` + - Generates the Markdown documents for the modules into the `docs` folder. + - Same as `-Docs` in `build-module.ps1`. +- `test-module.ps1` + - Runs the `Pester` tests defined in the `test` folder. + - Same as `-Test` in `build-module.ps1`. +- `pack-module.ps1` + - Packages the module into a `.nupkg` for distribution. + - Same as `-Pack` in `build-module.ps1`. +- `generate-help.ps1` + - Generates the Markdown documents for the modules into the `docs` folder. + - Same as `-Docs` in `build-module.ps1`. + - This process is now integrated into `build-module.ps1` automatically. To disable, use `-NoDocs` when running `build-module.ps1`. +- `export-surface.ps1` + - Generates Markdown documents for both the cmdlet surface and the model (class) surface of the module. + - These files are placed into the `resources` folder. + - Used for investigating the surface of your module. These are *not* documentation for distribution. +- `check-dependencies.ps1` + - Used in `run-module.ps1` and `test-module.ps1` to verify dependent modules are available to run those tasks. + - It will download local (within the module's directory structure) versions of those modules as needed. + - This script *does not* need to be ran by-hand. \ No newline at end of file diff --git a/src/ImageBuilder/license.txt b/src/ImageBuilder/license.txt new file mode 100644 index 000000000000..b9f3180fb9af --- /dev/null +++ b/src/ImageBuilder/license.txt @@ -0,0 +1,227 @@ +MICROSOFT SOFTWARE LICENSE TERMS + +MICROSOFT AZURE POWERSHELL + +These license terms are an agreement between Microsoft Corporation (or based on where you live, one of its affiliates) and you. Please read them. They apply to the software named above, which includes the media on which you received it, if any. + +BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. IF YOU DO NOT ACCEPT THEM, DO NOT USE THE SOFTWARE. + + +-----------------START OF LICENSE-------------------------- + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +-------------------END OF LICENSE------------------------------------------ + + +----------------START OF THIRD PARTY NOTICE-------------------------------- + + +The software includes the AutoMapper library ("AutoMapper"). The MIT License set out below is provided for informational purposes only. It is not the license that governs any part of the software. + +Provided for Informational Purposes Only + +AutoMapper + +The MIT License (MIT) +Copyright (c) 2010 Jimmy Bogard + + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + + + + +*************** + +The software includes Newtonsoft.Json. The MIT License set out below is provided for informational purposes only. It is not the license that governs any part of the software. + +Newtonsoft.Json + +The MIT License (MIT) +Copyright (c) 2007 James Newton-King +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +-------------END OF THIRD PARTY NOTICE---------------------------------------- + diff --git a/src/ImageBuilder/resources/README.md b/src/ImageBuilder/resources/README.md new file mode 100644 index 000000000000..937f07f8fec2 --- /dev/null +++ b/src/ImageBuilder/resources/README.md @@ -0,0 +1,11 @@ +# Resources +This directory can contain any additional resources for module that are not required at runtime. This directory **does not** get packaged with the module. If you have assets for custom implementation, place them into the `..\custom` folder. + +## Info +- Modifiable: yes +- Generated: no +- Committed: yes +- Packaged: no + +## Purpose +Use this folder to put anything you want to keep around as part of the repository for the module, but is not something that is required for the module. For example, development files, packaged builds, or additional information. This is only intended to be used in repositories where the module's output directory is cleaned, but tangential resources for the module want to remain intact. \ No newline at end of file diff --git a/src/ImageBuilder/test/Get-AzImageBuilderRunOutput.Recording.json b/src/ImageBuilder/test/Get-AzImageBuilderTemplateRunOutput.Recording.json similarity index 100% rename from src/ImageBuilder/test/Get-AzImageBuilderRunOutput.Recording.json rename to src/ImageBuilder/test/Get-AzImageBuilderTemplateRunOutput.Recording.json diff --git a/src/ImageBuilder/test/Get-AzImageBuilderRunOutput.Tests.ps1 b/src/ImageBuilder/test/Get-AzImageBuilderTemplateRunOutput.Tests.ps1 similarity index 99% rename from src/ImageBuilder/test/Get-AzImageBuilderRunOutput.Tests.ps1 rename to src/ImageBuilder/test/Get-AzImageBuilderTemplateRunOutput.Tests.ps1 index cc1c1ce469b1..17837916ee9d 100644 --- a/src/ImageBuilder/test/Get-AzImageBuilderRunOutput.Tests.ps1 +++ b/src/ImageBuilder/test/Get-AzImageBuilderTemplateRunOutput.Tests.ps1 @@ -27,4 +27,4 @@ Describe 'Get-AzImageBuilderRunOutput' { $result = Get-AzImageBuilderRunOutput -InputObject $object $result.Name | Should -Be $env.Resources.RunOutputName.runOutputName20 } -} +} \ No newline at end of file diff --git a/src/ImageBuilder/test/New-AzImageBuilderCustomizerObject.Tests.ps1 b/src/ImageBuilder/test/New-AzImageBuilderTemplateCustomizerObject.Tests.ps1 similarity index 100% rename from src/ImageBuilder/test/New-AzImageBuilderCustomizerObject.Tests.ps1 rename to src/ImageBuilder/test/New-AzImageBuilderTemplateCustomizerObject.Tests.ps1 diff --git a/src/ImageBuilder/test/New-AzImageBuilderDistributorObject.Tests.ps1 b/src/ImageBuilder/test/New-AzImageBuilderTemplateDistributorObject.Tests.ps1 similarity index 100% rename from src/ImageBuilder/test/New-AzImageBuilderDistributorObject.Tests.ps1 rename to src/ImageBuilder/test/New-AzImageBuilderTemplateDistributorObject.Tests.ps1 diff --git a/src/ImageBuilder/test/New-AzImageBuilderSourceObject.Tests.ps1 b/src/ImageBuilder/test/New-AzImageBuilderTemplateSourceObject.Tests.ps1 similarity index 100% rename from src/ImageBuilder/test/New-AzImageBuilderSourceObject.Tests.ps1 rename to src/ImageBuilder/test/New-AzImageBuilderTemplateSourceObject.Tests.ps1 diff --git a/src/ImageBuilder/test/New-AzImageBuilderTemplateValidatorObject.Tests.ps1 b/src/ImageBuilder/test/New-AzImageBuilderTemplateValidatorObject.Tests.ps1 new file mode 100644 index 000000000000..1d55b4e6a63c --- /dev/null +++ b/src/ImageBuilder/test/New-AzImageBuilderTemplateValidatorObject.Tests.ps1 @@ -0,0 +1,25 @@ +if(($null -eq $TestName) -or ($TestName -contains 'New-AzImageBuilderTemplateValidatorObject')) +{ + $loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' + if (-Not (Test-Path -Path $loadEnvPath)) { + $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' + } + . ($loadEnvPath) + $TestRecordingFile = Join-Path $PSScriptRoot 'New-AzImageBuilderTemplateValidatorObject.Recording.json' + $currentPath = $PSScriptRoot + while(-not $mockingPath) { + $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File + $currentPath = Split-Path -Path $currentPath -Parent + } + . ($mockingPath | Select-Object -First 1).FullName +} + +Describe 'New-AzImageBuilderTemplateValidatorObject' { + It 'PowerShellValidator' -skip { + { throw [System.NotImplementedException] } | Should -Not -Throw + } + + It 'ShellValidator' -skip { + { throw [System.NotImplementedException] } | Should -Not -Throw + } +} diff --git a/src/ImageBuilder/test/NewSourceObjectFromJsonObject.Tests.ps1 b/src/ImageBuilder/test/NewSourceObjectFromJsonObject.Tests.ps1 deleted file mode 100644 index 5f5df95a73a8..000000000000 --- a/src/ImageBuilder/test/NewSourceObjectFromJsonObject.Tests.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1' -if (-Not (Test-Path -Path $loadEnvPath)) { - $loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1' -} -. ($loadEnvPath) -$TestRecordingFile = Join-Path $PSScriptRoot 'NewSourceObjectFromJsonObject.Recording.json' -$currentPath = $PSScriptRoot -while(-not $mockingPath) { - $mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File - $currentPath = Split-Path -Path $currentPath -Parent -} -. ($mockingPath | Select-Object -First 1).FullName - -Describe 'NewSourceObjectFromJsonObject' { - It '__AllParameterSets' -skip { - { throw [System.NotImplementedException] } | Should -Not -Throw - } -} diff --git a/src/ImageBuilder/test/loadEnv.ps1 b/src/ImageBuilder/test/loadEnv.ps1 index c4ebf2e8310c..5f079e89615e 100644 --- a/src/ImageBuilder/test/loadEnv.ps1 +++ b/src/ImageBuilder/test/loadEnv.ps1 @@ -1,6 +1,5 @@ # ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation +# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -10,6 +9,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code +# is regenerated. # ---------------------------------------------------------------------------------- $envFile = 'env.json' if ($TestMode -eq 'live') { diff --git a/src/ImageBuilder/utils/Unprotect-SecureString.ps1 b/src/ImageBuilder/utils/Unprotect-SecureString.ps1 new file mode 100644 index 000000000000..cb05b51a6220 --- /dev/null +++ b/src/ImageBuilder/utils/Unprotect-SecureString.ps1 @@ -0,0 +1,16 @@ +#This script converts securestring to plaintext + +param( + [Parameter(Mandatory, ValueFromPipeline)] + [System.Security.SecureString] + ${SecureString} +) + +$ssPtr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString) +try { + $plaintext = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($ssPtr) +} finally { + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ssPtr) +} + +return $plaintext \ No newline at end of file