Azure: Refactor error handling