You can configure Start/Stop VMs options; the Start/Stop VMs feature allows you to start or stop the Azure VMs based on user-defined schedules.
Refer: https://learn.microsoft.com/en-us/azure/automation/automation-solution-vm-management
https://learn.microsoft.com/en-us/azure/azure-functions/start-stop-vms/overview
Hope this helps