Apologies for not directly answering your question, but by the sounds of your question, you are trying to build an update management system to mitigate the threats of vulnerable operating system components and tools having unpatched vulnerabilities which expose you to risk.
This functionality is actually already available for both Windows and Linux via Azure Automation in the form of the unimaginatively named Update Management solution.
Essentially you will need to do the following:
- Configure Azure Monitor and Log Analytics to provide information about vulnerable packages on your machines,
- Ensure that any network security groups and firewalls are configured to allow access to/from the various components of the system,
- Enable Change Tracking and Inventory,
- Enable Update Management,
- Onboard your machines.
I would also highly recommend employing Azure Security Center as this provides a clearer overview of vulnerabilities across your estate, not just as applied to specific virtual machines.