The beta-phase of Zn4Sb3 has been regarded as a very promising thermoelectric material since middle nineties, owing to its unique merit: intermediate temperature region (200-400 °C), made of cheap, non-toxic and abundant elements and high thermoelectric property. However, the thermal stability of Zn4Sb3 seems to be an inherent obstacle for the practical application during the working temperatures. Herein, magnesium doped Zn-Sb semiconductor (Mg0.04Zn3.96Sb3) was investigated thoroughly in-situ during thermal annealing up to 600 K, whilst both microstructure and electronic structures were recorded via the combination of synchrotron-based two dimensional X-ray diffraction techniques and the X-ray photoemission spectroscopy. While the time-resolved grazing incidence XRD reveals the preserved crystal structures during thermal annealing to 600 K, XPS measurement demonstrate the robustness of electronic structures. On basis of these findings, it was concluded in the end that the doping of magnesium significantly improves the thermal stability of zinc-antimonite compounds and introduces minor influence on the electronic structure of Zn-Sb alloy. Our study may propose an effective approach towards the wild application of Zn4Sb3 related thermoelectric materials.