def METHOD_NAME(client, entity, if_exists='fail'):
    from azure.core.exceptions import ResourceExistsError
    if if_exists == 'fail':
        try:
            return client.create_entity(entity)
        except ResourceExistsError:
            raise ResourceExistsError("The specified entity already exists.")
    if if_exists == 'merge' or if_exists == 'replace':
        return client.upsert_entity(entity, mode=if_exists)
    from knack.util import CLIError
    raise CLIError("Unrecognized value '{}' for --if-exists".format(if_exists))