Forum Discussion

mtoarantes's avatar
mtoarantes
Regular Visitor
1 year ago

Microsoft Fabric Notebook - API - WABI

Endpoint URL - wabi-east-us-redirect.analysis.windows.net/metadata/monitoringhub

Hello Everyone, 

 

I would like to know how can i get access in this endpoint cause when i try to connect i get a message error about Timeout ..

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, mtoarantes 
    Thanks for reaching out to the Microsoft fabric community forum.

     Are you encountering errors when connecting to the Lakehouse via the SQL Analytics endpoint? If so, this might be related to the large volume of data causing M language query processing to time out. You can resolve this issue by setting the CommandTimeout. Here are some relevant answers that might help you:

    For more details, please refer to:

    Solved: How to set command timeout option - Microsoft Fabric Community

     

    If the error occurs during an API call, please check if the API you are using supports Long Running Operations. Here are some relevant document screenshots:

    For more details, please refer to:

    Long running operations - Microsoft Fabric REST APIs | Microsoft Learn

    Items - Create Item - REST API (Core) | Microsoft Learn

    Solved: Re: Not able to connect to Lakehouse SQL endpoint - Microsoft Fabric Community

     

    If the issue is with an API call, please share which API call is causing the problem and provide more error details.Of course, if you have any new discoveries or questions, please feel free to get in touch with us.
     

    Best Regards,

    Leroy Lu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • mtoarantes's avatar
    mtoarantes
    Regular Visitor

    Hello Anonymous ,

    Thank you for the answer, bellow im putting the code about the API 

     

    API_ENDPOINT = "wabi-east-us-redirect.analysis.windows.net"
     
    def obtener_token():
    return mssparkutils.credentials.getToken("pbi")
     
    def cargar_datos(engine, tipo_carga😞
        """Carga los datos de manera histórica o incremental según el tipo de carga"""
        if tipo_carga == "historical":
            print("Iniciando carga histórica")
            fecha_inicio = datetime(1970, 1, 1)
            fecha_fin = datetime.utcnow()
        else:
            print("Iniciando carga incremental")
            max_start_time = obtener_max_start_time(engine)
            if max_start_time is None:
                print("No se encontró fecha máxima. Realizando carga histórica.")
                cargar_datos(engine, "historical")
                return
            fecha_inicio = max_start_time
            fecha_fin = datetime.utcnow()

        uri = "metadata/monitoringhub/histories"
        params = {
            "endTime": fecha_fin.isoformat() + 'Z',
            "startTime": fecha_inicio.isoformat() + 'Z',
            "limit": 50000,
        }

        datos = invocar_api_fabric("GET", uri, params=params)
        if 'error' in datos:
            print(f"Error al obtener datos: {datos['error']}")
            return

        print(f"Datos obtenidos: {len(datos)} registros")
        df = normalizar_datos(datos)
        df_refinado = refinar_datos(df)

        if tipo_carga == "incremental":
            df_existente = obtener_datos_existentes(engine, fecha_inicio)
            df_refinado_existente = refinar_datos(df_existente)
            df_refinado = pd.concat([df_refinado_existente, df_refinado]).drop_duplicates(keep=False)

        guardar_dataframe_en_bd(df_refinado, engine, 'logs')
        print(f"Finalizada la carga {tipo_carga}")
     
     
  • mtoarantes's avatar
    mtoarantes
    Regular Visitor
    def crear_sesion():
        """Crea una sesión de requests con reintentos"""
        sesion = requests.Session()
        reintentos = Retry(total=3, backoff_factor=5, status_forcelist=[502, 503, 504])
        adaptador = HTTPAdapter(max_retries=reintentos)
        sesion.mount('http://', adaptador)
        sesion.mount('https://', adaptador)
        return sesion
    
    SESION = crear_sesion()
    
    def invocar_api_fabric(metodo, uri, params=None, payload=None):
        """Invoca la API de Fabric y maneja la paginación si es necesario"""
        token = obtener_token()
        headers = {
            "Authorization": f"Bearer {token}",
            "Content-Type": "application/json"
        }
        
        todos_los_datos = []
        token_continuacion = None
    
        try:
            while True:
                if token_continuacion:
                    params['continuationToken'] = token_continuacion
                
                url = f"https://{API_ENDPOINT}/{uri}"
                respuesta = SESION.request(metodo, url, headers=headers, params=params, json=payload, timeout=800)
                respuesta.raise_for_status()
                datos_respuesta = respuesta.json()
                
                if isinstance(datos_respuesta, list):
                    todos_los_datos.extend(datos_respuesta)
                else:
                    todos_los_datos.extend(datos_respuesta.get('value', []))
                    token_continuacion = datos_respuesta.get('continuationToken')
                
                if not token_continuacion:
                    break
    
            return todos_los_datos
  • mtoarantes's avatar
    mtoarantes
    Regular Visitor

    Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x754daa1eed50>, 'Connection to wabi-us-east-redirect.analysis.windows.net timed out. (connect timeout=800)')': /metadata/monitoringhub/histories?endTime=2025-02-21T15%3A27%3A49.520096Z&startTime=2025-02-01T00%3A00%3A00Z&limit=50000