Forum Discussion
Operation returned an invalid status code 'Unauthorized' while copying data to Lakehouse
This seems like a fabric platform issue and fabric regression, not your config. Microsoft recently changed the Lakehouse destination to require a Lakehouse connection, and that connection now uses OAuth only. Pipelines cannot refresh oauth tokens, so once your user token expires, the copy activity fails with Unauthorized when writing to OneLake. It is not related to SAP hana/permissions.
Workarounds that you can try:
Avoid using the new Lakehouse connection (use manual table entry if still available).
Recreate the conn before each run (temp).
Raise a support ticket because the change broke non interactive pipeline loads.
- SivaReddy246808 months agoAdvocate I
Vinodh247 Thanks for replying.
I'm trying the workarounds that you suggested
1. The connection still seems to be mandatory. Even when the Lakehouse is attached directly, Fabric asks for a connection to be created.
2. This approach works for small tables that run in a loop(can you please provide some info or document on how to refresh token using pipeline), but for large-volume tables the token expires in the middle of the extraction. We are planning to load these tables in chunks based on the date fields to avoid the issue.
- Vinodh2478 months agoSuper User
I am afraid there is no doc on “refreshing token using pipeline” because fabric does not support it. Oauth tokens for lakehouse conne are user based and expire silently during long running copy operations.
- v-nmadadi-msft8 months agoCommunity Support
Hi SivaReddy24680 ,
Thanks for reaching out to the Microsoft fabric community forum.
In addition to the valuable points suggested by Vinodh247 , Check out this point as well.Please ensure that for the Lakehouse you are trying to copy data into, you have the correct workspace role assigned in the workspace where that Lakehouse exists. The role should be Contributor, Member, or Admin, Viewer is not sufficient for write operations.
I hope this information helps. Please do let us know if you have any further queries.
Thank you- SivaReddy246808 months agoAdvocate I
I have the Admin role for the workspace. We are not encountering this error at the beginning of the process, it occurs intermittently after writing some records.