<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def get_resource_by_id(resource_id, api_version, extract_value=None):
    '''
    Get an AzureARM resource by id
    '''
    ret = {}

    try:
        resconn = get_conn(client_type='resource')
        resource_query = resconn.resources.get_by_id(
            resource_id=resource_id,
            api_version=api_version
        )
        resource_dict = resource_query.as_dict()
        if extract_value is not None:
            ret = resource_dict[extract_value]
        else:
            ret = resource_dict
    except CloudError as exc:
        __utils__['azurearm.log_cloud_error']('resource', exc.message)
        ret = {'Error': exc.message}

    return ret