A.J. Burnett has probably gone through ten bottles of whipped cream already. That’s just fine with him, based on how his Yankees are playing.

Burnett pitched well in an encouraging tuneup and New York rallied for two runs in the ninth inning, beating the Royals 4-3 for its seventh straight victory.

Farm leaguer Juan Miranda got the game-winning hit off Krazy Kyle Farnsworth, an infield single that caromed off the reliever’s leg and into foul territory between home plate and first base.

The custom all season, Burnett plastered Miranda in the face with a whipped cream pie.

Following its league-best 15th walk-off win, New York is 46 games above .500 for the first time since finishing 114-48 in 1998.

Looking for his 100th career win, Burnett allowed two runs and three hits in 6 1/3 innings. He struck out eight and walked three.

After missing his start on Monday to be with his father, Burnett has turned in three straight quality starts after six weeks of so-so pitching. Burnett is slated to start the regular-season finale Sunday at Tampa Bay, following CC Sabathia on Friday and Andy Pettitte on Saturday.

A good sign for New York was the return of reliever David Robertson. Robertson entered to start the eighth and threw a strikeout before getting a groundout and issuing a walk.

The right-hander was lifted for Brian Bruney, who tossed 1 1/3 scoreless innings.