Microsoft's heavy bet on AI pays off as it beats expectations in second quarter