Background: Canby was born in Piatt's Landing, Kentucky, to Israel T. and Elizabeth (Piatt) Canby. He attended Wabash College, but transferred to the United States Military Academy, from which he graduated in 1839. He was commissioned a second lieutenant in the 2nd U.S. Infantry and served as the regimental adjutant. Although often referred to as Edward Canby, a biographer has suggested that he was known as "Richard" during childhood and to some friends for most of his life.
Context: During his early career, Canby served in the Second Seminole War in Florida and saw combat during the Mexican-American War, where he received three brevet promotions, including to major for Contreras and Churubusco, and lieutenant colonel for Belen Gates. He also served at various posts, including Upstate New York and in the adjutant general's office in California from 1849 until 1851, covering the period of the territory's transition to statehood.  Against his wishes, he was assigned to what was supposed to be the civilian post of custodian of the California Archives from March 1850 until he left California in April 1851. The Archives included records of Spanish and Mexican governments in California, as well as Mission records and land titles. Evidently, Canby had some knowledge of the Spanish language, which was extremely useful as the government was trying to unravel land titles. (The Filson Historical Society in Louisville, Kentucky holds what appears to be a document written in Canby's hand in Spanish, in which he identifies himself as "Edwardo  [sic] Ricardo S. Canby.")  Canby served in Wyoming and Utah (then both part of the Utah Territory) during the Utah War (1857-1858). During this period, he served on the panel of judges for the court martial of Captain Henry Hopkins Sibley. Sibley was acquitted. Subsequently, Canby wrote an endorsement for a teepee-like army tent which Sibley had adapted from the American Indian style.  Both officers were later assigned to New Mexico, where in 1860 Canby coordinated a campaign against the Navajo, commanding Sibley in a futile attempt to capture and punish Navajo for "depredations" against the livestock of settlers. The campaign ended in frustration, with Canby and Sibley rarely sighting Navajo raiders. Usually they saw the Navajo at a distance and never got close to them.
Question: what did he do in the military?

Answer:
During his early career, Canby served in the Second Seminole War in Florida and saw combat during the Mexican-American War,