It is possible to apply for a work permit even if you are not in Canada. In such cases, IRCC will issue you a port of entry letter of introduction to help you land in Canada. Then upon further verification, the immigration officers will issue your work permit right at the port of entry.