Milan will pay a reported €40million for the 30-year-old Italy centre-back, who will sign a five-year contract at San Siro upon the completion of a medical.
Bonucci was a crowd hero at Juve and a star performer as they captured the last six Serie A titles.
However, an argument with Allegri during a 4-1 win over Palermo in February resulted in the player being dropped for the subsequent Champions League trip to Porto.
Juve reached the final of Europe's premier competition but lost 4-1 to Real Madrid and, after the match in Cardiff, Bonucci was forced to deny having a half-time row in the dressing room with Allegri, Paulo Dybala and Andrea Barzagli.
The former Bari player bought an entire page of Italian sports newspaper Gazzetta dello Sport to demonstrate his gratitude to all at Juventus, with one notable omission.
"Seven seasons have passed. Seven seasons of victories, of dreams realised, of growth that took place through an empathic and exceptional bond with Juve, in its absolute entirety," Bonucci's statement read.
"There remains a great regret for not having won the Champions League, but greater pride for the achievements and for having been part of a large family.
"I've always given everything, really, to the end. Today, looking back, I nonetheless see a splendid story, worthy of ending in full respect and affection, without affecting what I have lived together with the club, the captain, my team-mates and the fans.
"A beautiful story. Thanks for everything, Juve."
Juventus captain Gianluigi Buffon and Bonucci also exchanged affectionate tweets, indicating there is no ill feeling between two pillars of defensive strength for club and country.
"Team-mate and travellers," the evergreen goalkeeper tweeted. "We walked part of the way together. A winning way. I wish you the best. But I will miss you…"
Bonucci responded: "I will miss you too. Thanks for the shared wins, for the battles won and also for those lost. See you on the national team."