It's more an expression of surprise (and perhaps disbelief) rather than disappointment. In fact, disappointment might not necessarily even come into it, e.g.,
"To my amazement, the shop was still open"
In your example, a similar expression might be;
"We were told to complete the task in a specific way, which I did, however to my amazement, a student who did it completely differently got a better mark than me!"