He studied at the Colegio de San Carlos and later in Spain, possibly at the naval school in Cádiz, then served in the navy and in scientific commissions to establish and map borders of the era.
After the British invasions of the Río de la Plata, the city of Montevideo had been left without a naval defense as the sailors had been taken prisoner to Great Britain.
He was made colonel in June 1813 and a member of the Lautaro Lodge, and was named governor of the Córdoba del Tucumán Intendancy, a post he occupied only for a short time.
In February 1814 he was replaced by Francisco Ortiz de Ocampo, a native of La Rioja who, even though born in the interior, could not control the tendency of the population to favor provincial autonomy, which would soon arrive in any case.
Returning to Buenos Aires, Viana became a member of the consulting council for the Supreme Director Gervasio Posadas, and accompanied general Carlos María de Alvear to finish the siege of Montevideo.