Azure uses the VHD format. You can generate a VHD image as follows:
nix run github:nix-community/nixos-generators -- --format azure -c /etc/nixos/configuration.nix
The output will be a .vhd file, which you can upload to Azure as a managed disk or custom image.
You can specify a custom configuration with -c or use the default.
Uploading the VHD to Azure
# Upload to Azure Storage
az storage blob upload \
--account-name <storage-account> \
--container-name <container> \
--name nixos-custom.vhd \
--file ./result/nixos.vhd \
--type page
# Create a managed disk from the VHD
az disk create \
--resource-group <resource-group> \
--name nixos-disk \
--source https://<storage-account>.blob.core.windows.net/<container>/nixos-custom.vhd
# Create a VM from the managed disk
az vm create \
--resource-group <resource-group> \
--name nixos-vm \
--attach-os-disk nixos-disk \
--os-type linux
2. Generate a NixOS Image for QEMU
QEMU uses the qcow2 format. To generate a QEMU image:
nix run github:nix-community/nixos-generators -- --format qcow2 -c /etc/nixos/configuration.nix
The output will be a .qcow2 file, which you can use directly with QEMU or other virtualization tools.