Forum Discussion
Mounting NB on- the-fly
I am running some codes in a standalone notebook that is currently giving me the following error
Spark SQL queries are only possible in the context of a lakehouse. Please attach a lakehouse to proceed
How can I progrmaatically mount/add a lakehouse to a NB prior to execution of that code. I tried following
notebookutils.fs.mount('abfss://[email protected]/lh_id','/lakehouse/default')
and then I tried running the spark code which still gave me the same error as above.
Is it doable?
10 Replies
- frithjof_vCommunity Champion
Hopefully something in this blog post can help achieving what you request: https://fabric.guru/how-to-mount-a-lakehouse-and-identify-the-mounted-lakehouse-in-fabric-notebook
- smpa01Community Champion
This post describes how to mount a NB which is exactly similar to what I have provided (good so far)
but it does not execute a code in a Notebook manually attached to a Lakehouse would have successfully executed otherwise.
The objective of progrmatic mounting is to see if the succedding code executes correctly as it would have in a manually attached lakehouse.
- frithjof_vCommunity Champion
I see, I will do a test on my side if I find the time to do the test.
Btw I see you are using notebookutils whereas the blog post is using mssparkutils.
Will it work if you use mssparkutils instead of notebookutils?
- smpa01Community Champion
frithjof_v thanks for all this. Give me a day or two to get back