Energetic materials (EMs) have been widely employed in both military and civilian areas for nearly two centuries. The introduction of high-energy azide anions to assemble energetic metal-organic frameworks (EMOFs) is an efficient strategy to enhance energetic properties. However, azido-based EMOFs always suffer low stabilities to external mechanical stimulation. Herein, we employed an in situ hydrothermal reaction as a technique to refine azide anions with a neutral triazole-cyano-based ligand TrzAt (TrzAt = 2-(1H-1,2,4-triazol-1-yl)acetonitrile) to yield two tetrazole-based EMOFs, namely, [ZnBr(trmetz)]n1 and [Cd(trmetz)2]n2 (Htrmetz = 5-(1,2,4-triazol-1-ylmethyl)-1H-tetrazole). Compound 1 features a closely packed 2D layered network, while compound 2 exhibits a 3D architecture. With azide anions inlaid into a nitrogen-rich and chelating ligand in the EMOFs, compounds 1 and 2 present remarkable decomposition temperatures (Tdec ≥ 300 °C), low impact sensitivities (IS ≥ 32 J) and low friction sensitivities (FS ≥ 324 N). The calculated heat of detonation (ΔHdet) values of 1 and 2 are 3.496 and 4.112 kJ g-1, respectively. In particular, the ΔHdet value of 2 is higher than that of traditional secondary explosives such as 2,4,6-trinitrotoluene (TNT, ΔHdet = 3.720 kJ g-1). These results indicate that EMOFs 1 and 2 may serve as potential replacements for traditional secondary explosives. This work provides a simple and effective strategy to obtain two EMOFs with satisfactory energy densities and reliable stabilities through an in situ hydrothermal technique for desensitization of azide anions.