5 image_nix
="${1:-"./examples/basic/image.nix"}"
7 nix-build
"${image_nix}" --out-link "azure"
11 img_name
="nixos-image"
12 img_file
="$(readlink -f ./azure/disk.vhd)"
14 if ! az group show
-n "${group}" &>/dev
/null
; then
15 az group create
--name "${group}" --location "${location}"
18 # note: the disk access token song/dance is tedious
19 # but allows us to upload direct to a disk image
20 # thereby avoid storage accounts (and naming them) entirely!
21 if ! az disk show
-g "${group}" -n "${img_name}" &>/dev
/null
; then
22 bytes
="$(stat -c %s ${img_file})"
25 --resource-group "${group}" \
26 --name "${img_name}" \
27 --for-upload true
--upload-size-bytes "${bytes}"
29 timeout
=$
(( 60 * 60 )) # disk access token timeout
31 az disk grant-access \
32 --access-level Write \
33 --resource-group "${group}" \
34 --name "${img_name}" \
35 --duration-in-seconds ${timeout} \
39 azcopy copy
"${img_file}" "${sasurl}" \
42 az disk revoke-access \
43 --resource-group "${group}" \
47 if ! az image show
-g "${group}" -n "${img_name}" &>/dev
/null
; then
48 diskid
="$(az disk show -g "${group}" -n "${img_name}" -o json | jq -r .id)"
51 --resource-group "${group}" \
52 --name "${img_name}" \
53 --source "${diskid}" \
54 --os-type "linux" >/dev
/null
57 imageid
="$(az image show -g "${group}" -n "${img_name}" -o json | jq -r .id)"