Rising infrastructure costs and weaker-than-expected advertising revenue weighed on the technology giant, even as its cloud business expanded rapidly