Earlier this week, US tech giant Microsoft vowed that it would give the Pentagon access to "all the technology" it creates.

Outgoing Pentagon chairman of the Joint Chiefs of Staff Gen. Joseph Dunford has slammed Google Inc's "inexplicable" tendency to make compromises to do business in China, while being more reluctant to work with the US department of defence.

"We are the good guys and it's inexplicable to me that we would make compromises in order to advance our business interests in China where we know that freedoms are restrained, where we know that China will take intellectual property from companies," Dunford said, according to Reuters.

In June, Google pulled out of a Pentagon-funded program known as Project Maven, a project for using artificial intelligence to analyze reconnaissance photography taken by drones, after over 3,100 employees signed a petition to leave the partnership. In October, the tech giant also dropped out of the running for a $10 billion Pentagon Joint Enterprise Defense Infrastructure (JEDI) cloud services contract, saying the contract did not align with its corporate values.

At the same time, the company has made compromises with Chinese authorities to create a local search engine with backdoor monitoring capabilities built in, allowing authorities to track everything from search history to user location.

Dunford criticized Google's policy, insisting that the Pentagon wasn't asking the company to do "something that's unethical, illegal or immoral."

"This is about ensuring that we collectively can defend the values for which we stand. That would be the argument I make to the tech companies," he said. "I'm not sure that people at Google will enjoy a world order that is informed by the norms and standards of Russia or China," the top general added.

Last week, Microsoft President Brad Smith vowed that his company would provide the Pentagon "with access to the best technology, to all the technology we create — full stop."