Russia's President Vladimir Putin (L) applauds during an agreement signing ceremony in Shanghai on May 21, 2014, with Gazprom CEO Alexei Miller (C) and Chinese state energy giant CNPC Chairman Zhou Jiping (R) attending the ceremony. China and Russia signed today a monumental, multi-decade gas supply contract in Shanghai, CNPC said, with reports saying it could be worth as much as $400 billion. - 

In Shanghai Wednesday, China signed an historic deal with Russia's Gazprom, securing a 30-year natural gas supply for the country. Russia and China have been in discussions over building a pipeline to deliver gas from Siberia to China for more than a decade.

This was the perfect time for China to be at the bargaining table with Russia's Gazprom because of the ongoing unrest in the Ukraine. Russia's government is becoming increasingly nervous about its reliance on selling natural gas to Western Europe and the constant threat of isolation from the West. For Russia, this deal means a more diversified customer bas for its enormous gas supply. For China, the deal means 38 billion cubic meters of natural gas a year starting in 2018 – equal to a quarter of what China currently consumes each year –will be purchased to the tune of nearly $400 billion.

The deal reveals a future where Russia and China are much closer economic partners than they've been in the past.

China is buying so much natural gas through this deal that it could help Beijing in its efforts to clean up China's environment. Much of the air pollution in China is due to burning coal. Natural gas is cleaner burning, and it's likely Russian gas will be replacing some of China's dirtiest coal-fired power plants.

China relies more and more on a diverse array of foreign countries for its energy, and the fact this is a 30-year deal will allow China's government to rest a little easier at night.

Follow Rob Schmitz at @rob_schmitz