We numerically and experimentally demonstrate that metasurfaces can be used to control the light emission from light emitting diodes (LED). This control provides a desired wavefront and functionality of the light emission in addition to enhancing light extraction efficiency. Simply placing the metasurface on top of the LED does not work as conventional metasurface designs require plane wave excitation, which LEDs cannot provide. To overcome this challenge we implement a novel concept using internal and external resonant cavities combined with the LED. Guided by our numerical simulations, we experimentally demonstrate this concept by fabricating Si and TiO2 metasurfaces on top of the resonant cavity LED structures. The integration of these metasurfaces with commercially available GaN and GaP LED devices show full wavefront control, beam deflection and beam collimation. Both the cavity and the metasurface enhance the LED radiation. Moreover, following the proposed principle, any random light emitting sources including fluorescent molecules and quantum dots can be integrated into a similar optical device to achieve focusing, beam deflecting, vortex beam generation and other capabilities.