We recite the blessing over the new moon at night, because that is when it is clearly visible and one can benefit from its light. One may not recite the blessing if he sees the moon at twilight, because the sun’s light is still shining and one does not benefit from the light of the moon at that time (Rama 426:1). Before reciting the blessing, one must look at the moon for a moment in order to derive pleasure from its light, but the custom is not to look at the moon when actually reciting the blessing (Mishna Berura 426:13, Kaf HaChaim 34). If one recites the blessing when the moon is covered by clouds he has not fulfilled his obligation, because he cannot benefit from its light. However, if it is covered only by a thin cloud, and one can see things that are usually visible by the light of the moon, he may say the blessing. Nevertheless, it is best to say the blessing when the moon is clearly visible, with no obstruction. Some authorities write that it is preferable to postpone Birkat HaLevanah when the moon is even slightly covered, but according to the letter of the law, one may recite the blessing even if a thin cloud passes over the moon, since one can derive benefit from its light. It seems to me that as long as one can discern the outline of the moon through the cloud, it is permissible to recite the blessing.
If, while reciting the blessing, the moon becomes completely covered by clouds, one should continue saying the blessing. However, if one estimates that while reciting the blessing a big cloud will come and cover the moon completely, he should not start the blessing, because ideally (l’chatchilah) the entire blessing must be said when the moon is in view (Ridbaz 1:346; Mishna Berura 426:2; Biur Halachah, s.v. nehenin).
 The Ridbaz (1:341) writes thatit primarily depends on the ability to derive benefit from its light, and many Acharonim cite his words, including the Magen Avraham and Mishna Berura 426:3. However, the Chida writes in Moreh BeEtzba (184) that one may not recite the blessing even if the moon is covered only by a very thin cloud, and the Ben Eish Chai (Shanah Bet, VaYikra 23) concurs. Nevertheless, according to the letter of the law, it seems that all agree that one may recite the blessing as long as one benefits from the light. This is the conclusion of the Yalkut Yosef 426:5.
The Eshel Avraham of Buchach explains that one may recite the blessing if the light of the moon allows one to see most of the things that are usually visible when the moon is unobstructed. This is assessed based on the moon’s light on the seventh night of the month, or the fourth of the month, if there is a pressing need. In his opinion, one may recite the blessing towards the middle of the month even if the moon is covered by a thicker cloud, and one may recite it towards the beginning of the month only if the cloud is very thin. The poskim, however, seem to indicate that the distinction depends on the thickness of the cloud, not the day on which the blessing is recited. So writes the author of Sefer Kiddush Levanah 2:3 (with notes). Therefore, in my humble opinion, it seems that if one can see the outline of the moon, it is considered “visible” (possibly even according to those who are meticulous), and the blessing may be said.
According to the letter of the law, though, the halachah follows the opinion of the Ridbaz and the Eshel Avraham. This is apparent from the words of the Terumat HaDeshen quoted in Leket Yosher: “Once, he saw only a small portion of the moon, because it was partially covered by a cloud, and he nevertheless sanctified [it].”
Some say that one should look at the moon only briefly. See Mishna Berura 426:13 and Kaf HaChaim 34.
Many authorities write that one who recited the blessing without looking at the moon has fulfilled his obligation, as long as he could have seen it had he looked (see Sefer Kiddush Levanah 2:11). They derive this by logical inference from [the law of] a blind man. Most poskim hold that a blind man must say Birkat HaLevanah, because the blessing was instituted in recognition of the renewal of the moon. In addition, even the blind benefit from the moon in that others use its light to escort them. This is the viewpoint of the Rashal, Magen Avraham, Eliyah Rabbah, and Pri Chadash. However, the Maharikash holds that a blind man should not recite the blessing, for he does not derive pleasure from the moon. In practice, a blind man should not recite the blessing, because of the uncertainty surrounding the matter. It is preferable for him to hear the blessing from someone else (see Mishna Berura 426:1; Biur Halachah, s.v. nehenin; Kaf HaChaim 2).
 See Sefer Kiddush Levanah (chap. 2, n. 9) where the author quotes Rav Pe’alim (vol. 3, Orach Chaim 68) who is unsure how to rule in a case where the moon will disappear in the middle of the blessing, but no days remain on which to recite Birkat HaLevanah. He concludes, “It is possible to say that under such dire circumstances everyone agrees that one should say the blessing, but further investigation is required.” The author of Halichot Shlomo (Tefillah 15:12) writes that if one is concerned that immediately after beginning the blessing, the moon will be covered, it is permissible to say the blessing, b’diavad.