 From May 14, 1724 to February 4, 1736 he was viceroy of Peru.He entered the military and fought in the War of the Spanish Succession, on the side of Philip V of Spain.He saw action in the campaigns in Naples, Sardinia, Rosellón and Catalonia, and in the siege of Gibraltar.