In European Union countries, transitioning from a temporary residence permit to a permanent residence permit is typically done inside the country: once one meets the eligibility based on length of stay or whatever, one files an application with the local immigration office. No need to leave and apply from outside.