Amazon’s stock rallied Friday to the highest close in more than nine months, and ended June with a four-month win streak.