Answer by taking a quote from the following article:

Giuseppe Fortunino Francesco Verdi (Italian: [dZu'zeppe 'verdi]; 9 or 10 October 1813 - 27 January 1901) was an Italian opera composer. He was born near Busseto to a provincial family of moderate means, and developed a musical education with the help of a local patron. Verdi came to dominate the Italian opera scene after the era of Vincenzo Bellini, Gaetano Donizetti, and Gioachino Rossini, whose works significantly influenced him. By his 30s, he had become one of the pre-eminent opera composers in history.

Having achieved some fame and prosperity, Verdi began in 1859 to take an active interest in Italian politics. His early commitment to the Risorgimento movement is difficult to estimate accurately; in the words of the music historian Philip Gossett "myths intensifying and exaggerating [such] sentiment began circulating" during the nineteenth century. An example is the claim that when the "Va, pensiero" chorus in Nabucco was first sung in Milan, the audience, responding with nationalistic fervour, demanded an encore. As encores were expressly forbidden by the government at the time, such a gesture would have been extremely significant. But in fact the piece encored was not "Va, pensiero" but the hymn "Immenso Jehova".  The growth of the "identification of Verdi's music with Italian nationalist politics" perhaps began in the 1840s. In 1848, the nationalist leader Giuseppe Mazzini, (whom Verdi had met in London the previous year) requested Verdi (who complied) to write a patriotic hymn. The opera historian Charles Osborne describes the 1849 La battaglia di Legnano as "an opera with a purpose" and maintains that "while parts of Verdi's earlier operas had frequently been taken up by the fighters of the Risorgimento...this time the composer had given the movement its own opera" It was not until 1859 in Naples, and only then spreading throughout Italy, that the slogan "Viva Verdi" was used as an acronym for Viva Vittorio Emanuele Re D'Italia (Viva Victor Emmanuel King of Italy), (who was then king of Piedmont). After Italy was unified in 1861, many of Verdi's early operas were increasingly re-interpreted as Risorgimento works with hidden Revolutionary messages that perhaps had not been originally intended by either the composer or his librettists.  In 1859, Verdi was elected as a member of the new provincial council, and was appointed to head a group of five who would meet with King Vittorio Emanuele II in Turin. They were enthusiastically greeted along the way and in Turin Verdi himself received much of the publicity. On 17 October Verdi met with Cavour, the architect of the initial stages of Italian unification. Later that year the government of Emilia was subsumed under the United Provinces of Central Italy, and Verdi's political life temporarily came to an end. Whilst still maintaining nationalist feelings, he declined in 1860 the office of provincial council member to which he had been elected in absentia. Cavour however was anxious to convince a man of Verdi's stature that running for political office was essential to strengthening and securing Italy's future. The composer confided to Piave some years later that "I accepted on the condition that after a few months I would resign." Verdi was elected on 3 February 1861 for the town of Borgo San Donnino (Fidenza) to the Parliament of Piedmont-Sardinia in Turin (which from March 1861 became the Parliament of the Kingdom of Italy), but following the death of Cavour in 1861, which deeply distressed him, he scarcely attended. Later, in 1874, Verdi was appointed a member of the Italian Senate, but did not participate in its activities.

How long did he serve?
feelings, he declined in 1860 the office of provincial council member to which he had been elected in absentia.