Forum Discussion

fabricpribeiro's avatar
fabricpribeiro
Post Patron
3 months ago
Solved

shortcuts - Refresh Method

Dears,

 

I have a report which is fed by my views.

 

This views query shortcut tables . The shorcuts point to another Fabric wokspace where the true tables are

 

Many times, when I open the report the information is gone and I need to refreseh the shorcuts manually to be able to see again the report

 

1) Is it expected that we have to refresh shortucs? this seems a bug on microsoft..

2) This report can be opened by any person at any time ... and I cannot be refrsehing this continuoulsy so that it works

3) What are you doing in a situation like this? are you using, for example a notebook and refreshing every 15 minutes?

4) What is the command (SQL or Python)  I need to use to refrseh the shorcuts which are inside a schema called Purview_DQRules?

 

Thanks,

 

Pedro

 

 

 

  • v-echaithra's avatar
    v-echaithra
    3 months ago

    Hi fabricpribeiro ,

    Thanks for the detailed clarification. Based on your answers, this appears closer to a SQL Analytics Endpoint metadata/cache synchronization issue over shortcut tables rather than expected shortcut behavior.

    The important observation is that even the shortcut tables themselves become empty until refreshed. That suggests the SQL Endpoint is temporarily losing visibility of the shortcut metadata/state.

    For the workaround, you can schedule a notebook against the Lakehouse containing the shortcuts/views and periodically refresh the metadata.
    You can try the following PySpark code in a Fabric notebook to refresh the shortcut tables metadata, you can start with a simple refresh:

    spark.sql("REFRESH TABLE Purview_DQRules.table_name")


    For multiple tables:


    tables = ["table1","table2","table3"]

    for t in tables:
    spark.sql(f"REFRESH TABLE Purview_DQRules.{t}")
    print(f"Refreshed {t}")


    The REST based MetadataRefreshExternalCommand shared earlier is also valid and refreshes the SQL Analytics Endpoint metadata more directly, which may be more effective in this scenario than only running REFRESH TABLE.

    Recommended frequency:

    Start with every 15 minutes
    If the issue persists, try every 5 minutes
    If stable, increase gradually to 30 minutes

    Best Regards

  • Hi fabricpribeiro  I read thru the conversation and I think the solution was to refresh the SQL Analytics Endpoint (SAE) metadata/cache on the source of the data and the community provided a couple of interest programatic solutions via yNotebooks, did it worked for you? Just curious since you have not accepted any solutions. If the solution is the refresh of the SAE and the question is wich alternatives are there to make it happend automatically and via schedule, I guess there's two: 

     

    #1. Calling the REST API  Programmatically Refresh & Sync SQL Analytics Endp... - Microsoft Fabric Communityvia Notebooks (seems mosth popular) ... fouind this blog post  from community member vojtechsima   well explain 

    Programmatically Refresh & Sync SQL Analytics Endp... - Microsoft Fabric Community

    #2. Calling new data pipeline activity  Refresh SQL Endpoint Activity - Microsoft Fabric | Microsoft Learn , this is currently in preview, but it works very well 😁  

     

    I guess it will looks something like this : 

     

    I guess there was already a a lot of good information on the current chat, hope you can mark the solution that works for you so the community is aware what worked! If you find this useful, a thumbs up would be nice 😉, proposed also as solution if appropiete. 

12 Replies

  • Great question — you're not alone in this!

    Is it a bug?

    No, it's expected behavior but poorly documented. The issue isn't the shortcut itself (that's a live pointer). The real culprit is the SQL Analytics Endpoint (SAE) metadata cache. Since your report reads through views, those views depend on the SAE layer. When the SAE goes idle (~15 min of inactivity), its metadata goes stale  that's why your report shows blank data until you manually refresh.

    The Fix

    Schedule a Fabric Notebook to auto-refresh the SAE metadata every 10–15 minutes. This is the most reliable, production-proven approach. 

    • fabricpribeiro's avatar
      fabricpribeiro
      Post Patron

      Thanks, which command should I put in the notebook? in order to refresh? also, is it in the LH which has the real data or the lakehouse which has the shorcuts and the views?

      • BHANUPURAM's avatar
        BHANUPURAM
        Advocate II

        Try this Sample code: replace the parameters with your workspaceid, lakehouse id etc 
        import sempy.fabric as fabric
        import json, time

         

        # Get workspace and lakehouse IDs
        workspace_id = spark.conf.get("trident.workspace.id")
        lakehouse_id = spark.conf.get("trident.lakehouse.id")

         

        # Get SQL Analytics Endpoint ID
        client = fabric.FabricRestClient()
        lakehouse_info = client.get(
            f"/v1/workspaces/{workspace_id}/lakehouses/{lakehouse_id}"
        ).json()
        sql_endpoint_id = lakehouse_info['properties']['sqlEndpointProperties']['id']

         

        # Trigger metadata refresh
        uri = f"/v1.0/myorg/lhdatamarts/{sql_endpoint_id}"
        payload = {"commands": [{"$type": "MetadataRefreshExternalCommand"}]}
        response = client.post(uri, json=payload)

         

        data = response.json()
        batch_id = data["batchId"]

         

        # Poll until complete
        status_uri = f"/v1.0/myorg/lhdatamarts/{sql_endpoint_id}/batches/{batch_id}"
        progress = data["progressState"]
        while progress == "inProgress":
            time.sleep(2)
            progress = client.get(status_uri).json()["progressState"]

         

        print(f"SAE Refresh completed with status: {progress}")
  • I am lost as I have here two different opnions. Can someone please help? I am not the only one which saw this issue on shorcuts I spoke as well with other people that say that from time to time they have to refreh their shorcuts. What to do?  and with which  SQL / phyton command? Thanks a lot

    • v-echaithra's avatar
      v-echaithra
      Community Support

      Hi fabricpribeiro ,

      In most cases, shortcuts should expose the latest data without requiring manual intervention. However, there are known scenarios where the SQL Analytics Endpoint metadata/cache over shortcut-based views becomes stale, especially after inactivity or upstream changes.

      A few clarifications that would help isolate the issue:

      Are the views created in the Lakehouse that contains the shortcuts?
      Is the semantic model using Direct Lake, DirectQuery, or Import?
      When the issue occurs, do the shortcut tables themselves show data, or only the views become blank?
      Does manually refreshing the SQL Analytics Endpoint/Lakehouse immediately resolve it?

      For production workloads, customers commonly use a scheduled notebook or pipeline as a workaround to refresh metadata periodically.

      • fabricpribeiro's avatar
        fabricpribeiro
        Post Patron

        Hello,

         

        Please find the answer to your questions below:

         

         

        A few clarifications that would help isolate the issue:

        Are the views created in the Lakehouse that contains the shortcuts? Yes
        Is the semantic model using Direct Lake, DirectQuery, or Import? Direct SQL  not Direct onelake as those are views not tables
        When the issue occurs, do the shortcut tables themselves show data, or only the views become blank?

        No, you have to refresh them as well , only after you see the data in the shorcuts and in the views


        Does manually refreshing the SQL Analytics Endpoint/Lakehouse immediately resolve it?  

        So far it did, its the first time today that even refreshing the shorcuts its not solving it

         

        For production workloads, customers commonly use a scheduled notebook or pipeline as a workaround to refresh metadata periodically.

        What is the code (python or SQL) to add into the notebook so that it does this refresh? and what is the frequency with which it should be refreshed?  

         

         

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi fabricpribeiro ,

    We’d like to follow up regarding the recent concern. Kindly confirm whether the issue has been resolved, or if further assistance is still required. We are available to support you and are committed to helping you reach a resolution.

    Thank you.

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi fabricpribeiro ,

    We wanted to kindly follow up regarding your query. If you need any further assistance, please reach out.
    Thank you.

  • Hi fabricpribeiro  I read thru the conversation and I think the solution was to refresh the SQL Analytics Endpoint (SAE) metadata/cache on the source of the data and the community provided a couple of interest programatic solutions via yNotebooks, did it worked for you? Just curious since you have not accepted any solutions. If the solution is the refresh of the SAE and the question is wich alternatives are there to make it happend automatically and via schedule, I guess there's two: 

     

    #1. Calling the REST API  Programmatically Refresh & Sync SQL Analytics Endp... - Microsoft Fabric Communityvia Notebooks (seems mosth popular) ... fouind this blog post  from community member vojtechsima   well explain 

    Programmatically Refresh & Sync SQL Analytics Endp... - Microsoft Fabric Community

    #2. Calling new data pipeline activity  Refresh SQL Endpoint Activity - Microsoft Fabric | Microsoft Learn , this is currently in preview, but it works very well 😁  

     

    I guess it will looks something like this : 

     

    I guess there was already a a lot of good information on the current chat, hope you can mark the solution that works for you so the community is aware what worked! If you find this useful, a thumbs up would be nice 😉, proposed also as solution if appropiete.