He was a pupil of Parini and held several positions in the administration of Milan. After 1848 — his Hymn to the Five Days is his — when the Austrians returned to Milan, he took refuge in Genoa, where he served as president of the administrative council of the University.
In 1808 he wrote the Epistle on the Sepulchres: a comparison between Foscolo’s poem and that of Pindemonte. With the terza rima poem Sulla Passione di Cristo (1816) and the four Sermons on Poetry (1818), his adherence to Romanticism becomes evident. He also composed a short poem, La Torre di Capua (1829), and in 1836 Scetticismo e religione.
Manzoni, in a letter to D’Azeglio and in I Promessi Sposi, praises his verses. The three epistles: Un'abiura in Roma nel secondo anno del pontificato di Pio IX, which tacitly contrast the reforming Pius IX with the more cautious and conservative pope of later years, were placed on the Index (decree of 20 April 1852) also because of their anticlerical spirit, for which a sensible and honest heterodox mourns the purity of the sky in the face of the corruption of the Church.