WASHINGTON — In its first-ever virtual graduation and commissioning ceremony, the U.S. Naval Academy on Friday welcomed a new class of officers into the Navy and Marine Corps as the sea services steer through the coronavirus crisis.

In remarks recorded earlier in the week, Defense Secretary Mark Esper congratulated the 1,017 graduating midshipmen, reminded them of the importance of character, trust and leadership, and pointed to the pandemic as an example of unexpected challenges they will inevitably face in their military careers.

"While the coronavirus is a daunting and, in some ways, an unprecedented challenge, it is just one of the many trials you'll experience throughout a lifetime of military service," Esper said. "As new threats continue to emerge, you must remain ready, vigilant and prepared to defend our country, our people and our way of life."

The Navy's top officer, Adm. Mike Gilday, was unable to attend the recording session in which Esper and other officials delivered speeches for Friday's virtual ceremony because Gilday remains in quarantine at his home after having come in contact earlier this month with a family member who tested positive for coronavirus.

The ceremony at Annapolis, Maryland, comes at a tumultuous time for the Navy as it struggles with the coronavirus and leadership crises. On Thursday, the Senate confirmed Kenneth Braithwaite, a former U.S. ambassador to Norway and a 1984 graduate of the Naval Academy, as Navy secretary. He took over for James McPherson, who held the job temporarily after the acting Navy secretary, Thomas Modly, resigned the post under pressure in April. Modly had stepped in when Richard Spencer was fired last November in a dispute with the White House over disciplinary action against a Navy SEAL.

The Navy has suffered coronavirus outbreaks on two deployed ships — the USS Kidd and the USS Theodore Roosevelt, an aircraft carrier that was sidelined in Guam in late March with an outbreak that has infected at least 1,100 members of its crew. The Roosevelt this week returned to sea for training in preparation to resume its duties in the Pacific. Results of a widened Navy investigation into how the Roosevelt's officers and their Navy chain of command handled the coronavirus outbreak are due soon.

The decision not to have a live Naval Academy graduation ceremony reflects concern about the coronavirus pandemic. It stands in contrast to the Air Force, which held a scaled-back live graduation ceremony in Colorado Springs, Colorado on April 18. The ceremony was attended by Vice President Mike Pence but without the large crowd that normally fills the academy's football stadium.

The Army is scheduled to hold a U.S. Military Academy live graduation ceremony at West Point, New York, on June 13 with President Donald Trump as the commencement speaker. Army leaders defended their decision to bring students back, saying that despite the coronovirus risk, students would have had to return anyway to prepare for their next duty assignment. The decision has been criticized as a political move to get Trump on stage at the academy, where he hasn't yet given a graduation address. But Army officials said the students must return for final medical checks, equipment and training.

The ceremony for Class of 2020 graduates of the U.S. Coast Guard Academy was done virtually on Wednesday and featured a pre-recorded keynote address by Army Gen. Mark Milley, chairman of the Joint Chiefs of Staff.

In the virtual spirit of Friday's Naval Academy event, Milley, chimed in with a Twitter note of encouragement to the graduates.

"Whether at sea, in the air, on land or in the cyber domain, the international order is under assault," Milley wrote. "Your leadership will have a direct role in preserving great power peace & free & open maritime commons."

Prior to the remarks by Esper and other senior officials, the Naval Academy ran a series of recorded tributes from several current and retired professional athletes, entertainers and others, including 99-year-old George Shultz, the former secretary of state, as well as singer-songwriter Jimmy Buffett.

As part of its effort to protect its graduates and others, the Naval Academy held a series of five private, live swearing-in ceremonies for the midshipmen between May 12 and May 20. Family members and other guests were not allowed to attend. Excerpts of those five videotaped events were shown during Friday's online ceremony.