The ships company and guard of honour marched on for the commissioning divisions and were inspected by Rear Admiral Paul Bennett.
The Chaplain of the Fleet led the service, during which a bottle was broken over the bow of Magpie
During the ceremony, a personal note that was sent to the ship by HRH The Duke of Edinburgh was read out.
The Duke commanded the last ship to bear the name HMS Magpie from 1950 until 1952 operating in the Mediterranean. He said:
"Having had the honour of commanding the anti-submarine frigate HMS Magpie, based in Malta soon after the war, I am delighted to know that the name 'Magpie' has been revived for a new Royal Navy survey ship.
"I am delighted to have this opportunity to offer my best wishes to the new ship's company for a happy and rewarding commission."
Lieutenant Commander William Alexander, the ships new Commanding Officer and Gleaner’s last, said: “We had a fantastic day. The ship’s company and I are extremely proud of HMS Magpie.
"We carried out the official naming ceremony and then rolled into the commissioning ceremony – two very important milestones in the ship’s generation.
"This is now the starting point for us to go forward and get up to an operational standard.’’
HMS Magpie is an 18-metre catamaran, bigger than her predecessor, 15-metre Gleaner.
It can accommodate up to 12 crew members and a galley which can meet the sailor's needs for up to seven days.
She is believed to be more resilient in rough seas, with the Navy expecting Magpie to be able to maintain 20 knots in a Sea State Four with waves up to 2.5 metres high.
Magpie will also be able to launch remote-controlled underwater devices to search wide areas of seabed for obstructions or mines.
She will play a similar role to HMS Gleaner's, ensuring the approaches to the UK’s ports are safe by scanning the seabed, updating charts and acting as another pair of eyes and ears into events in home waters.
She is also first vessel to be delivered under a contract negotiated by Defence Equipment and Support with Atlas Elektronik.