Forum Discussion
Error when getting the workspace name from a notebook
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.
- v-hashadapu1 year agoCommunity Support
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.
- dbeavon31 year agoMemorable Member
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.
- v-hashadapu1 year agoCommunity Support
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.