HI Kryten,
I believe this should be possible although some changes need to be made to the code to make it M5Stack compatible.
Also perhaps not all functions are available yet for the ESP32 chip itself (& thus also the M5Stack).
For example, re. Arduino core for ESP32, analogWrite is not available yet but is being worked on.
However apparently most of that framework is available. See:
https://github.com/m5stack/azure_iothub_arduino_lib_esp32/blob/master/hardware/espressif/esp32/README.md
Perhaps someone else can add more to this....
Check the link below to visit the EXCELLENT "macsbug" blog for an example of changes made to esp32 code to make it run on M5Stack...... ( esp32-spaceshooter ) . Most changes are minor.
Use Chrome if you need it translated from Japanese, otherwise it may be hard to read. : >
https://macsbug.wordpress.com/2018/01/12/esp32-spaceshooter-with-m5stack/