Forum Discussion

UmeshGoti's avatar
UmeshGoti
Helper I
1 year ago
Solved

While Creating Semantic Layer in directQuery Mode Need to attach with database

Hello Community,

 

As part of report migration project from other technologies to PowerBi. i am using Fabric Rest APIs (https://learn.microsoft.com/en-us/rest/api/fabric/semanticmodel/items/create-semantic-model?tabs=HTTP&tryIt=true&source=docs#code-try-0)
to create semantic layer in directQuery Mode. 
And i am using below "model.bim" JSON configuration for connecting with database
but here i don't see any option to provide database username and password
so when i open this dataset from power bi service it gives popup like "The datasource is missing credentials and cannot be accessed"

now my requirement is somehow i need to pass database username and password along with model.bim JSON
so semantic layer will already get connected with database and we can create visual report directly

 

"partitions": [{
"name": "Applications",
"mode": "directQuery",
"source": {
"type": "m",
"expression": [
"let",
" Source = Sql.Database(\"xxx-xxxx..database.windows.net\", \"database_name\"),",
" dbo_Applications = Source{[Schema=\"dbo\",Item=\"country\"]}[Data]",
"in",
" dbo_Applications"
]
}
}
]

 

 

  • Hi. Like the UI after you publish a new semantic model, the first thing would be edit it's credentials at the settings of configure a gateway. Using the API for changing data source or creating a new semantic model is the same here. Until a month or two it was mandatory to do it at the UI. Nowadays there is a Fabric Rest API request that might let you write the credentials. I haven't tested yet how it works but I know it's preview. You can try it if you want to keep all in code: https://learn.microsoft.com/en-us/rest/api/fabric/core/connections/update-connection?tabs=HTTP

    I hope that helps,

5 Replies

  • Hi. Like the UI after you publish a new semantic model, the first thing would be edit it's credentials at the settings of configure a gateway. Using the API for changing data source or creating a new semantic model is the same here. Until a month or two it was mandatory to do it at the UI. Nowadays there is a Fabric Rest API request that might let you write the credentials. I haven't tested yet how it works but I know it's preview. You can try it if you want to keep all in code: https://learn.microsoft.com/en-us/rest/api/fabric/core/connections/update-connection?tabs=HTTP

    I hope that helps,

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi UmeshGoti,

       

      we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
      If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

       

      Regards,

      Vinay Pabbu

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi UmeshGoti,

         

        May I ask if you have gotten this issue resolved?

        If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.

         

        Regards,

        Vinay Pabbu

  • Thanks ibarrau  for your suggestions

    i am trying to explore update connection api there we need to pass connection id 
    but in our case i have created semantic layer so i have  dataset id that's where not getting idea what connection id we need to pass to update database credentials in created semantic layer

    let me know if you could find something !! that will help me a lot 

    Thanks in Advance !!!