Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
I have deployed a semantic model in fabric workspace in import mode and when I try to refresh, it is giving an error "We cannot refresh this semantic model because this semantic model uses a default data connection without explicit connection credentials. Please replace the default data connection in the semantic model settings with an explicit cloud or gateway data connection.". I am able to refresh the model only if I update the cloud connection manually in settings. Is there any way we can automate this process of updating the connection using API's, if the required connection is already available in the workspace?
Solved! Go to Solution.
Hi @mamatha5195 You will have to use the Power BI REST API endpoints with a Python script to handle updating the data source credentials. For automation, I think Power Automate or Azure Functions would be suitable to trigger the script periodically or based on events.
Hi @mamatha5195 ,
Thank you for the follow-up.I would be be happy to assist you!
At the moment, sempy.fabric does not support updating data source credentials or changing connections. It is mainly for querying and working with the semantic model itself , not managing its connections. So as mentioned earlier, the Power BI REST APIs are the only APIs currently available for that purpose.
I hope this helps.If so,consider accepting it as solution.
Hi @mamatha5195 ,
Thank you @Akash_Varuna for the helpful response!
The error occurs because the semantic model uses a default connection without explicit credentials, which requires manual updating. To automate this, you have to use Power BI REST APIs as suggested by Akash. Then, use the PATCH /groups/{groupId}/datasets/{datasetId}/datasources API to update the data source.This process can be Python scripted . Make sure the caller has Contributor access.
Here is the API reference for more details. https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/update-datasources-in-group
Thank you.
Regards,
Pallavi.
Hi @mamatha5195 ,
Thank you for the follow-up.I would be be happy to assist you!
At the moment, sempy.fabric does not support updating data source credentials or changing connections. It is mainly for querying and working with the semantic model itself , not managing its connections. So as mentioned earlier, the Power BI REST APIs are the only APIs currently available for that purpose.
I hope this helps.If so,consider accepting it as solution.
I am using below API to map the connection ID and recieving errors that the resource is not available in the URL. But for requests.get() I am able to get the existing datasource details. Please let me know if the API works for patch.
update_payload = {
"datasources": [
{
"datasourceId": datasource_id
}
]
}
url = f"https://api.powerbi.com/v1.0/myorg/groups/{target_workspace_id}/datasets/{target_model_id}/datasourc..."
response = requests.patch(url, json=update_payload, headers=headers)
if response.status_code == 200:
print("Dataset successfully mapped to the specific connection.")
else:
print(f"Error: {response.status_code}")
print(response.json())
Hi @mamatha5195 You will have to use the Power BI REST API endpoints with a Python script to handle updating the data source credentials. For automation, I think Power Automate or Azure Functions would be suitable to trigger the script periodically or based on events.