Bug 1397271 - [Doc][RFE]: Specify steps to convert dynamic image to fixed size when uploading via Azure-CLI
Summary: [Doc][RFE]: Specify steps to convert dynamic image to fixed size when uploadi...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Documentation
Version: 5.6.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: GA
: cfme-future
Assignee: Suyog Sainkar
QA Contact: Red Hat CloudForms Documentation
URL:
Whiteboard: doc
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-11-22 06:29 UTC by Sachin
Modified: 2020-01-17 16:13 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-05-31 11:53:04 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:


Attachments (Terms of Use)

Description Sachin 2016-11-22 06:29:16 UTC
Description of problem:

In section 1.2.2 of the link[1], uploading dynamic size image does not work as Azure requires fixed size image. The process to convert dynamic VHD to fixed is documented on Mojo[2]. Is it possible to include content in Mojo[2] in official doc?

Version-Release number of selected component (if applicable):
CF-4.1


Additional info:

[1] https://access.redhat.com/documentation/en/red-hat-cloudforms/4.1/paged/installing-red-hat-cloudforms-on-microsoft-azure/

[2] https://mojo.redhat.com/docs/DOC-1089560


Document URL: 

Section Number and Name: 

Describe the issue: 

Suggestions for improvement: 

Additional information:

Comment 3 Jeff Teehan 2016-12-02 03:11:23 UTC
The statement regarding using powershell is incorrect.  I upload images every other build for a year.  Here is the powershell that doesn't require any pre-conversion to a Fixed type:

# Video Demo Script - Upload VHD to Azure
$myazurename = "MyAccount"
$myazurepwd = ConvertTo-SecureString "MyPassword" -AsPlainText -Force
$azcreds = New-Object System.Management.Automation.PSCredential ($myazurename, $myazurepwd)
Login-AzureRMAccount -Credential $azcreds
Get-AzureRmSubscription -SubscriptionId "MySubscriptionID" -TenantId "MyTenantID" | Select-AzureRmSubscription

$ResourceGroupName = "Automation"

$BlobLocation = "https://cfmeautopay.blob.core.windows.net/"
$BlobContainer = "templates"
$BlobName = "cfme-azure-5.7.0.9-1.x86_64.vhd"
$BlobDestination = $BlobLocation + $BlobContainer + "/" + $BlobName

$LocalFilePath = "C:\tmp\"
$LocalFileName = "cfme-azure-5.7.0.9-1.x86_64.vhd"
$LocalFile = $LocalFilePath + $LocalFileName

Add-AzureRmVhd -ResourceGroupName $ResourceGroupName -Destination $BlobDestination -LocalFilePath $LocalFile -NumberOfUploaderThreads 8

There is also a method I used to use which converted the VHD image to Fixed AND and exact multiple of megabytes.  It uses PowerShell to Fix the disk and the upload it, but it really isn't necessary (or fast) but is required it you wish to upload using the CLI:

$BlobLocation = "https://cfmeqe.blob.core.windows.net/"
$BlobContainer = "templates"
$BlobName = "cfme-azure-560"
$BlobDestination = $BlobLocation + $BlobContainer + "/" + $BlobName

$LocalFilePath = "C:\tmp\"
$SourceVHD = "cfme560-via-cli.vhd"
$LocalFileName = "cfme560-via-cli"
$LocalFile = $LocalFilePath + $LocalFileName + ".vhd"

Convert-VHD -Path 'c:\tmp\cfme560-via-cli.vhd'  -DestinationPath 'c:\tmp\cfme560-fixed' -VHDType Fixed
Resize-VHD -Path $LocalFile -SizeByte 44040192000
Add-AzureRmVhd -ResourceGroupName cfmeqe -Destination $BlobDestination -LocalFilePath $LocalFile -NumberOfUploaderThreads 8

And finally, upload by CLI:
azure storage blob upload -a cfmeqestore -k "mystoragekey" -t page --file 'C:\tmp\cfme560-fixed.vhd' --container 'templates' --blob 'cfme560-fixed'

Please let me know how I can help turn this into more useful documentation so that we can get everybody who is stuck back on track.

Comment 4 Jeff Teehan 2016-12-02 23:31:26 UTC
I stand corrected.  In classic mode there was an exact megabyte restriction.  For the last 14 months, resource mode has not enforced that.  However, I ran the same script today I've been using for quite some time and it failed with 

ErrorText           : {
                        "Details": [],
                        "InnerError": null,
                        "Code": "InvalidVhd",
                        "Message": "The VHD for disk 'cfme-azure-57013' with blob
                      https://cfmeautopay.blob.core.windows.net/vhds/cfme-azure-57013.vhd has an unsupported virtua
                      The size must be a whole number in (MBs).",
                        "Target": null
                      }

So, I'll have to rewrite the conversion/upload script and resubmit the comment.  Sorry for the confusion, but Azure does change things from time to time.

Comment 5 Jeff Teehan 2016-12-03 04:18:05 UTC
So, this is the answer.  You can convert with any tool you like.  I'm only showing powershell.  Then I used the CLI to upload it.

#Must have HyperV Enabled
#Must have installed Azure Powershell Modules

$myazurename = "MyAccount"
$myazurepwd = ConvertTo-SecureString "MyPassword" -AsPlainText -Force
$azcreds = New-Object System.Management.Automation.PSCredential ($myazurename, $myazurepwd)
Login-AzureRMAccount -Credential $azcreds
Get-AzureRmSubscription -SubscriptionId "MySubscription" -TenantId "MyTenantId" | Select-AzureRmSubscription

$ResourceGroupName = "MyResourceGropu"

$LocalFilePath = "C:\tmp\"
$LocalFileName = "cfme-azure-5.7.0.13-1.x86_64"
$LocalFile = $LocalFilePath + $LocalFileName + '.vhd'
$FixedFile = $LocalFilePath + $LocalFileName + '-f.vhd'

$BlobLocation = "https://cfmeautopay.blob.core.windows.net/"
$BlobContainer = "templates"
$BlobName = $LocalFile
$BlobDestination = $BlobLocation + $BlobContainer + "/" + $BlobName

Convert-VHD -Path $LocalFile  -DestinationPath $FixedFile -VHDType Fixed

# Resize just needs to be rounded up to the next whole exact megabyte
# http://www.whatsabyte.com/P1/byteconverter.htm
Resize-VHD -Path $FixedFile -SizeByte 44040192000

# Azure X-Plat CLI
azure storage blob upload -a cfmeautopay -k "MyStorageKey" -t page --file "c:\tmp\cfme-azure-5.7.0.13-1.x86_64-f.vhd" --container 'templates' --blob "cfme-azure-5.7.0.13-1.x86_64.vhd"


Note You need to log in before you can comment on or make changes to this bug.