Preheat oven to 375 degrees F.
Defrost and roll out the pastry, dust lightly with flour on both sides. In a saucepan, fry bacon until crisp, reserving 1 tbsp drippings. Crumble. Saute onions on medium heat in reserved drippings until soft, approximately 10 minutes. Add the cayenne and stir. Place the bacon in the center of the rolled out puff pastry. Top with onion mixture, then top with brie. Gather the pastry, pressing firmly to seal. Brush entire pastry with beaten egg. Place brie on a cookie sheet, seal side down. Bake 20-25 minutes, until pastry is golden brown. Allow baked brie to cool 15-20 minutes before cutting.