The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredAsk the Fabric Databases & App Development teams anything! Live on Reddit on August 26th. Learn more.
Hi,
I started experimenting with the user data functions preview and have a notebook with these two cells:
notebookutils.udf.run(
workspaceId='c5081853-1a86-4717-a662-5ff68bc123e1',
capacityId='F64D31D6-DF40-4EDD-9C79-66E1BB3088C4',
artifactId='8323a337-30dd-4dd4-a835-d2d950e4fcdd',
functionName='hello_fabric',
# UPDATE HERE: Update the request body based on the inputs to your function
parameters={
"name": "string"
}
)
atu = notebookutils.udf.getFunctions("uf-a-fabric-atu-userfunctions", "c5081853-1a86-4717-a662-5ff68bc123e1")
print(atu.hello_fabric("test"))
The first one was generated by the UDF object's "Generate invocation code" feature, the second is code I wrote using the documentation here https://learn.microsoft.com/en-us/fabric/data-engineering/notebook-utilities#user-data-function-udf-...
The first version executes correctly and returns
'{"functionName": "hello_fabric", "invocationId": "b64fa986-4964-4476-b8ac-102dae1d20fb", "status": "Succeeded", "output": "Welcome to Fabric Functions, string, at 2025-04-28 12:40:22.923473!", "errors": []}'
But that code is rather verbose if you want to include it in the rest of the notebook code, the second one has a much smaller footprint so would prefer to use that, but I'm getting the following error:
---------------------------------------------------------------------------
Py4JJavaError Traceback (most recent call last)
Cell In[20], line 1
----> 1 atu = notebookutils.udf.getFunctions("uf-a-fabric-atu-userfunctions", "c5081853-1a86-4717-a662-5ff68bc123e1")
3 print(atu.hello_fabric("test"))
File ~/cluster-env/trident_env/lib/python3.11/site-packages/notebookutils/udf.py:18, in getFunctions(udf, workspaceId)
6 def getFunctions(udf: str, workspaceId: str = "") -> UDF:
7 """
8 Get the User data functions (UDF).
9 :param udf: The UDF artifact id or name.
(...)
16 myFunctions.multiply(1, 2, 3) # call function multiply
17 """
---> 18 return _udf.getFunctions(udf, workspaceId)
File ~/cluster-env/trident_env/lib/python3.11/site-packages/notebookutils/mssparkutils/handlers/udfHandler.py:34, in UdfHandler.getFunctions(self, artifact, workspace_id)
32 if not workspace_id:
33 workspace_id = self.getCurrentWorkspaceId()
---> 34 metadata = self.jvm.notebookutils.udf.getMetadataStr(artifact, workspace_id)
35 metadata = json.loads(metadata)
36 name = metadata.get("displayName", "")
File ~/cluster-env/trident_env/lib/python3.11/site-packages/py4j/java_gateway.py:1322, in JavaMember.__call__(self, *args)
1316 command = proto.CALL_COMMAND_NAME +\
1317 self.command_header +\
1318 args_command +\
1319 proto.END_COMMAND_PART
1321 answer = self.gateway_client.send_command(command)
-> 1322 return_value = get_return_value(
1323 answer, self.gateway_client, self.target_id, self.name)
1325 for temp_arg in temp_args:
1326 if hasattr(temp_arg, "_detach"):
File /opt/spark/python/lib/pyspark.zip/pyspark/errors/exceptions/captured.py:179, in capture_sql_exception.<locals>.deco(*a, **kw)
177 def deco(*a: Any, **kw: Any) -> Any:
178 try:
--> 179 return f(*a, **kw)
180 except Py4JJavaError as e:
181 converted = convert_exception(e.java_exception)
File ~/cluster-env/trident_env/lib/python3.11/site-packages/py4j/protocol.py:326, in get_return_value(answer, gateway_client, target_id, name)
324 value = OUTPUT_CONVERTER[type](answer[2:], gateway_client)
325 if answer[1] == REFERENCE_TYPE:
--> 326 raise Py4JJavaError(
327 "An error occurred while calling {0}{1}{2}.\n".
328 format(target_id, ".", name), value)
329 else:
330 raise Py4JError(
331 "An error occurred while calling {0}{1}{2}. Trace:\n{3}\n".
332 format(target_id, ".", name, value))
Py4JJavaError: An error occurred while calling z:notebookutils.udf.getMetadataStr.
: java.lang.Exception: Request to https://api.fabric.microsoft.com/metadata/artifacts/8323a337-30dd-4dd4-a835-d2d950e4fcdd failed with status code: 403, response:{"error":{"code":"InvalidRequest","message":"Tenant not authorized for cluster"}}, response headers: Array(Cache-Control: no-store, must-revalidate, no-cache, Pragma: no-cache, Transfer-Encoding: chunked, Content-Type: application/json; charset=utf-8, Strict-Transport-Security: max-age=31536000; includeSubDomains, X-Frame-Options: deny, X-Content-Type-Options: nosniff, RequestId: 58337236-b25b-477c-b10f-5a202539f119, Access-Control-Expose-Headers: RequestId, Date: Mon, 28 Apr 2025 12:43:35 GMT)
at com.microsoft.spark.notebook.workflow.client.FabricClient.getEntity(FabricClient.scala:70)
at com.microsoft.spark.notebook.workflow.client.BaseRestClient.get(BaseRestClient.scala:59)
at com.microsoft.spark.notebook.msutils.impl.fabric.MSArtifactUtilsImpl.getMetadata(MSArtifactUtilsImpl.scala:239)
at com.microsoft.spark.notebook.msutils.impl.fabric.UdfUtilsImpl$.getMetadata(UdfUtilsImpl.scala:149)
at notebookutils.udf$.$anonfun$getMetadataStr$1(udf.scala:78)
at com.microsoft.spark.notebook.common.trident.CertifiedTelemetryUtils$.withTelemetry(CertifiedTelemetryUtils.scala:82)
at notebookutils.udf$.getMetadataStr(udf.scala:76)
at notebookutils.udf.getMetadataStr(udf.scala)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:374)
at py4j.Gateway.invoke(Gateway.java:282)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:238)
at java.base/java.lang.Thread.run(Thread.java:829)
Any idea what's causing this?
Solved! Go to Solution.
Hi @sushiat ,
Sorry to know it didn’t help. Please consider reaching out to Microsoft Support. You can provide them with all the troubleshooting steps you've already taken, which will help them understand the issue better and provide a resolution. They might be able to identify something specific about your admin account setup or provide a solution that isn't immediately obvious.
Below is the link to create Microsoft Support ticket:
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn
Thank you
Hi @sushiat ,
We are following up once again regarding your query. Could you please confirm if the issue has been resolved through the support ticket with Microsoft?
If the issue has been resolved, we kindly request you to share the resolution or key insights here to help others in the community. If we don’t hear back, we’ll go ahead and close this thread.
Should you need further assistance in the future, we encourage you to reach out via the Microsoft Fabric Community Forum and create a new thread. We’ll be happy to help.
Thank you for your understanding and participation.
Hi @sushiat
Could you please confirm if the issue has been resolved after raising a support case? If a solution has been found, it would be greatly appreciated if you could share your insights with the community. This would be helpful for other members who may encounter similar issues.
Thank you for your understanding and assistance.
Any update about this issue, I am having the same problem 😕
Hi @sushiat ,
Thanks for reaching out to the Microsoft fabric community forum.
I tried to replicate your exact scenario at my end and both the codes successfully ran.
The error you are receiving is most likely because the UDF feature is still in preview.
Please try creating a new UDF artifact, then update your notebook to reference the new artifact and re-run the two cells. This can help rule out any issues related to the original artifact configuration.
If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thank you
Thanks for testing it out, created a second UDF object, tried from another workspace. Created a third UDF in another workspace, same result every time. Original attempt had one added library, second and third had only the demo function, nothing else.
Not quite sure why it happens. Guess for now just have to wait for some update to fix it as I couldn't find any limitations or known issues about it.
Hi @sushiat ,
Sorry to know it didn’t help. Please consider reaching out to Microsoft Support. You can provide them with all the troubleshooting steps you've already taken, which will help them understand the issue better and provide a resolution. They might be able to identify something specific about your admin account setup or provide a solution that isn't immediately obvious.
Below is the link to create Microsoft Support ticket:
How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn
Thank you
User | Count |
---|---|
5 | |
2 | |
2 | |
2 | |
2 |
User | Count |
---|---|
12 | |
8 | |
7 | |
6 | |
6 |