In this paper, we demonstrate how to efficiently control the quality factor of silicon nitride nanobeam cavities, grown on a silica substrate and embedded in an upper cladding, by engineering the nanobeam cross-section and the shape of the periodic holes. We propose optimized configurations that are able to overcome the decreasing of the Q-factor when the nanobeam is embedded in an asymmetric medium. More precisely, we show that the maximum achievable quality factor can be designed and tuned in asymmetric configurations where the upper cladding is particularly different from the substrate one. These optimized configurations exhibit high-Q factor and small mode volume over a wide range of the upper cladding refractive index paving the way for the realization of innovative optical sensors and for the compensation of fabrication tolerances in embedded optical nanobeam cavities.