Forum Discussion
Fabric activity(Notebook) failed. 'An item with the same key has already been added.
Hi
We are currently encountering an issue while running notebooks through the pipeline. This problem has started occurring recently. It appears that earlier the notebooks were using the default notebook connection provided by Fabric. However, after the recent update, the notebooks have begun using a different connection. This new connection supports only Service Principal authentication.
Is this because of the Service Principal Auth method.?
Thanks
Hello Siva I'm guessing you're using a SPN for the notebook connection. Have you switched to SPN based connection recently? It is quite possible that you're experiencing this problem because the SPN you used in the connection have been used somewhere else.
If there are multiple Connections referencing the same SPN (or duplicate parameter keys/headers in the activity), Fabric can throw 2015 / duplicate key at runtime.If possible, create a new SPN and try again, and let us know how it went!
6 Replies
- deborshi_nag
Super User
Hello Siva I'm guessing you're using a SPN for the notebook connection. Have you switched to SPN based connection recently? It is quite possible that you're experiencing this problem because the SPN you used in the connection have been used somewhere else.
If there are multiple Connections referencing the same SPN (or duplicate parameter keys/headers in the activity), Fabric can throw 2015 / duplicate key at runtime.If possible, create a new SPN and try again, and let us know how it went!
- SivaReddy24680
Advocate I
Hi deborshi_nag
Thank you for your response. I tried deleting the existing connection and creating a new one, however this did not resolve the issue. Since the connection for the Notebook activity is not mandatory, I removed the connection configuration and the pipeline executed successfully afterward.
- deborshi_nag
Super User
Hello SivaReddy24680
Once the Fabric Connection is created and bound to the current notebook, you can generate code snippets to access the data source directly from the notebook.
Fabric Connection with Notebook - Microsoft Fabric | Microsoft Learn
Can you try this please.
- bariscihan
Resolver II
Hi,
After reviewing the error “An item with the same key has already been added”, this is typically not a notebook runtime issue itself, but a connection configuration conflict in the pipeline activity.
From what I can see, the problem started after the notebook began using a Service Principal–based connection instead of the default Fabric notebook connection. When a custom connection is attached to a Notebook activity, Fabric internally maps connection parameters (headers/keys). If the same key is already defined elsewhere (for example in another connection, linked resource, or implicit default settings), it can trigger this duplicate key exception at runtime.
Here’s what worked for me and why:
✔ The Notebook activity does not require an explicit connection configuration when it runs within the same workspace context.
✔ Removing the custom Service Principal connection from the Notebook activity eliminated the duplicate key registration.
✔ After removing the connection configuration, the pipeline executed successfully.So the recommended approach is:
Remove the explicit connection from the Notebook activity unless cross-workspace or cross-tenant access is required.
Let the notebook use the default Fabric workspace identity.
Only use a Service Principal connection when accessing external resources that truly require it.
If SPN is required, ensure it is not reused in multiple connections with overlapping parameter definitions.
This appears to be a configuration-level duplication rather than an authentication failure.
Hope this helps others facing the same issue.
Thanks.
- SivaReddy24680
Advocate I
Thank You for the Information.