The azure cli tool is used to do this publication. To install it follow below. For further questions see Azure CLI Install
# add ~/bin and add it to path
mkdir -p ~/bin/
[ "${PATH#*$HOME/bin}" = "$PATH" ] || PATH=$HOME/bin:$PATH
# install npm
sudo apt --quiet update
sudo apt --quiet --assume-yes install npm nodejs-legacy </dev/null
mkdir azure
( cd azure && npm install azure-cli ) </dev/null
ln -s $PWD/azure/node_modules/azure-cli/bin/azure ~/bin/
# avoid a prompt about enabling data collection
azure telemetry --disable
# enable bash completion
azure --completion >> azure/completion.sh
echo source \"$PWD/azure/completion.sh\" >> ~/.profile
. azure/completion.sh
Now you have to get this client logged in. See 'cli connect' doc for more information.
azure login
# This prints an activation code and a link to https://aka.ms/devicelogin
# load that page in your browser, enter the activation code, hit enter.
# Various things require different 'subscriptions'. Just register
# for these now.
azure provider register Microsoft.Storage
azure provider register Microsoft.Network
azure provider register Microsoft.Compute
Links:
We use the new (ASM) method here.
# install qemu utils to make a raw disk
sudo apt install --quiet --assume-yes qemu-utils cloud-image-utils </dev/null
# get a raw file
url=http://example.com/your/image.qcow
img=${url##*/}
img_raw=${img%.qcow2}.raw
img_vhd="${img_raw%.raw}.vhd"
wget "$url" -O "$img.dist"
qemu-img convert -O raw "$img" "$img_raw"
# quite possibly do not need intermediate raw but wanted to resize
qemu-img resize -f raw "${img_raw}" 8G
# see Notes below wrt fixed and force_size
qemu_ver=$(qemu-img --version | awk '{print $3}')
case "${qemu_ver}" in
2.[012345]*|1.*) subfmt="fixed";;
*) subfmt="fixed,force_size";; # anything 2.6+
esac
qemu-img convert -O vpc -o "subformat=${subfmt}" "$img_raw" "${img_vhd}"
# set up resource group and storage account
# resource groups and storage accounts are case insensitive. storage account
# complains that it has to be lower case on creation and 3-24 lower case or numeric.
# storage accounts are globally unique
rgroup="xx16resourcegroup"
stgaccount="xx16stgaccount"
container="xx16images"
location="westus"
azure group create "$rgroup" --location="$location"
azure storage account create "$stgaccount$location" "--resource-group=$rgroup" \
--location="$location" --kind Storage --sku-name PLRS
key1=$(azure storage account keys list "$stgaccount" "--resource-group=$rgroup" |
awk '$2 == "key1" { print $3 }' )
azure storage container create "--account-name=$stgaccount" \
"--account-key=$key1" "--container=$container"
# this took 10 minutes for me, from azure to azure (image is 8G). I was uploading
# from useast to uswest. Probably should launch in the location you publish to.
time azure storage blob upload --blobtype=page --account-name=$stgaccount \
--account-key=$key1 --container=$container "$img_vhd"
# you can later remove this with:
# azure storage blob delete --quiet \
# --account-name=$stgaccount --account-key=$key1 --container=$container "$img_vhd"
Notes:
-o subformat=fixed,force_size
from Information for Non-Endorsed Distributions. On qemu >= 2.6 you also needforce_size
# now to boot that thing
img_vhd=image.qcow
rgroup="xx16resourcegroup"
stgaccount="xx16stgaccount"
container="xx16images"
location="westus"
img_urn="https://${stgaccount}.blob.core.windows.net/${container}/${img_vhd}"
vmname=myvm2
time azure vm create --os-type=Linux \
--ssh-publickey-file=$HOME/.ssh/id_rsa.pub \
--admin-username=ubuntu --location=$location \
--resource-group=$rgroup --storage-account-name="$stgaccount" \
--image-urn="$img_urn" \
--nic-name=${vmname}-nic1 \
--vnet-name=${vmname}-vnet1 --vnet-address-prefix=192.168.77.0/24 \
--vnet-subnet-name=${vmname}-subnet1 \
--vnet-subnet-address-prefix=192.168.77.0/24 \
--public-ip-domain-name=${vmname} \
--public-ip-name=${vmname}-pubip1 \
$vmname
Note, the vm create command hangs for a crazy amount of time, while the machine is actually booting. I think it may hang waiting for system to identify itself fabric. So don't think that it has to come back to go looking further.
Get console output of a vm with:
azure vm get-serial-output $rgroup $vnname > out
Current state is that I believe the initramfs does not wait for block despite having been modified with 'rootdelay=300'. Here is a bootlog with debug=1. (http://paste.ubuntu.com/23427501/)