Refactor azure to outsource image detection