Skip to content

Indexed parameters

The Proxmox VE API has parameters that exist once per device: net0, net1, scsi0, scsi1, ipconfig0. In the client each family is one argument, named with an N at the end, of type IDictionary<int, string>: the key is the index, the value is the configuration string that Proxmox VE expects.

var networks = new Dictionary<int, string>
{
[0] = "model=virtio,bridge=vmbr0,firewall=1", // net0
[1] = "model=virtio,bridge=vmbr1,tag=100", // net1
};
var result = await client.Nodes["pve01"].Qemu[100].Config.UpdateVm(netN: networks);

Only the indexes in the dictionary are sent: the call above leaves net2 as it is. The value of an index replaces the whole device: when you change an existing network device keep its macaddr, or Proxmox VE generates a new one. The most used families:

Argument Sent as For
netN net0, net1, … Network devices of VMs and containers
scsiN, virtioN, sataN, ideN scsi0, virtio0, … Disks and CD-ROM drives of VMs
ipconfigN ipconfig0, … Cloud-init IP configuration of VMs
hostpciN, usbN hostpci0, usb0, … Passthrough of host devices
mpN mp0, mp1, … Mount points of containers

The format of each value is in the description of the parameter in the API viewer, and in the pages of the Proxmox VE administration guide linked below. The client does not check the string: Proxmox VE does, and a wrong one gives status 400 with the reason in GetError().

model=<model>,bridge=<bridge> followed by options, as described in Network Device.

Option Meaning Example
model Emulated card virtio, e1000, vmxnet3
bridge Bridge of the node to attach to vmbr0
tag VLAN tag tag=100
firewall Apply the Proxmox VE firewall firewall=1
macaddr MAC address, generated when left out macaddr=BC:24:11:00:00:01
rate Rate limit in MB/s rate=100
mtu MTU, virtio only mtu=9000
queues Multiqueue, virtio only queues=4
link_down Create the device disconnected link_down=1

To create a new disk give the storage and the size in GiB: <storage>:<size>. To attach an existing volume give its id: <storage>:<volume>. Options follow, as described in Hard Disk.

var result = await client.Nodes["pve01"].Qemu[100].Config.UpdateVm(
scsiN: new Dictionary<int, string>
{
[0] = "local-lvm:32,discard=on,iothread=1", // new 32 GiB disk
[1] = "local-lvm:100,backup=0", // new 100 GiB disk, left out of backups
},
ideN: new Dictionary<int, string>
{
[2] = "local:iso/debian-13.1.0-amd64-netinst.iso,media=cdrom",
});
Bus Indexes Notes
scsiN 0 to 30 The usual choice, with scsihw: "virtio-scsi-single"
virtioN 0 to 15 VirtIO block
sataN 0 to 5
ideN 0 to 3 Mostly CD-ROM drives
Option Meaning Values
cache Cache mode none, writethrough, writeback, directsync, unsafe
discard Pass TRIM to the storage on, ignore
iothread Dedicated I/O thread 0, 1
ssd Present the disk as SSD 0, 1
backup Include the disk in backups 0, 1
media Kind of drive disk, cdrom

The EFI disk and the TPM state exist only once, so they are plain string arguments, efidisk0 and tpmstate0:

var result = await client.Nodes["pve01"].Qemu[100].Config.UpdateVm(
bios: "ovmf",
efidisk0: "local-lvm:1,efitype=4m,pre-enrolled-keys=1");

ipconfigN configures the network device with the same index: ipconfig0 is for net0. See Cloud-Init Support.

var result = await client.Nodes["pve01"].Qemu[100].Config.UpdateVm(
ciuser: "admin",
sshkeys: Uri.EscapeDataString(publicKey),
ipconfigN: new Dictionary<int, string>
{
[0] = "ip=192.168.1.100/24,gw=192.168.1.1", // static
[1] = "ip=dhcp", // DHCP
});

The API wants sshkeys URL-encoded: encode it yourself, as above.

Containers use the same pattern with their own formats: netN carries name, bridge and addresses, mpN a volume and its path in the container.

var result = await client.Nodes["pve01"].Lxc[200].Config.UpdateVm(
netN: new Dictionary<int, string>
{
[0] = "name=eth0,bridge=vmbr0,ip=dhcp",
},
mpN: new Dictionary<int, string>
{
[0] = "local-lvm:8,mp=/var/lib/data", // new 8 GiB volume mounted at /var/lib/data
});

With raw calls there is no dictionary: use the names of the API, net0, scsi1. PveClientBase.AddIndexedParameter adds the entries of a dictionary to the parameters with those names:

var parameters = new Dictionary<string, object> { ["memory"] = 4096 };
PveClientBase.AddIndexedParameter(parameters, "net", networks);
var result = await client.SetAsync("/nodes/pve01/qemu/100/config", parameters);

A complete VM, from nothing to started, is in Create a VM.