(See also HyperV)
Guidelines to install FreeBSD Virtual Machines in Microsoft Azure.
What is Azure?
Azure is Microsoft's cloud service. The main objective is to make it possible for any company building services on the Internet to develop their business and scale without making a huge initial investment. While Microsoft offers their own technologies, a big part of the world doesn't so they have full interest in supporting the alternative unix-ish technologies that make up the Internet today. Not unlike other cloud providers, from the point of view of a FreeBSD user, Azure is a "virtual" hardware provider: they have huge clusters around the world and without you worrying about disk failures or temperatures you make use of them for a fee.
Azure is constantly evolving and while you still find references to the "Classic" VMs, most services have been migrated to the Portal.
Where can I learn more about Azure?
How is FreeBSD supported?
Microsoft has invested in porting their virtualization support (Hyper-V) for FreeBSD. Starting with FreeBSD-10 support for Hyper-V is included in the main tree. Starting with version 10.3 and up to 12.0, Microsoft offers FreeBSD directly as a Virtual Machine option so you do not have to go through the process of building your own Virtual Machine. FreeBSD will be offering VMs directly in the near future.
What can I do with it?
There are many uses for a cloud machine. Initially you should keep in mind that you don't really get a superuser "root" account, but you rather end up administering the machine through sudo. This environment is ideal for using jails and delivering personalized services. Setting up a proxy with squid and privoxy in one jail and a webserver or a database in other jail works fine and saves resources hugely in a cheap VM. Some developers also set up a Poudriere server in an instance and only turn them on when needed.
What do I need?
* You need to have an account with the Microsoft Azure service: generally there are free trial accounts and if you are a MSDN subscriber you may already have access.
* You may want to use the Azure CLI. This is a Python application and you can install it from ports or packages on FreeBSD. Unless you want to automate things, most things are much easier to do through the portal though.
Creating your Virtual Machine
* Once you are in the portal look for the "Virtual Machines" blade and select the Add (+) button. this will bring you to "Create a virtual machine".
* For a FreeBSD image go to INSTANCE DETAILS and select "Browse all images and disks". This will take you to a new page where you can search for FreeBSD by name. Select the most recent version (currently 11.3 and 12.0) you can find. Please write a review when you get the chance: it helps other users to know how you find the service useful.
* Select carefully the size of the VM: while all sizes are likely to work well with FreeBSD, and the size depends on both the type of service and the your budget you want to be clever to get the most from your money. As a rule of thumb you want to check for IOPS and VCPUs. While you use SMP, and you might want at least two VCPUs with sufficient memory for your purposes, it may always be the case that you are just setting up an experimental site or you will have a very low load and with some of the smaller VMs you will get much better pricing.
* In INBOUND RULES select "Allow selected ports", this will allow you to use SSH to connect to the machine and configure services.
* Microsoft is rather conservative when updating VM images so it is likely you will not find the latest and greatest version of FreeBSD readily available you will have to do and initial update with FreeBSD-update(8). At least a simple, minor, update to the latest patchlevel is highly recommended for security. After rebooting, a pkg-upgrade(8) is also really a good idea.
* Once a minor update is done you will likely want to do a major update to the latest FreeBSD release. I highly recommend backing up your latest working configuration. Also, installing the tmux package and configuring your favorite text editor as a default are good ideas. If things go very wrong you may lose SSH access: in such cases the "Reset Remote Access" Option in the Virtual Machine home may be your saver.
* Do make sure you are using the latest azure-agent package, it should be using a recent version of python3. This is required for some of the basic services Azure offers.
Using an image from the VM Depot
This section is kept for reference: creating your VM through the Marketplace is the preferred option
Using an image from the VM depot used to be the best option before 10.3: Microsoft's Ross Gardler did an excellent tutorial .
If you still need this for some reason, some tricks to have in mind:
- Before transferring the image. You are likely to have to create a *classic* storage resource in your region. This is most easily done through the portal.
- You may have to go into the classic Azure-SwitchMode: azure config mode asm.
- Once up and running: freebsd-update(8) and pkg(8) upgrade are your friends.
Building your own image
Building your own image has the advantage of letting you do some initial customization with a virtualization engine. VirtualBox works fine with VHD images. The obvious disadvantage is that it will take some time to upload big images if you are in a slow network.
If you follow the tutorials from Microsoft employees keep some tricks in mind:
- You can build the image with a virtualization tool different that Microsoft's Hyper-V but you still will need the Azure CLI.
- There is actually no need to use wget on FreeBSD: You can use fetch(1) or even better, you will notice the python agent required by Azure is already in the ports tree so you can install it with pkg(8).
- Try to keep you images small so that uploading them won't take too long. Once uploaded, the networking is fast enough that you can use pkg(8).