Forum Discussion

Mestu_Paul's avatar
Mestu_Paul
Helper II
9 months ago
Solved

How to create semantic model from lakehouse sql endpoint using REST API

I want to create semantic model using rest api from Lakehouse SQL point or tables but dont find any documentation to create semantic model using REST API. 

Can anyone help me to create semantic model from lakehouse (sql endpoint or files or tables) using REST API

  • Hello again Mestu_Paul - Do you have a specific requirement to use a lakehouse SQL analytics endpoint and REST API?

     

    If you are really just wanting to create a semantic model using a lakehouse as a source, then this is a good end-to-end tutorial of direct lake for Power BI users: https://learn.microsoft.com/en-us/power-bi/fundamentals/fabric-get-started

     

    If you connect PowerBI to the lakehouse as a lakehouse (which is stored in OneLake), the storage mode for the model will be direct lake.  This will allow you to avoid the SQL analytics endpoint and REST APIs, which simplifies the process and provides a more reliable and performant connection. 

     

    The tutorial demonstrates creating the model from within the lakehouse, which means it is created in the cloud. 

    If you prefer using PowerBI desktop, see this page: Learn About Editing Semantic Models in Direct Lake in Power BI Desktop - Microsoft Fabric | Microsoft Learn

     

    I still recommend going through the tutorial though as it shows how to leverage other helpful Fabric artifacts as well. 

     

  • Hi Mestu_Paul I completely agree with the information provided by jennratten, however, it does not address your actual request  ๐Ÿ‘‰ "How to create semantic model from lakehouse sql endpoint using REST API" (I don't need to know your reasons, just going to answer your question ๐Ÿ˜…

     

    Well, you will need several things, to achieve the creation of a semantic model via API...

     

    #1. Access to Fabric via Auth. token in this repository, in this article The TMSL to TMDL Switch (Part 2): I Did My Homework!  there's the link to a Git repository whit an example that works! I use Power shell 

     

    #2. You need to define your semantic model in either  TMSL (JSON) or TMDL (YAML-like), what this means is the you need to actually have JSON files as shown in this example using the TMSL format, you can also see that in the model.bim there's the ACTUAL CONNECTION TO THE Lakehouse SQL point  !!! 

     

     

    #3. You need to encode this files as 64-bit strings and call the API interface Items - Create Semantic Model - REST API (SemanticModel) | Microsoft Learn  with the encoding string as the payload in each of the parts 

    And BUM! You create a semantic model using API ... Of course to make an actual version of this process requieres some coding, but the code I'm sharing on the repo in my article will GIVE YOU A BIG PUSH IN THE RIGHT DIRECTION. 

     

    So, your question has been ANSWERED! This is how you create a semantic model using the API ... please mark this as the answer and kudos for the information would be appreciated. 

     

     

     

7 Replies

  • Hi Mestu_Paul I completely agree with the information provided by jennratten, however, it does not address your actual request  ๐Ÿ‘‰ "How to create semantic model from lakehouse sql endpoint using REST API" (I don't need to know your reasons, just going to answer your question ๐Ÿ˜…

     

    Well, you will need several things, to achieve the creation of a semantic model via API...

     

    #1. Access to Fabric via Auth. token in this repository, in this article The TMSL to TMDL Switch (Part 2): I Did My Homework!  there's the link to a Git repository whit an example that works! I use Power shell 

     

    #2. You need to define your semantic model in either  TMSL (JSON) or TMDL (YAML-like), what this means is the you need to actually have JSON files as shown in this example using the TMSL format, you can also see that in the model.bim there's the ACTUAL CONNECTION TO THE Lakehouse SQL point  !!! 

     

     

    #3. You need to encode this files as 64-bit strings and call the API interface Items - Create Semantic Model - REST API (SemanticModel) | Microsoft Learn  with the encoding string as the payload in each of the parts 

    And BUM! You create a semantic model using API ... Of course to make an actual version of this process requieres some coding, but the code I'm sharing on the repo in my article will GIVE YOU A BIG PUSH IN THE RIGHT DIRECTION. 

     

    So, your question has been ANSWERED! This is how you create a semantic model using the API ... please mark this as the answer and kudos for the information would be appreciated. 

     

     

     

    • Mestu_Paul's avatar
      Mestu_Paul
      Helper II

      Hello svenchio,

      Thank you for your response. Actually I want to create semantic model from lakehouse table or sql endpoint.

      You write about creating semantic model using rest api, but I need to use lakehouse as datasource.  I'm clarifying in main post again

  • Hello again Mestu_Paul - Do you have a specific requirement to use a lakehouse SQL analytics endpoint and REST API?

     

    If you are really just wanting to create a semantic model using a lakehouse as a source, then this is a good end-to-end tutorial of direct lake for Power BI users: https://learn.microsoft.com/en-us/power-bi/fundamentals/fabric-get-started

     

    If you connect PowerBI to the lakehouse as a lakehouse (which is stored in OneLake), the storage mode for the model will be direct lake.  This will allow you to avoid the SQL analytics endpoint and REST APIs, which simplifies the process and provides a more reliable and performant connection. 

     

    The tutorial demonstrates creating the model from within the lakehouse, which means it is created in the cloud. 

    If you prefer using PowerBI desktop, see this page: Learn About Editing Semantic Models in Direct Lake in Power BI Desktop - Microsoft Fabric | Microsoft Learn

     

    I still recommend going through the tutorial though as it shows how to leverage other helpful Fabric artifacts as well. 

     

  • Mestu_Paul Thanks for the kudo! If this post helps to answer your questions, please consider marking it as a solution so others can find it more quickly when faced with a similar challenge.

     

    Proud to be a Microsoft Fabric Super User!

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

    Hi Mestu_Paul,

     

    Thank you svenchio  and svenchio  for your response to the query,


    Has your issue been resolved?

    If the response from the community member answered your query, please consider confirming it. If you have any further questions, feel free to reach out!

    Thank you.

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

    Hi Mestu_Paul,

     

    Just wanted to follow up and confirm that everything has been going well on this. Please let me know if thereโ€™s anything from our end.
    Please feel free to reach out Microsoft fabric community forum.