According to The World of Ice and Fire, there are multiple contradicting stories regarding the end of the Long Night.
It is also from these histories that we learn of the Long Night, when a season of winter came that lasted a generation — a generation in which children were born, grew into adulthood, and in many cases died without ever seeing the spring. Indeed, some of the old wives’ tales say that they never even beheld the light of day, so complete was the winter that fell on the world. While this last may well be no more than fancy, the fact that some cataclysm took place many thousands of years ago seems certain. Lomas Longstrider, in his Wonders Made By Man, recounts meeting descendants of the Rhoynar in the ruins of the festival city of Chroyane who have tales of a darkness that made the Rhoyne dwindle and disappear, her waters frozen as far south as the joining of the Selhoru. According to these tales, the return of the sun came only when a hero convinced Mother Rhoyne’s many children — lesser gods such as the Crab King and the Old Man of the River — to put aside their bickering and join together to sing a secret song that brought back the day.
It is also written that there are annals in Asshai of such a darkness, and of a hero who fought against it with a red sword. His deeds are said to have been performed before the rise of Valyria, in the earliest age when Old Ghis was first forming its empire. This legend has spread west from Asshai, and the followers of R’hllor claim that this hero was named Azor Ahai, and prophesy his return. In the Jade Compendium, Colloqu Votar recounts a curious legend from Yi Ti, which states that the sun hid its face from the earth for a lifetime, ashamed at something none could discover, and that disaster was averted only by the deeds of a woman with a monkey’s tail.
How the Long Night came to an end is a matter of legend, as all such matters of the distant past have become. In the North, they tell of a last hero who sought out the intercession of the children of the forest, his companions abandoning him or dying one by one as they faced ravenous giants, cold servants, and the Others themselves. Alone he finally reached the children, despite the efforts of the white walkers, and all the tales agree this was a turning point. Thanks to the children, the first men of the Night’s Watch banded together and were able to fight — and win — the Battle for the Dawn: the last battle that broke the endless winter and sent the Others fleeing to the icy north.
In the annals of the Further East, it was the Blood Betrayal, as [the Bloodstone Emperor’s] usurpation is named, that ushered in the age of darkness called the Long Night. Despairing of the evil that had been unleashed on earth, the Maiden-Made-of-Light turned her back upon the world, and the Lion of Night came forth in all his wroth to punish the wickedness of men.
How long the darkness endured no man can say, but all agree that it was only when a great warrior — known variously as Hyrkoon the Hero, Azor Ahai, Yin Tar, Neferion, and Eldric Shadowchaser — arose to give courage to the race of men and lead the virtuous into battle with his blazing sword Lightbringer that the darkness was put to rout, and light and love returned once more to the world.
But regarding the first part of your question, while the followers of R’hllor prophesy the return of Azor Ahai, they don’t seem to have had anything to do with the original legend. We don’t know when the religion was founded, but according to TWOIAF, it has grown numerous in “the past hundred years”. It’s been around for a while, I’m sure — it very likely had strength during the the age of Valyria — but I would doubt that it even existed during the time of the Long Night.
The Valyrians had their own pantheon. (Some of their gods were named Balerion, Meraxes, Vhagar, and Syrax.) But note the Freehold had freedom of religion:
At the height of her power, the Freehold was home to a hundred temples; some had tens of thousands of worshippers, some precious few, but no faith was forbidden in Valyria, nor were any exalted above the others. Many Valyrians worshipped more than one god, turning to different deities according to their needs; more, it is said, worshipped none at all. Most regarded freedom of faith as a hallmark of any truly advanced civilization.
Some scholars have suggested that the dragonlords regarded all faiths as equally false, believing themselves to be more powerful than any god or goddess. They looked upon priests and temples as relics of a more primitive time, though useful for placating “slaves, savages, and the poor” with promises of a better life to come. Moreover, a multiplicity of gods helped to keep their subjects divided and lessened the chances of their uniting under the banner of a single faith to overthrow their overlords.
Despite this religious freedom, the Targaryens don’t seem to have had anything to do with R’hllor. Before Aegon’s Conquest, we only know that they were associated with the Valyrian religion and the Faith of the Seven. The sept at Dragonstone had statues carved from the masts of the ships that brought the Targaryens to that island, and Aegon counted his reign from the day he was anointed king by the High Septon in Oldtown. And Maegor’s second (polygamous) marriage was performed by Queen Visenya in a Valyrian ceremony.
But after King Jaehaerys the Conciliator re-established the Targaryen protection of the Faith, that’s the only religion that we know they were connected to. All successive kings were blessed by the High Septon upon their ascension to the throne. Several Targaryen princesses became septas (and one wanted to but wasn’t allowed), and one king (Baelor the Blessed) actually was a septon. And Aegon V even wanted to honor the Seven in the ritual that unfortunately led to the Tragedy at Summerhall.
The only association that we know of between the Targaryens and R’hllor was when a Red Temple learned that Aerys II was obsessed with fire. The red priest Thoros of Myr was sent to King’s Landing in an attempt to convert him to the worship of the Lord of Light, but was unsuccessful. (The pyromancers were more impressive than he was.) But he remained at King’s Landing, even through the Rebellion and afterwards, though he never converted Robert either. (Although Robert found it hilarious when Thoros would enter tourney melees with his wildfire-dipped sword and get horses to throw their riders.)
Now, the High Priest Benerro of Volantis, who preaches that Dany is Azor Ahai Reborn, has sent his priest Moqorro to convert her to their faith. Whether he’ll have any luck is anyone’s guess, but I personally doubt it:
The red priests believed in two gods, she had heard, but two who were eternally at war. Dany liked that even less. She would not want to be eternally at war.