Good day,
I am not sure if I fully understand your question.
can it be set to restart the VM automatically once the capacity is not needed.
Do you mean that when Azure does not needs the capacity you want to restart (stop and start the machine or do you mean to start the machine after eviction ? like you do in cases the CPU high to stop processes?
If you mean to stop and start then it should be clear that the spot is based on what the Azure needs and not what your VM needs. When Azure needs the capacity it will take it. Why do you use spot VM if you do not want to use the capacity when it is available?!? It make no sense in first glance to stop when Azure does not need it. The entire idea of spot VM is that you use the time that Azure does not use it.
In case the answer is that you can simply try to start the machine when it is evicted, then If there is capacity, then the VM will deployed, and if there is't then you get error and can try again after few minutes. Note that after eviction if you start the machine it will be charged at the current price. You can do it manually using PowerShell.
As I said I do not fully understand your description.
please clarify and elaborate a bit more on your architecture.
Maybe you meant the opposite?
"restart the VM automatically once the capacity is needed by the Azure (during the 30 seconds notice)"
Like if my CPU gets to 90%, I can kill some long running process
Do you want to restart the machine or kill process?
- Off-topic: you should probably not design a system that based on killing process. It is sound very poor solution for most cases. I HIGHLY recommend you to try to find a different design like not starting process if you are going to kill it (basically find the reason for the long running and avoid it if possible or try to predict these cases in order to avoid starting the process)