Revolutions and a country's foreign service and foreign presence

What typically happens when there is a major revolution, like that of the Bolsheviks in 1917, or when you have a fascist takeover, with regard to that country’s envoys and ambassadors abroad? For example, when the Nazis came to power in Germany, to what extent were the ranks of German consular officials shaken up? Did the new regime immediately purge the foreign service, or was that an afterthought not attended to until years later? Did some ambassadors appointed by the Weimar leaders refuse to go home, and seek asylum in the host countries?

Similarly with the Taliban: When they took over Afghanistan, were there any in the Afghani foreign service, particularly women, who refused to go home?