"And I will set My face against you" (Leviticus 26:17): [You did not merit that I should turn toward you for good, so I have turned toward you for evil.] A parable of a king who said to his servant: I turn away from all my affairs and occupy myself with you for evil. "And you shall be smitten before your enemies": After all this, death will be killing you [from within], and the enemy surrounds you from without. And so it says, "Outside the sword shall bereave, and within, terror" (Deuteronomy 32:25). "And those who hate you shall rule over you": That is to say, from you and among you shall your enemies be, who will search out your hidden treasures.
When God Turns His Face Against Israel in Midrash Aggadah
Midrash Aggadah, Leviticus 26:17
ונתתי פני בכם. [לא זכיתם שאהי' פונה אליכם לטובה ופניתי אליכם לרעה] משל למלך אשר אמר לעבדו פונה אני מכל עסקי ואתעסק בך לרעה: ונגפתם לפני אויביכם. אחר כל זה יהיה המות הורג אתכם, [מבפנים] והאויב מקיף אתכם מבחוץ, וכן הוא אומר מחוץ תשכל חרב ומחדרים אימה (דברים לב כח): ורדו בכם שונאיכם. כלומר מכם ובכם יהיו אויביכם שיחפשו מטמוניות שלכם: