@@ -135,6 +135,9 @@ function Add-AzsVMImage {
135
135
[Parameter (ParameterSetName = ' VMImageFromAzure' )]
136
136
[bool ] $CreateGalleryItem = $true ,
137
137
138
+ [Parameter (ParameterSetName = ' VMImageFromLocal' )]
139
+ [string ] $MarketPlaceZipPath = ' ' ,
140
+
138
141
[switch ] $Force
139
142
)
140
143
@@ -296,8 +299,8 @@ function Add-AzsVMImage {
296
299
Set-AzureRmCurrentStorageAccount - StorageAccountName $storageAccountName - ResourceGroupName $resourceGroupName
297
300
$container = Get-AzureStorageContainer - Name $containerName - ErrorAction SilentlyContinue
298
301
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 "
301
304
$null = $container | Set-AzureStorageBlobContent - File $GalleryItem.FullName - Blob $galleryItem.Name
302
305
$galleryItemURI = ' {0}{1}/{2}' -f $storageAccount.PrimaryEndpoints.Blob.AbsoluteUri , $containerName , $galleryItem.Name
303
306
@@ -472,8 +475,15 @@ function New-AzsServer2016VMImage {
472
475
[Parameter ()]
473
476
[bool ] $Net35 = $true ,
474
477
478
+
479
+ [Parameter ()]
480
+ [string ] $MarketPlaceZipPath ,
481
+
482
+
483
+
475
484
[Parameter ()][alias (' sku_version' )]
476
485
[version ]$osImageSkuVersion = (date - Format yyyy.MM.dd).ToString()
486
+
477
487
)
478
488
begin {
479
489
function CreateWindowsVHD {
@@ -660,10 +670,10 @@ function New-AzsServer2016VMImage {
660
670
661
671
if ($CreateGalleryItem ) {
662
672
$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 "
664
674
}
665
675
else {
666
- Add-AzsVMImage - sku $sku - osDiskLocalPath $ImagePath @PublishArguments - CreateGalleryItem $CreateGalleryItem
676
+ Add-AzsVMImage - sku $sku - osDiskLocalPath $ImagePath @PublishArguments - CreateGalleryItem $CreateGalleryItem - MarketPlaceZipPath " $MarketPlaceZipPath "
667
677
}
668
678
}
669
679
catch {
@@ -693,11 +703,11 @@ function New-AzsServer2016VMImage {
693
703
Write-Verbose - Message " Server Full VHD already found."
694
704
}
695
705
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 "
698
708
}
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 "
701
711
}
702
712
}
703
713
catch {
@@ -732,7 +742,9 @@ Function CreateGalleryItem {
732
742
733
743
[string ] $Title ,
734
744
735
- [string ] $Description
745
+ [string ] $Description ,
746
+
747
+ [string ] $MarketPlaceZipPath = ' '
736
748
)
737
749
$workdir = ' {0}{1}' -f [System.IO.Path ]::GetTempPath(), [System.Guid ]::NewGuid().ToString()
738
750
New-Item $workdir - ItemType Directory | Out-Null
@@ -743,18 +755,46 @@ Function CreateGalleryItem {
743
755
New-Item - ItemType directory - Path $extractedGalleryItemPath | Out-Null
744
756
expand-archive - Path " $workdir \CustomizedVMGalleryItem.zip" - DestinationPath $extractedGalleryItemPath - Force
745
757
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
+
752
776
}
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
756
792
}
757
793
}
794
+ else
795
+ {
796
+ Write-Error " Provided Market Place Item Generator zip file does not exist" - ErrorAction Stop
797
+ }
758
798
}
759
799
760
800
Expand-Archive - Path " $workdir \MarketplaceItem.zip" - DestinationPath $workdir - Force
0 commit comments