The development of the smart grid (SG) has the potential to bring significant improvements to the energy generation, transmission, and distribution sectors. Hence, adequate handling of fluctuating energy demands is required. This can only be achieved by implementing the concept of transactive energy. Transactive energy aims to optimize energy production, transmission, and distribution combined with next-generation hardware and software, making it a challenge for implementation at a national level, and to ensure the effective collaboration of energy exchange between consumers and producers, a serverless architecture based on functionality can make significant contributions to the smart grids advanced metering infrastructure (SG-AMI). In this paper, a scalable serverless SG-AMI architecture is proposed based on fog-edge computing, virtualization consideration, and Function as a service (FaaS) as a services model to increase the operational flexibility, increase the system performance, and reduce the total cost of ownership. The design was benchmarked against the Iraqi Ministry of Electricity (MOELC) proposed designs for the smart grid, and it was evaluated based on the MOELC traditional computing-design, and a related cloud computing-based design. The results show that our proposed design offers an improvement of 20% to 65% performance on network traffic load, latency, and time to respond, with a reduction of 50% to 67% on the total cost of ownership, lower power and cooling consumption compared to the SG design proposed by MOELC. From this paper, it can be observed that a robust roadmap for SG-AMI architecture can effectively contribute towards increasing the scalability and interoperability, automation, and standardization of the energy sector.