Forum Discussion

Mestu_Paul's avatar
Mestu_Paul
Icon for Helper II rankHelper II
10 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 mo...
  • jennratten's avatar
    10 months ago

    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. 

     

  • svenchio's avatar
    10 months ago

    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.