"This isn't an easy post; you guys are doing the tough work," she told the assembled servicemen and women at Al-Udeid base, the forward headquarters for the US Central Command outside the Qatari capital.
Before she spoke, a military band played several songs, including "Sweet Home Alabama".
Obama is in Qatar as part of a seven-day regional tour during which she is expected to focus on the issue of "cultural beliefs" obstructing girls' education.
She is set to make a keynote speech at the World Innovation Summit for Education (WISE) in Doha Wednesday, as part of her well-publicised efforts to promote girls' education globally.
In an email ahead of her trip, Obama wrote that 62 million girls across the globe are not going to school at all, urging support for the "Let Girls Learn" initiative that she launched with President Barack Obama earlier this year.
Obama was accompanied by late-night talk show host Conan O' Brien as part of the morale-boosting visit to troops.
Signup to our newsletter and follow us on Facebook and Twitter!
O'Brien, whose "Conan" programme airs on TBS cable television, put on a show for the troops, part of which will be broadcast later this year.
He told the crowd he had accepted the invitation, despite promising his wife he would not return to the region again any time soon after a recent visit to Dubai.
"I went to Dubai, flew back 18 hours, saw my wife and kids, and said 'I won't be doing that, honey, any time soon'."
"And I think the phone rang three days later and they said 'we need you to fly pretty much to Dubai'.
"My wife said, 'that's the first lady; you're going. I don't want to see you again if you don't go on this trip'."
Al-Udeid, home to around 10,000 military personnel, is used as a hub by the US military for its air strikes against the Islamic State jihadist group in Syria and Iraq.
Earlier Tuesday, Obama met Qatar's emir, Sheikh Tamim bin Hamad al-Thani.
She is set to travel on to Jordan, where she is to visit a girls' school in Amman built with US aid funds.