The suspects covered their faces with scarves during the attempted raid on the Pentland bakery in Penicuik.
One of the men brandished a knife, but they both ran away when they were refused money. Lothian and Borders Police said the pair ran uphill towards Glaskhill.
The first man is described as white, around 5ft 9in, of stocky build and with broad shoulders. He was wearing a black unbranded hooded top and jogging bottoms and had a green scarf covering his face.
The second man is thought to be white, around 5ft 7in and of slim build.
He was wearing a black Adidas zip-up hooded top with white stripes down the arms and a white scarf covering his face.
Police have appealed for eyewitnesses to get in touch.