We use octopus deploy for managing our environments. This uses agents (called tentacles) on the machines it controls. To get the correct configuration on an Azure VM created from an image I use a sysprep script.
The tentacle service can be configured from the commandline. Using the configuration wizard you can commit changes direct or generate a script. This script is commandline and can be run as a startup script. This is all well documented.
The trick of getting the script to run after provisioning is to add it to SetupComplete2.cmd in the C:\windows\OEM folder:
cd "C:\Program Files\Octopus Deploy\Tentacle" Tentacle.exe create-instance --instance="Tentacle" --config="C:\Octopus\Tentacle\Tentacle.config" Tentacle.exe new-certificate --instance="Tentacle" --if-blank Tentacle.exe configure --instance="Tentacle" --home="C:\Octopus" --app="C:\Octopus\Applications" Tentacle.exe register-with --instance "Tentacle" --server "http://MY-OCTOPUS" --apiKey="APIKEY" --role "web-server" --environment "Test" --comms-style TentacleActive Tentacle.exe service --instance="Tentacle" --install --start
When loadbalancing the machines you should use the Tentacle in polling mode as there is no way to target a machine directly when it is behind a loadbalancer. In the script above that is what TentacleActive(line 6) does.
Now do the sysprep and image capture as described in the windowsazure documentation. When you create a new VM based on this image it will register with the Octopusdeploy server after it is done provisioning.
Important: uncheck the install vm agent when creating the vm you’re going to image. When the base image contains the vm agent and you leave the (default) option checked creating a new vm, that new vm remains in the running (provisioning) state for ages. Not installing the vm agent in your base image will prevent you from making that mistake.