@@ -135,6 +135,9 @@ function Add-AzsVMImage {
135135 [Parameter (ParameterSetName = ' VMImageFromAzure' )]
136136 [bool ] $CreateGalleryItem = $true ,
137137
138+ [Parameter (ParameterSetName = ' VMImageFromLocal' )]
139+ [string ] $MarketPlaceZipPath = ' ' ,
140+
138141 [switch ] $Force
139142 )
140143
@@ -296,8 +299,8 @@ function Add-AzsVMImage {
296299 Set-AzureRmCurrentStorageAccount - StorageAccountName $storageAccountName - ResourceGroupName $resourceGroupName
297300 $container = Get-AzureStorageContainer - Name $containerName - ErrorAction SilentlyContinue
298301
299- if ($CreateGalleryItem -eq $true -And $platformImage.Properties.ProvisioningState -eq ' Succeeded' ) {
300- $GalleryItem = CreateGalleryItem - publisher $publisher - offer $offer - sku $sku - version $version - osType $osType - title $title - description $description
302+ if ($CreateGalleryItem -eq $true -And $platformImage.Properties.ProvisioningState -eq ' Succeeded' ) {
303+ $GalleryItem = CreateGalleryItem - publisher $publisher - offer $offer - sku $sku - version $version - osType $osType - title $title - description $description - MarketPlaceZipPath " $MarketPlaceZipPath "
301304 $null = $container | Set-AzureStorageBlobContent - File $GalleryItem.FullName - Blob $galleryItem.Name
302305 $galleryItemURI = ' {0}{1}/{2}' -f $storageAccount.PrimaryEndpoints.Blob.AbsoluteUri , $containerName , $galleryItem.Name
303306
@@ -472,8 +475,15 @@ function New-AzsServer2016VMImage {
472475 [Parameter ()]
473476 [bool ] $Net35 = $true ,
474477
478+
479+ [Parameter ()]
480+ [string ] $MarketPlaceZipPath ,
481+
482+
483+
475484 [Parameter ()][alias (' sku_version' )]
476485 [version ]$osImageSkuVersion = (date - Format yyyy.MM.dd).ToString()
486+
477487 )
478488 begin {
479489 function CreateWindowsVHD {
@@ -660,10 +670,10 @@ function New-AzsServer2016VMImage {
660670
661671 if ($CreateGalleryItem ) {
662672 $description = " This evaluation image should not be used for production workloads."
663- Add-AzsVMImage - sku $sku - osDiskLocalPath $ImagePath @PublishArguments - title " Windows Server 2016 Datacenter Core Eval" - description $description - CreateGalleryItem $CreateGalleryItem
673+ Add-AzsVMImage - sku $sku - osDiskLocalPath $ImagePath @PublishArguments - title " Windows Server 2016 Datacenter Core Eval" - description $description - CreateGalleryItem $CreateGalleryItem - MarketPlaceZipPath " $MarketPlaceZipPath "
664674 }
665675 else {
666- Add-AzsVMImage - sku $sku - osDiskLocalPath $ImagePath @PublishArguments - CreateGalleryItem $CreateGalleryItem
676+ Add-AzsVMImage - sku $sku - osDiskLocalPath $ImagePath @PublishArguments - CreateGalleryItem $CreateGalleryItem - MarketPlaceZipPath " $MarketPlaceZipPath "
667677 }
668678 }
669679 catch {
@@ -693,11 +703,11 @@ function New-AzsServer2016VMImage {
693703 Write-Verbose - Message " Server Full VHD already found."
694704 }
695705 if ($CreateGalleryItem ) {
696- $description = " This evaluation image should not be used for production workloads."
697- Add-AzsVMImage - sku $sku - osDiskLocalPath $ImagePath @PublishArguments - title " Windows Server 2016 Datacenter Eval" - description $description - CreateGalleryItem $CreateGalleryItem
706+ $description = " This evaluation image should not be used for production workloads."
707+ Add-AzsVMImage - sku $sku - osDiskLocalPath $ImagePath @PublishArguments - title " Windows Server 2016 Datacenter Eval" - description $description - CreateGalleryItem $CreateGalleryItem - MarketPlaceZipPath " $MarketPlaceZipPath "
698708 }
699- else {
700- Add-AzsVMImage - sku $sku - osDiskLocalPath $ImagePath @PublishArguments - CreateGalleryItem $CreateGalleryItem
709+ else {
710+ Add-AzsVMImage - sku $sku - osDiskLocalPath $ImagePath @PublishArguments - CreateGalleryItem $CreateGalleryItem - MarketPlaceZipPath " $MarketPlaceZipPath "
701711 }
702712 }
703713 catch {
@@ -732,7 +742,9 @@ Function CreateGalleryItem {
732742
733743 [string ] $Title ,
734744
735- [string ] $Description
745+ [string ] $Description ,
746+
747+ [string ] $MarketPlaceZipPath = ' '
736748 )
737749 $workdir = ' {0}{1}' -f [System.IO.Path ]::GetTempPath(), [System.Guid ]::NewGuid().ToString()
738750 New-Item $workdir - ItemType Directory | Out-Null
@@ -743,18 +755,46 @@ Function CreateGalleryItem {
743755 New-Item - ItemType directory - Path $extractedGalleryItemPath | Out-Null
744756 expand-archive - Path " $workdir \CustomizedVMGalleryItem.zip" - DestinationPath $extractedGalleryItemPath - Force
745757
746- $maxAttempts = 5
747- for ($retryAttempts = 1 ; $retryAttempts -le $maxAttempts ; $retryAttempts ++ ) {
748- try {
749- Write-Verbose - Message " Downloading Azure Stack Marketplace Item Generator Attempt $retryAttempts "
750- Invoke-WebRequest - Uri http:// www.aka.ms/ azurestackmarketplaceitem - OutFile " $workdir \MarketplaceItem.zip"
751- break
758+
759+ # Check if we were provided with the MarketPlace Item Generator File
760+ if ( $MarketPlaceZipPath -eq ' ' )
761+ {
762+
763+ $maxAttempts = 5
764+ for ($retryAttempts = 1 ; $retryAttempts -le $maxAttempts ; $retryAttempts ++ ) {
765+ try {
766+ Write-Verbose - Message " Downloading Azure Stack Marketplace Item Generator Attempt $retryAttempts " - Verbose
767+ Invoke-WebRequest - Uri http:// www.aka.ms/ azurestackmarketplaceitem - OutFile " $workdir \MarketplaceItem.zip"
768+ break
769+ }
770+ catch {
771+ if ($retryAttempts -ge $maxAttempts ) {
772+ Write-Error " Failed to download Azure Stack Marketplace Item Generator" - ErrorAction Stop
773+ }
774+ }
775+
752776 }
753- catch {
754- if ($retryAttempts -ge $maxAttempts ) {
755- Write-Error " Failed to download Azure Stack Marketplace Item Generator" - ErrorAction Stop
777+ }
778+ else
779+ {
780+ write-verbose - Message " Copying Marketplace Item Generator to working directory" - Verbose
781+
782+ # Copy the provided file into the working directory
783+ if ( Test-Path - Path " $MarketPlaceZipPath " )
784+ {
785+ try {
786+ Write-Verbose - Message " Copying Market Place Item Generator zip file into working directory" - Verbose
787+ copy-item - Path " $MarketPlaceZipPath " - Destination " $workdir \MarketplaceItem.zip"
788+ }
789+ catch
790+ {
791+ Write-Error " Failed to copy Market Place Item Generator zip into working directory: $_ " - ErrorAction Stop
756792 }
757793 }
794+ else
795+ {
796+ Write-Error " Provided Market Place Item Generator zip file does not exist" - ErrorAction Stop
797+ }
758798 }
759799
760800 Expand-Archive - Path " $workdir \MarketplaceItem.zip" - DestinationPath $workdir - Force
0 commit comments