Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I'm just trying to get the workspace name from a workbook with notebookutils and it is choking and dying.
This error happens when running the notebook as a service principal.
this_workspace_name = notebookutils.mssparkutils.env.getWorkspaceName()
... Results in:
Py4JJavaError: An error occurred while calling z:mssparkutils.env.getWorkspaceName.
: org.apache.http.client.HttpResponseException: status code: 403
org.apache.http.client.HttpResponseException: status code: 403, reason phrase: Non HTTP 200 response code. StatusCode=403 Reason=Forbidden
Hi @dbeavon3 , hope you are doing well. may i know if the information provided here solved your issue or if you have raised the support ticket as suggested? If your issue's solved either way, please share the insights here, so others with similar issues may find the solution easily.
Thank you.
Hi @dbeavon3 ,
You can use this, to retrive current workspace name.
notebookutils.runtime.context.currentWorkspaceName()
Ref : https://learn.microsoft.com/en-us/fabric/data-engineering/notebook-utilities#runtime-utilities
That is helpful. I'll test. I'm assuming it works in both python notebooks and pyspark?
Hi @dbeavon3 , Thank you for reaching out to the Microsoft Community Forum.
This is happening because notebookutils.mssparkutils.env.getWorkspaceName() makes an internal API call to fetch workspace metadata, which service principals can’t access by default. In Microsoft Fabric, service principals don’t have implicit rights to read workspace context, this includes the workspace name, even if they have access to the Lakehouse or notebooks.
To resolve it, go to the Fabric workspace and assign the service principal a Contributor or Admin role at the workspace level via the access control settings. This gives it the necessary control plane permissions to access metadata APIs used by that utility function.
If updating permissions isn’t an option, inject the workspace name into the notebook manually using a parameter or environment variable. This avoids the API call entirely and works reliably in service principal contexts.
Hi @v-hashadapu
Do you have a reference/link with that information? Is there a known issue? Is it by design? I don't think it is true that service principals are restricted, as compared to normal users. It has not been my experience.
FYI, The service principals are already full admins.
This may be a bug. I found some other related discussions on another forum, but it was quite old (maybe a year?) Is it possible that this sort of bug would remain unfixed for another year? If so, I think Microsoft should provide some documentation about this bug in the meantime. Perhaps they should use their "known issues" list.
Hi @dbeavon3 , We apologize for the inconvenience. This issue has been documented among the known issues as of April 2025. Our support team is actively working to resolve it as quickly as possible. If you have any additional questions, please feel free to open a new thread in the community. We are here to assist you.
Thank you for your co-operation.
Hi @v-hashadapu
Do you have a link ? I don't think it was documented on the known issues page or I would not have asked.
It seems doubtful that they are working as quickly as possible. I saw others mentioning this issue, and it looks like their posts are very old.
Hi @dbeavon3 , We understand the inconvenience this is causing you and others and we are actively working on resolving the issue as soon as possible.
Regarding the link to this issue in the Known Issues section, it is not public yet. However, I can assure you that our support team has added this matter to their Known Issues list and is working on a solution.
Thank you for your patience and understanding.
Please add it to the public known issues list or the PG will never prioritize it. As I said the prior discussions about this problem are very old.
This seems like a fairly simple issue, and it seems silly that it is dragging on so long.
Hi @dbeavon3 , we understand the inconvinience. We suggest you contact the support team to get the faster solution to the issue. You can reach them by raising a Microsoft Support ticket .
Below is the link to help create Microsoft Support ticket:
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn