Hi Saral Joshi,
I understood that you have done in-place upgrade from Ubuntu 20.04 LTS to Ubuntu 22.04 LTS to one of your VMs and after upgrading you have notified that VM agent is not ready but after deallocation of the machine it worked but only for 15-20 min.
An in-place upgrade to a new major version breaks the connection between the data plane and the control plane of the VMs. Consequently, Azure capabilities such as Auto guest patching, Auto OS image upgrades, Hotpatching, and Azure Update Manager won't be available. To access these features, we recommend that you create a VM instead of performing an in-place upgrade for the other VMs. Before creating new VM, please take a disk backup of old VM and attach it to new VM.
So, I suggest checking the current version of the walinuxagent and installing the latest update and also configure auto update for agent and then restart the waagent service.
Please refer to the documents below:
https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/update-linux-agent?tabs=ubuntu
Please let me know if you have further questions.
If it was helpful, please click "Upvote" on this post and "Accept" the answer for the benefit of community.
Thank you.