A surge in cloud-computing earnings—and high-profile investments in AI—should help the company catch up with other tech leaders.