Same as you in Portugal: the tax number first, through a representative before I even arrived, and it opened the bank and the rental. Everything else followed from it. If anyone is planning a move to Portugal, get that number sorted before anything else, because almost every door asks for it.
In Portugal the tax number came first for me, before the residence permit, the bank and even the rental contract. Almost every office asked for it. But friends in other countries tell me their ID or residence number came first, and the tax number came later, or wasn't even a separate thing.
Which came first for you, and which one ended up being the key that opened everything else?