Great question! Porting your number to a new carrier is actually a lot simpler than you think.
You need to make sure that you are fully up to date on all of your payments to your current carrier - they are unlikely to let you switch if you owe them any payments.
To port your cell phone, make sure the number you are wishing to port is not terminated before the switch. Don't cancel service prior to arranging to the port. If your number is disconnected before your switch, then it is not linked to you or your device anymore. If the number is not linked to you, it will be very hard to get back.
The carrier you are switching to will port your number. You do not need to port it yourself. During your switch, the number will automatically disconnect from your old service and connect to your new service/device.
From the FCC website, "Under the Federal Communications Commission's "local number portability" rules, you can switch telephone service providers for wireline, wireless or Voice over Internet Protocol and keep your existing phone number if you remain in the same geographic area. If you are moving from one geographic area to another, however, you may not be able to take your number with you."
Here is an article from the WhistleOut website that outlines the porting process!