Deploy Clavister NetWall in Azure with the Azure CLI

Last modified on 24 Nov, 2026. Revision 3


Overview

At the end you have one firewall in Azure with a public IP. You manage it with the Web Interface and SSH, only from your own IP address. It does not forward any traffic yet, and it runs without a license until you install one.

The work in short:

  • Convert the cOS Core image to a VHD file and upload it to Azure (steps 2 to 4).
  • Make a snapshot (a copy of a disk) from the file. The snapshot is the template for your firewalls (step 5).
  • Make a disk from the snapshot and start the firewall from it as a virtual machine, a VM (steps 6 and 7).
  • Log in with the Azure Serial Console and set the password and management access (steps 8 and 9).
  • Open the network security group last, so the firewall can be reached (step 10).

Time: about 15 minutes when the tools are installed.

Cost: from step 7, Azure charges per hour for the VM, and for its disk and public IP. The snapshot costs a little. See the Azure pricing calculator for the prices in your region. The section Remove everything at the end deletes it all.

The example uses the Azure region swedencentral (Sweden Central), the cOS Core KVM image for x86_64, and a VM with 2 vCPU and 4 GB memory.

Requirements

The commands are for a Linux or macOS terminal. On Windows, run wsl --install in PowerShell as administrator, restart the computer and open Ubuntu from the Start menu. Install all tools below inside Ubuntu with the Linux instructions, and run all commands there. Your Windows Downloads folder is /mnt/c/Users/<your Windows user>/Downloads in Ubuntu.

  • An Azure subscription where you have the role Owner or Contributor. If you created the subscription yourself, you are Owner.
  • Azure CLI version 2.60 or later, installed as described in How to install the Azure CLI. Check the version with az version.
  • qemu-img to convert the image:
    • Debian or Ubuntu: sudo apt install qemu-utils
    • RHEL or Fedora: sudo dnf install qemu-img
    • macOS: brew install qemu
  • The cOS Core KVM image for x86_64 from MyClavister. If the download is a zip file, unpack it. The image file name ends with -kvm-x86_64-bios-en.qcow2.
  • openssl, curl and an SSH client. Most Linux and macOS systems have them. If not, install them like qemu-img, for example sudo apt install openssl curl openssh-client.
  • About 2 GB of free disk space.

How to use the commands

  • The Azure CLI is the az command in your own terminal. Do not use Cloud Shell in the Azure portal, because the image file is on your computer.
  • Copy each command block as a whole. A line that ends with a backslash (\) continues on the next line. If a block has a value that you must change, paste it into a text editor first, change it, and then copy it to the terminal.
  • You type firewall commands only after you log in to the firewall: in steps 8 and 9, after ssh in step 11, and in If your own IP changes. The firewall prompt is Device:/>. All other commands run in your own terminal.
  • A line like RG=... saves a value in a shell variable. Later commands use it as $RG. Variables only exist in the terminal window where you set them, so use the same window for all steps. If you close it, see If you closed the terminal at the end.
  • Check a variable with echo, for example echo $RG. If it shows nothing, the value is not set. Run the command before it again and check its output before you go on.
  • If a command shows an error, fix it before you go on.
  • On a phone, swipe a command block sideways to see the end of long lines.

How to set this up

Steps 1 to 5 prepare the snapshot. You do them one time. Steps 6 to 12 start and set up one firewall.

Step 1 - Log in to Azure

az login

Your browser opens. Log in the same way as to the Azure portal, then go back to the terminal. The CLI lists your subscriptions. Type the number of the subscription to use, or press Enter to keep the one marked with *.

If no browser opens, for example in WSL, use this command instead:

az login --use-device-code

It shows a URL and a code. Open the URL in a browser, type the code and log in.

Check the login:

az account show --query "{subscription:name, user:user.name}" --output table

You see the name of the subscription and your user name. To use another subscription, run az account set --subscription "<subscription name>".

Step 2 - Set variables

Go to the folder with the image file, for example cd /mnt/c/Users/<your Windows user>/Downloads in WSL. Show the exact file name with ls *.qcow2.

In the block below, replace the IMAGE value with your file name, without .qcow2. Then run it.

LOCATION=swedencentral
RG=clavister-fw
IMAGE=clavister-cos-core-15.00.07.05-kvm-x86_64-bios-en
STORAGE=clavister$(openssl rand -hex 4)
echo $LOCATION $RG $IMAGE $STORAGE

The last line shows all four values. What the lines do:

  • LOCATION is the Azure region. To see the names of all regions, run az account list-locations --output table.
  • RG is the name of the resource group. A resource group is a folder in Azure that holds everything this guide creates. At the end you can delete it all in one step.
  • IMAGE saves the image name, so later commands can use $IMAGE.
  • STORAGE is the name of the storage account for the upload, for example clavister3f9a1c2e. $(...) runs a command and uses its output. Here it adds 8 random characters, because the name must be unique in all of Azure.

Step 3 - Convert the image to VHD

Azure uses disk images in the VHD format, with a fixed size. vpc is the name that qemu-img uses for VHD.

qemu-img convert -f qcow2 -O vpc -o subformat=fixed,force_size $IMAGE.qcow2 $IMAGE.vhd

The command prints nothing when it works. Check the new file with ls -lh $IMAGE.vhd. It is about 1 GB. If qemu-img says that it cannot open the file, the IMAGE value or the folder is wrong. See step 2.

Step 4 - Upload the image

A storage account is file storage in Azure, and a container is a folder in it. A disk file must be uploaded as a page blob (--type page).

az group create --name $RG --location $LOCATION --output none
az storage account create --resource-group $RG --name $STORAGE \
  --location $LOCATION --sku Standard_LRS --allow-blob-public-access false --output none
KEY=$(az storage account keys list --resource-group $RG --account-name $STORAGE \
  --query "[0].value" --output tsv)
az storage container create --account-name $STORAGE --account-key $KEY \
  --name vhds --output none
az storage blob upload --account-name $STORAGE --account-key $KEY --container-name vhds \
  --name $IMAGE.vhd --file $IMAGE.vhd --type page --output none

The storage account takes about 30 seconds. The upload shows the progress and ends with Finished. KEY is the access key of the storage account. It works like a password, so do not share it.

Step 5 - Create the snapshot

The snapshot is the template that you make a disk from for each firewall. Azure has two VM types: Generation 1 VMs start with BIOS, and Generation 2 VMs start with UEFI. This image needs Generation 1, so the command uses --hyper-v-generation V1.

STORAGE_ID=$(az storage account show --resource-group $RG --name $STORAGE \
  --query id --output tsv)
az snapshot create --resource-group $RG --name $IMAGE \
  --source https://$STORAGE.blob.core.windows.net/vhds/$IMAGE.vhd \
  --source-storage-account-id $STORAGE_ID --hyper-v-generation V1 \
  --sku Standard_LRS --query provisioningState --output tsv

You should see Succeeded.

The snapshot is a separate copy, so the storage account is not needed any more. Delete it, so it does not cost money:

az storage account delete --resource-group $RG --name $STORAGE --yes

Step 6 - Choose the VM size

Use Standard_F2s_v2. It has 2 vCPU, 4 GB memory and fixed CPU performance.

TYPE=Standard_F2s_v2

cOS Core uses one vCPU to poll the network all the time, so Azure shows about 50% CPU also without traffic. This is normal.

For another size, see How many vCPUs and how much memory do the different NetWall Virtual Appliances support? The size must support Generation 1 VMs. The Microsoft page for each size lists this. Many new sizes support only Generation 2.

Step 7 - Start the firewall

az disk create --resource-group $RG --name clavister-fw-disk --source $IMAGE \
  --sku StandardSSD_LRS --output none
PUBLIC_IP=$(az vm create --resource-group $RG --name clavister-fw \
  --attach-os-disk clavister-fw-disk --os-type linux --size $TYPE \
  --public-ip-sku Standard --nsg-rule NONE --accelerated-networking false \
  --query publicIpAddress --output tsv)
az vm boot-diagnostics enable --resource-group $RG --name clavister-fw
echo $PUBLIC_IP

az vm create shows a warning about Azure Trusted Launch. You can ignore it. Trusted Launch is only for Generation 2 VMs.

The last line shows the public IP of the firewall. Write it down. From now on Azure charges per hour for the VM. If az vm create answers that the quota is too low, see Not enough quota in Good to know.

What the commands do:

  • az disk create makes the disk of the firewall from the snapshot of step 5. The snapshot has the same name as the image, so --source $IMAGE means the snapshot.
  • --attach-os-disk starts the VM from the disk as it is. Azure does not try to set up a user or a password in it.
  • --os-type linux: Azure needs an OS type, and linux is right for cOS Core.
  • az vm create also makes a virtual network, a network interface and a public IP for the VM.
  • --nsg-rule NONE creates a network security group (NSG) called clavister-fwNSG without any rules. An NSG is the Azure packet filter in front of the VM. Without rules, it blocks all traffic from the internet.
  • --accelerated-networking false gives the VM the standard Azure network interface, which cOS Core uses.
  • boot-diagnostics enable turns on the serial console for the VM.

The first start takes about 1 minute.

Step 8 - Log in on the serial console

At the first start, the firewall has the password admin and accepts management from any IP. The NSG blocks all traffic from the internet, so nobody can reach the firewall yet. Do not open the NSG before you have finished step 9. Until step 10 you cannot reach the Web Interface. That is on purpose.

So the first setup uses the Azure Serial Console, which works like a console cable to the firewall.

First find your own public IP address and write it down. You type it in step 9.

curl https://ipv4.icanhazip.com

You can also open the same address in a browser.

Add the serial console to the Azure CLI (only needed one time):

az extension add --name serial-console

It says that only a preview version of serial-console exists, and installs it. That is fine.

After the next command, this terminal window shows the firewall console. You leave it at the end of step 9.

az serial-console connect --resource-group $RG --name clavister-fw

When you see Connected to the serial port of the VM, press Enter. If you see nothing, wait one minute and press Enter again.

The console first shows many lines from the start. They are normal for a new firewall in Azure:

  • the boot log, with one restart to update the boot loader
  • a note that there is no license yet (demo mode)
  • lines about Cloud init and 169.254.169.254 with response code 404. Azure has no start settings for the firewall, so it uses its default settings.

When the lines stop, you see Username:. Log in:

  • Username: admin
  • Password: admin

You now see the firewall CLI prompt Device:/>.

Step 9 - Secure management access

Type these commands in the firewall CLI (Device:/>). Type or paste one line at a time. A set or add command that works shows no message or a short confirmation. If you see an error, check the spelling and type the line again.

Set a new admin password. Replace YourNewStrongPassword with your own password. Use at least 15 characters and mix upper case, lower case, digits and special characters. Do not use double quotes in the password.

cc LocalUserDatabase AdminUsers
set User admin Password="YourNewStrongPassword"
cc

cc LocalUserDatabase AdminUsers opens the list of admin users, and the prompt changes to Device:/AdminUsers>. cc alone goes back to Device:/>.

Allow management only from your own public IP from step 8. If1 is the network interface of the firewall in Azure. HTTP_If1 and SSH_If1 are its default management rules: HTTP_If1 controls both HTTP and HTTPS to the Web Interface, and SSH_If1 controls SSH.

Replace 203.0.113.10 with your own IP. With the example IP, you cannot reach the firewall over the internet and must log in with the serial console again, as in step 8 but with your new password.

add Address IP4Address mgmt_admin Address=203.0.113.10
set RemoteManagement RemoteMgmtHTTP HTTP_If1 Network=mgmt_admin
set RemoteManagement RemoteMgmtSSH SSH_If1 Network=mgmt_admin

You can also use a network, for example Address=203.0.113.0/24.

Add a default route through the Azure gateway, so the firewall can reach the internet and you can reach the firewall:

set Interface Ethernet If1 AutoDefaultGatewayRoute=Yes

Save the changes with activate. Wait until the console shows this text:

Run the "commit" command to keep the new configuration.

Then type commit within 30 seconds. Without commit, the firewall goes back to the previous configuration by itself, which protects you if a change breaks your connection. If the 30 seconds pass without commit, type activate and commit again.

Check the routes with routes. You should see a 0.0.0.0/0 route.

Leave the console:

  • Type exit. You see Username: again. Without exit you stay logged in, and the next serial console connection does not ask for a password.
  • Press Ctrl+]. A small menu appears.
  • Press q. Do not press r, because it restarts the VM. You are back in your own terminal.
  • If Ctrl+] does not work on your keyboard, close the terminal window and open a new one, see If you closed the terminal.

Step 10 - Open the network security group

Do this only after step 9. Now it is safe: the firewall has a new password and accepts management only from your IP. The firewall does the filtering, so the NSG lets all traffic in and you keep only one set of rules.

Type this in your own terminal:

az network nsg rule create --resource-group $RG --nsg-name clavister-fwNSG \
  --name allow-all-firewall-filters --priority 100 --direction Inbound --access Allow \
  --protocol "*" --source-address-prefixes "*" --destination-port-ranges "*" \
  --query provisioningState --output tsv

You should see Succeeded.

Step 11 - Open the Web Interface

From the computer with the IP you allowed in step 9, open https:// and the public IP in a browser, for example https://198.51.100.10. Show the IP with echo $PUBLIC_IP.

The browser warns about the certificate, because the firewall uses a self-signed certificate at the start. Choose to continue to the site. Log in as admin with your new password.

If the page does not load, check that your own IP is still the same (step 8), and that you typed commit in step 9.

You can also use the CLI over SSH. Answer yes if SSH asks about the host key.

ssh admin@$PUBLIC_IP

After the login, the firewall says that it is in demo mode until you install a license (step 12). Type exit to leave.

The firewall does not forward any traffic until you add IP policies. This guide does not cover that. See the cOS Core Administration Guide.

Step 12 - Install a license

Without a license, cOS Core runs in demo mode. For 2 hours after each start it works fully, except for subscription services. After that, only management access works.

Register the license in MyClavister. There you get the ID and the license number.

Log in to the firewall CLI with SSH (step 11) and type, with your own ID and license number:

license -secaas_add <ID> <license number>

The firewall needs working DNS for this. It uses the DNS server that it gets from Azure with DHCP. The firewall downloads the license file and restarts after 30 seconds, so SSH closes. After about 1 minute you can log in again. license -show shows the license.

Good to know

The commands below use the variables from the steps above. In a new terminal, set them first, see If you closed the terminal.

The public IP stays the same. The public IP from step 7 is static. It stays when you stop and start the VM, until you delete it.

Change the VM size. Stop the VM, change the size and start it again. The public IP stays the same.

az vm deallocate --resource-group $RG --name clavister-fw
az vm resize --resource-group $RG --name clavister-fw --size Standard_F4s_v2 --output none
az vm start --resource-group $RG --name clavister-fw

deallocate stops the VM, and Azure does not charge for the VM while it is stopped. The disk and the public IP still cost a little.

If your own IP changes. You cannot manage the firewall from the new IP. Log in with the serial console as in step 8, but with admin and your new password from step 9. Then type the lines below, with your new IP. After activate, wait for the commit text before you type commit, as in step 9.

set Address IP4Address mgmt_admin Address=203.0.113.20
activate
commit

Not enough quota. A new subscription can have a low vCPU limit per VM size family. If az vm create answers that the quota is too low, ask Azure for a higher limit for the family Standard FSv2 Family vCPUs in the Azure portal under Quotas. Check your limits with az vm list-usage --location $LOCATION --output table.

Start one more firewall. Run step 7 again from the same snapshot, with other names for the disk and the VM, for example clavister-fw2-disk and clavister-fw2. Use the new VM name also in steps 8 and 10. The NSG then gets the name clavister-fw2NSG.

Route traffic for other servers. To route other servers in Azure through the firewall, you need more than this guide covers, for example a second network interface and Azure route tables. One of the steps is to turn on IP forwarding on the network interface of the firewall:

az network nic update --resource-group $RG --name clavister-fwVMNic --ip-forwarding true

If you closed the terminal

The variables are gone in a new terminal. Go back to the folder with the image file with cd, and set the variables again. Use your own image name and region.

LOCATION=swedencentral
RG=clavister-fw
IMAGE=clavister-cos-core-15.00.07.05-kvm-x86_64-bios-en
TYPE=Standard_F2s_v2
PUBLIC_IP=$(az vm show --show-details --resource-group $RG --name clavister-fw \
  --query publicIps --output tsv)
echo $PUBLIC_IP

Before step 7, the PUBLIC_IP line shows that the VM is not found. That is fine.

If you closed the terminal before step 4, run step 2 again instead. If you closed it between step 4 and step 5, also set the storage account variables again:

STORAGE=$(az storage account list --resource-group $RG --query "[0].name" --output tsv)
KEY=$(az storage account keys list --resource-group $RG --account-name $STORAGE \
  --query "[0].value" --output tsv)

Remove everything

This deletes the firewall and everything else in the resource group: the VM, its disk, the public IP, the network, the NSG and the snapshot. It cannot be undone. In a new terminal, first set the variables, see If you closed the terminal.

az group delete --name $RG --yes

This takes 3 to 5 minutes. A progress indicator shows while it runs. Do not stop it. The command prints nothing when it is done.

Azure also creates a resource group called NetworkWatcherRG in some subscriptions. It is shared by all networks in the subscription and costs nothing. Leave it.

On your computer you can delete the .qcow2 and .vhd image files.