Skip to content

Instantly share code, notes, and snippets.

Last active October 5, 2019 00:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Installing PhantomOS on Azure, kinda
export RES_GROUP=photon
export AZURE_STORAGE_ACCOUNT=photonimages
export BLOB_NAME=photon3.vhd
export ADMIN_USERNAME=arschles
export VM_NAME=photon3
export LOCATION=eastus2
export PHOTON_VHD_PATH=photon3.vhd
set pipefail
set -eou
echo "Downloading Photon 3.0 from $DL_URL"
curl -L -o photon-3-0.tgz $DL_URL
echo "Unzipping Photon"
mkdir photon3-unzip
tar -xvzf photon3.tgz
echo "Creating new resource group $RES_GROUP in $LOCATION"
echo "If the group is already created, this will print a failure, but you can ignore it and move on :)"
az group create --name $RES_GROUP --location $LOCATION || true
# echo "Creating new storage account & container"
az storage account create -g $RES_GROUP --location eastus2 --name $AZURE_STORAGE_ACCOUNT --kind Storage --sku Standard_LRS
az storage container create -n $AZURE_STORAGE_CONTAINER_NAME --account-name $AZURE_STORAGE_ACCOUNT
# set these for the operations against containers and blobs
export AZURE_STORAGE_KEY=$(az storage account keys list -g $RES_GROUP --account-name $AZURE_STORAGE_ACCOUNT | jq -r '.[0].value')
echo "Uploading Photon VHD"
az storage blob upload \
--type page \
--name $BLOB_NAME
echo "Getting Photon VHD Image URL in Blob Storage"
# use jq -r to strip the leading and trailing quotes from this URL. az vm create
# won't work if you give it a URL with quotes around it womp womp
VHD_URL=$(az storage blob url -c $STORAGE_CONTAINER_NAME -n $BLOB_NAME | jq -r)
echo "The VHD is at $VHD_URL"
echo "Creating new Azure VM from public key at $SSH_PUBKEY_FILE with admin username $ADMIN_USERNAME"
az vm create \
--resource-group $RES_GROUP \
--location $LOCATION \
--name $VM_NAME \
--storage-account $STORAGE_ACCOUNT_NAME \
--os-type linux \
--admin-username $ADMIN_USERNAME \
--ssh-key-value $SSH_PUBKEY_FILE \
--image $VHD_URL \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment