I have create one azure function to call 3rd party API and used application ID in SPFx webpart but when on 'gulp serve' it shows error. I have tried in both team site as well as developer site. I am working on Office 365 Enterprise E3 trial.
Do you have the 'Developer Preview' site feature enabled? This is what needs to be enabled to use these experimental features.
You can turn this on by going to Admin Centres -> Sharepoint -> Settings -> Enable Preview Features. Source