Syrian troops have foiled an attack by militants against one of the largest military barracks in the country, in northern Aleppo.