The presence of oil in the Middle East region had been known since 1908. The Germans and other Axis members had been aware of this fact for just as long. They would ideally have liked to invade the Middle East, but due to their strategic positioning, this was impossible. An attack on the Middle East could have been launched from three locations: The Balkans, through Turkey, the Caucasus, or from Libya, through Egypt. As /u/NotVladeDivac points out, Allied diplomatic efforts made the first approach untenable. The second was ruled out by the failure of the German invasion of the Soviet Union. The third was made impossible by the British defence of Egypt, and ultimately by Operation Torch.
The Germans did, however, attempt to support an anti-Allied regime in Iraq, and had a close relationship with the Iranian regime. At the end of March 1941, the pro-British Regent of Iraq was overthrown by the pro-German prime minister and a group of army officers. This government made diplomatic overtures towards Germany, and when Anglo-Indian forces arrived to put down the rebellion, German and Italian aircraft and light forces were sent to assist the Iraqi forces. Arms were also sent from Syria, which was administered by Vichy France at the time. However, this would ultimately fail to help the Iraqi rebellion, which was overwhelmed by the advancing British. Iran, meanwhile, had had a long relationship with Germany, mainly resulting from the German's lack of imperial ambitions in the region. The rise of the Nazi government did little to affect this. While the Iranian government was not explicitly pro-Axis, they were seen as a threat by the British government. It must be noted that Anglo-Persian relationships had been strained since the cancellation of the D'Arcy Concession in 1931 (the D'Arcy Concession gave the Anglo-Persian Oil Company a monopoly on the sale of Iranian oil, strongly benefiting the British over the Iranians). The Iranians were a threat to the British oil refinery at Adaban and the Trans-Iranian railway along which a large amount of Lend-Lease to the USSR flowed. While the Iranians attempted to remain neutral, the British and Soviets couldn't allow them to. They invaded in August 1941, and had completely secured the country by September. It was partitioned between the two countries until 1946.
Sources:
Iraq 1941: The Battles for Basra, Habbaniya, Fallujah and Baghdad, Robert Lyman, Osprey, 2006
Despatch on Operations in Iraq, East Syria, and Iran From 10th April, 1941 to 12th January 1942, Archibald Wavell, London Gazette, 1946, 37685
Despatch on Operations in the Middle East From 5th July, 1941 to 31st October 1941, Claude Auchinleck, London Gazette, 1946, 37685
They were aware and in fact, this is what contributed to neutral Turkey's strategic importance. Turkey was the land bridge and only route to the oil-rich middle east, considering the allies controlled the Mediterranean. This lead to Turkey actually receiving armaments from both sides to sway them even though Turkey was not contributing to the war efforts of either of the three parties; axis, allied, or communist. In addition, this caused Turkey to lean towards the Allies as it made Turkey's President of the time, İsmet İnönü, very nervous having the Axis forces present in neighboring Greece and Bulgaria knowing they needed oil badly. Thus, in 1941, a non-aggression pact was signed between Germany and Turkey.
I believe there were plans drawn up for a Nazi invasion of the middle east to secure its oil, however, by the time the shortage became critical, the Germans were already too over stretched and being beaten at other fronts to mount this sort of large scale strategic operation.
edit: this thread from the sub could open up some of the details I'm referring to http://www.reddit.com/r/AskHistorians/comments/1opl33/how_did_turkey_keep_out_of_wwii/