Use page blob for VHDs and minor fixes (#516)

* Fix warning message

* Use page blob for VHDs, and minor fixes

* Various small bug fixes

* Print properties instead of object
This commit is contained in:
sarathys 2019-08-03 12:48:54 -07:00 коммит произвёл GitHub
Родитель 495c884b60
Коммит a5a73e63cd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 22 добавлений и 13 удалений

Просмотреть файл

@ -700,8 +700,9 @@ function PreCheck
}
else
{
Write-Error -Message "Property value for $property is null. Please check JSON contents, then retry import."
throw "JSON file contains null values for required properties."
$errorMessage = "`r`nProperty value for $property is null. Please check JSON contents, then retry import"
$errorMessage += "`r`nJSON file contains null values for required properties: $($properties)"
Write-Error -Message $errorMessage -ErrorAction Stop
}
}
@ -709,8 +710,9 @@ function PreCheck
if ($iconUris.small -eq $null -or $iconUris.large -eq $null -or $iconUris.medium -eq $null -or $iconUris.wide -eq $null )
{
Write-Error -Message "Property value for certain Icons is null. Please check JSON contents, then retry import."
throw "JSON file contains null values for certain Icons. Please ensure small, medium, large and wide icons exist in the JSON."
$errorMessage = "`r`nProperty value for certain Icons is null. Please check JSON contents, then retry import."
$errorMessage += "`r`nJSON file contains null values for certain Icons. Please ensure small, medium, large and wide icons exist in the JSON."
Write-Error -Message $errorMessage -ErrorAction Stop
}
}
}
@ -768,7 +770,7 @@ function Import-ByDependency
{
if ($_.Exception.Response.StatusCode -ne 404)
{
Write-Warning -Message "Failed to execute web request" -Exception $_.Exception
Write-Warning -Message "Failed to execute web request: Exception: $($_.Exception)"
}
}
@ -839,7 +841,7 @@ function Test-AzSOfflineMarketplaceItem {
{
if ($_.Exception.Response.StatusCode -ne 404)
{
Write-Warning -Message "Failed to execute web request" -Exception $_.Exception
Write-Warning -Message "Failed to execute web request, Exception: `r`n$($_.Exception)"
}
}
}
@ -903,7 +905,7 @@ function Resolve-ToLocalURI {
# check osDiskImage
if ($json.productDetailsProperties.OsDiskImage) {
$osDiskImageFile = Get-Item -path "$productFolder\*.vhd"
$osImageURI = Upload-ToStorage -filePath $osDiskImageFile.FullName -productid $productid -resourceGroup $resourceGroup
$osImageURI = Upload-ToStorage -filePath $osDiskImageFile.FullName -productid $productid -resourceGroup $resourceGroup -blobType Page
$json.productDetailsProperties.OsDiskImage.sourceBlobSasUri = $osImageURI
}
@ -1040,6 +1042,8 @@ function Syndicate-Product {
properties = $properties
}
Write-Verbose -Message "properties : $($json | ConvertTo-Json -Compress)" -Verbose
$syndicateResponse = InvokeWebRequest -Method PUT -Uri $syndicateUri -ArmEndpoint $armEndpoint -Headers ([ref]$headers) -Body $json -MaxRetry 2 -azsCredential $azsCredential
if ($syndicateResponse.StatusCode -eq 200) {
@ -1058,7 +1062,11 @@ function Upload-ToStorage {
[String] $productid,
[parameter(mandatory = $true)]
[String] $resourceGroup
[String] $resourceGroup,
[Parameter(Mandatory = $false)]
[ValidateSet('Page', 'Block')]
[String] $blobType = "Block"
)
$syndicationStorageName = "syndicationstorage"
@ -1099,6 +1107,7 @@ function Upload-ToStorage {
-Container $syndicationContainerName `
-Blob $blobName `
-Context $ctx `
-BlobType $blobType `
-Force | Out-Null
$fileURI = (Get-AzureStorageBlob -blob $blobName -Container $syndicationContainerName -Context $ctx).ICloudBlob.Uri.AbsoluteUri
@ -1246,16 +1255,16 @@ function InvokeWebRequest {
catch
{
if ($retryCount -ge $maxRetry) {
Write-Warning "Request to $method $uri failed the maximum number of $maxRetry times. Timestamp: $($(get-date).ToString('T'))"
Write-Warning "Request to $method $uri failed the maximum number of $maxRetry times. Timestamp: $((get-date).ToString('T'))"
Write-Warning "Exception: `r`n$($_.Exception)"
throw
} else {
$error = $_.Exception
if ($_.Exception.Response.StatusCode -eq 401)
{
try {
if (!$azsCredential) {
Write-Warning -Message "Access token expired."
$azsCredential = Get-Credential -Message "Enter the azure stack operator credential"
$azsCredential = Get-Credential -Message "Enter the Azure Stack operator credential"
}
$endpoints = Get-ResourceManagerMetaDataEndpoints -ArmEndpoint $armEndpoint
$aadAuthorityEndpoint = $endpoints.authentication.loginEndpoint
@ -1266,12 +1275,12 @@ function InvokeWebRequest {
}
catch
{
Write-Warning "webrequest exception. `n$error"
Write-Warning "webrequest exception. `r`n$($_.Exception)"
}
}
$retryCount++
Write-Debug "Request to $method $uri failed with status $error. `nRetrying in $sleepSeconds seconds, retry count - $retryCount. Timestamp: $($(get-date).ToString('T'))"
Write-Warning "Request to $method $uri failed with exception: `r`n$($_.Exception). `r`nRetrying in $sleepSeconds seconds, retry count - $retryCount. Timestamp: $((get-date).ToString('T'))"
Start-Sleep $sleepSeconds
}
}