@@ -700,17 +700,19 @@ function PreCheck
700700 }
701701 else
702702 {
703- Write-Error - Message " Property value for $property is null. Please check JSON contents, then retry import."
704- throw " JSON file contains null values for required properties."
703+ $errorMessage = " `r`n Property value for $property is null. Please check JSON contents, then retry import"
704+ $errorMessage += " `r`n JSON file contains null values for required properties: $ ( $properties ) "
705+ Write-Error - Message $errorMessage - ErrorAction Stop
705706 }
706707 }
707708
708709 $iconUris = $configuration.iconUris
709710
710711 if ($iconUris.small -eq $null -or $iconUris.large -eq $null -or $iconUris.medium -eq $null -or $iconUris.wide -eq $null )
711712 {
712- Write-Error - Message " Property value for certain Icons is null. Please check JSON contents, then retry import."
713- throw " JSON file contains null values for certain Icons. Please ensure small, medium, large and wide icons exist in the JSON."
713+ $errorMessage = " `r`n Property value for certain Icons is null. Please check JSON contents, then retry import."
714+ $errorMessage += " `r`n JSON file contains null values for certain Icons. Please ensure small, medium, large and wide icons exist in the JSON."
715+ Write-Error - Message $errorMessage - ErrorAction Stop
714716 }
715717 }
716718}
@@ -768,7 +770,7 @@ function Import-ByDependency
768770 {
769771 if ($_.Exception.Response.StatusCode -ne 404 )
770772 {
771- Write-Warning - Message " Failed to execute web request" - Exception $ _.Exception
773+ Write-Warning - Message " Failed to execute web request: Exception: $ ( $ _.Exception ) "
772774 }
773775 }
774776
@@ -839,7 +841,7 @@ function Test-AzSOfflineMarketplaceItem {
839841 {
840842 if ($_.Exception.Response.StatusCode -ne 404 )
841843 {
842- Write-Warning - Message " Failed to execute web request" - Exception $ _.Exception
844+ Write-Warning - Message " Failed to execute web request, Exception: `r`n $ ( $ _.Exception ) "
843845 }
844846 }
845847 }
@@ -903,7 +905,7 @@ function Resolve-ToLocalURI {
903905 # check osDiskImage
904906 if ($json.productDetailsProperties.OsDiskImage ) {
905907 $osDiskImageFile = Get-Item - path " $productFolder \*.vhd"
906- $osImageURI = Upload- ToStorage - filePath $osDiskImageFile.FullName - productid $productid - resourceGroup $resourceGroup
908+ $osImageURI = Upload- ToStorage - filePath $osDiskImageFile.FullName - productid $productid - resourceGroup $resourceGroup - blobType Page
907909 $json.productDetailsProperties.OsDiskImage.sourceBlobSasUri = $osImageURI
908910 }
909911
@@ -1040,6 +1042,8 @@ function Syndicate-Product {
10401042 properties = $properties
10411043 }
10421044
1045+ Write-Verbose - Message " properties : $ ( $json | ConvertTo-Json - Compress) " - Verbose
1046+
10431047 $syndicateResponse = InvokeWebRequest - Method PUT - Uri $syndicateUri - ArmEndpoint $armEndpoint - Headers ([ref ]$headers ) - Body $json - MaxRetry 2 - azsCredential $azsCredential
10441048
10451049 if ($syndicateResponse.StatusCode -eq 200 ) {
@@ -1058,7 +1062,11 @@ function Upload-ToStorage {
10581062 [String ] $productid ,
10591063
10601064 [parameter (mandatory = $true )]
1061- [String ] $resourceGroup
1065+ [String ] $resourceGroup ,
1066+
1067+ [Parameter (Mandatory = $false )]
1068+ [ValidateSet (' Page' , ' Block' )]
1069+ [String ] $blobType = " Block"
10621070 )
10631071
10641072 $syndicationStorageName = " syndicationstorage"
@@ -1099,6 +1107,7 @@ function Upload-ToStorage {
10991107 - Container $syndicationContainerName `
11001108 - Blob $blobName `
11011109 - Context $ctx `
1110+ - BlobType $blobType `
11021111 - Force | Out-Null
11031112
11041113 $fileURI = (Get-AzureStorageBlob - blob $blobName - Container $syndicationContainerName - Context $ctx ).ICloudBlob.Uri.AbsoluteUri
@@ -1246,16 +1255,16 @@ function InvokeWebRequest {
12461255 catch
12471256 {
12481257 if ($retryCount -ge $maxRetry ) {
1249- Write-Warning " Request to $method $uri failed the maximum number of $maxRetry times. Timestamp: $ ( $ (get-date ).ToString(' T' )) "
1258+ Write-Warning " Request to $method $uri failed the maximum number of $maxRetry times. Timestamp: $ ( (get-date ).ToString(' T' )) "
1259+ Write-Warning " Exception: `r`n $ ( $_.Exception ) "
12501260 throw
12511261 } else {
1252- $error = $_.Exception
12531262 if ($_.Exception.Response.StatusCode -eq 401 )
12541263 {
12551264 try {
12561265 if (! $azsCredential ) {
12571266 Write-Warning - Message " Access token expired."
1258- $azsCredential = Get-Credential - Message " Enter the azure stack operator credential"
1267+ $azsCredential = Get-Credential - Message " Enter the Azure Stack operator credential"
12591268 }
12601269 $endpoints = Get-ResourceManagerMetaDataEndpoints - ArmEndpoint $armEndpoint
12611270 $aadAuthorityEndpoint = $endpoints.authentication.loginEndpoint
@@ -1266,12 +1275,12 @@ function InvokeWebRequest {
12661275 }
12671276 catch
12681277 {
1269- Write-Warning " webrequest exception. `n $error "
1278+ Write-Warning " webrequest exception. `r`n $ ( $_ .Exception ) "
12701279 }
12711280 }
12721281
12731282 $retryCount ++
1274- Write-Debug " Request to $method $uri failed with status $error . ` n Retrying in $sleepSeconds seconds, retry count - $retryCount . Timestamp: $ ( $ (get-date ).ToString(' T' )) "
1283+ Write-Warning " Request to $method $uri failed with exception: `r`n $ ( $_ .Exception ) . `r` n Retrying in $sleepSeconds seconds, retry count - $retryCount . Timestamp: $ ( (get-date ).ToString(' T' )) "
12751284 Start-Sleep $sleepSeconds
12761285 }
12771286 }
0 commit comments