Under a hierarchical structure perspective, the integration of tools like the internet of things, cloud computing, and machine learning into a microgrid real-time energy management system involves superior capabilities like an autonomous and scalable design, massive storage capabilities, real-time information analysis and processing, and security issues control, to mention a few. This paper evaluates most of them using a cloud-based real-time energy management system integrated into a real-life hardware-in-the-loop testbed. The proposed cloud-based system is tested by solving an economic power dispatch problem including the equalization of the multiple battery-based energy storage systems interacting within a multi-microgrid environment. The test assessment combined reviewing and running microgrid models, incorporating these models into a real-life power-hardware -in-the-loop unit, linking the testbed to a cloud server, and merging the energy management system with on -demand computing tools, primarily machine learning and the internet of things. As established by the experi-mental evidence, this paper cites the benefits of combining machine learning techniques and internet of things tools with a scalable and autonomous real-life cloud-based energy management system architecture to improve the framework's functionality, enhance the energy forecasting for generation and usage, and cut down the price paid to the service provider.