<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Azure Pipeline - Lookup and CopyData in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Azure-Pipeline-Lookup-and-CopyData/m-p/4342540#M5763</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/648442"&gt;@Tom_CA&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While I can't get the Json output of the Lookup activity directly through the data pipeline, I do have a workaround to store the JSON output of the lookup activity in a file in Lakehouse.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please follow my steps to do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, run the Lookup activity successfully in the pipeline.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_5-1735095598908.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1219451i83A1304A6E1B92D7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_5-1735095598908.png" alt="vhuijieymsft_5-1735095598908.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, copy the output json result.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_0-1735095384735.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1219445i27BFE11A744C51D5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_0-1735095384735.png" alt="vhuijieymsft_0-1735095384735.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the following code to save the output json result as a temporary file. Please replace the parts I marked with your own json output.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;import json
import os
import shutil

# Define example schema with more columns
test = {
    "firstRow": {
        "SalesOrderNumber": "SO51555",
        "SalesOrderLineNumber": 7,
        "OrderDate": "2021-06-23T00:00:00Z",
        "CustomerName": "Chloe Garcia",
        "Email": "chloe27@adventure-works.com",
        "Item": "Patch Kit/8 Patches",
        "Quantity": 1,
        "UnitPrice": 2.29,
        "Tax": 0.1832
    }
}

# Write to temporary file
temp_path = "/tmp/test.json"
with open(temp_path, 'w') as f:
    json.dump(test, f)

print(f"Schema temporarily saved to {temp_path}")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_1-1735095409503.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1219446iDEA72F8B725E2060/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_1-1735095409503.png" alt="vhuijieymsft_1-1735095409503.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the following code to save it to the file section of lakehouse, where the path uses the File API Path.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# File API path
lakehouse_dir = "/lakehouse/default/Files/"
lakehouse_path = lakehouse_dir + "test.json"

if not os.path.exists(lakehouse_dir):
    os.makedirs(lakehouse_dir)

# Use shutil.copy to copy files to the target location
shutil.copy(temp_path, lakehouse_path)

print(f"Schema saved to {lakehouse_path}")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_2-1735095442067.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1219448i565A4E1A909C339E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_2-1735095442067.png" alt="vhuijieymsft_2-1735095442067.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_3-1735095442068.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1219447i9EE58E2320B58591/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_3-1735095442068.png" alt="vhuijieymsft_3-1735095442068.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally you can use this code to see if your stored json output is correct.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;import json
import pandas as pd

# set Lakehouse path
lakehouse_path = "/lakehouse/default/Files/test.json"

# use pandas to read JSON file
df = pd.read_json(lakehouse_path, orient='records', lines=True)

schema_loaded = json.loads(df.to_json(orient='records'))

print("Loaded schema:")
print(json.dumps(schema_loaded, indent=4))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_4-1735095466232.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1219449iD460CFAA82B215E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_4-1735095466232.png" alt="vhuijieymsft_4-1735095466232.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By using notebook, you'll be able to save the json file in lakehouse's file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any other questions please feel free to contact me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Dec 2024 03:00:17 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-12-25T03:00:17Z</dc:date>
    <item>
      <title>Azure Pipeline - Lookup and CopyData</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Azure-Pipeline-Lookup-and-CopyData/m-p/4342423#M5762</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello colleagues, I'm attempting to store the JSON output from my lookup activity in a file within my Lakehouse. I've experimented with the Copy Data activity, but it hasn't yielded the desired results. Could you suggest an effective method for saving the lookup activity's output to a file?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;There is no "inline" option as in Azure Data Factory.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Dec 2024 23:16:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Azure-Pipeline-Lookup-and-CopyData/m-p/4342423#M5762</guid>
      <dc:creator>Tom_CA</dc:creator>
      <dc:date>2024-12-24T23:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Azure Pipeline - Lookup and CopyData</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Azure-Pipeline-Lookup-and-CopyData/m-p/4342540#M5763</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/648442"&gt;@Tom_CA&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While I can't get the Json output of the Lookup activity directly through the data pipeline, I do have a workaround to store the JSON output of the lookup activity in a file in Lakehouse.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please follow my steps to do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, run the Lookup activity successfully in the pipeline.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_5-1735095598908.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1219451i83A1304A6E1B92D7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_5-1735095598908.png" alt="vhuijieymsft_5-1735095598908.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, copy the output json result.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_0-1735095384735.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1219445i27BFE11A744C51D5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_0-1735095384735.png" alt="vhuijieymsft_0-1735095384735.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the following code to save the output json result as a temporary file. Please replace the parts I marked with your own json output.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;import json
import os
import shutil

# Define example schema with more columns
test = {
    "firstRow": {
        "SalesOrderNumber": "SO51555",
        "SalesOrderLineNumber": 7,
        "OrderDate": "2021-06-23T00:00:00Z",
        "CustomerName": "Chloe Garcia",
        "Email": "chloe27@adventure-works.com",
        "Item": "Patch Kit/8 Patches",
        "Quantity": 1,
        "UnitPrice": 2.29,
        "Tax": 0.1832
    }
}

# Write to temporary file
temp_path = "/tmp/test.json"
with open(temp_path, 'w') as f:
    json.dump(test, f)

print(f"Schema temporarily saved to {temp_path}")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_1-1735095409503.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1219446iDEA72F8B725E2060/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_1-1735095409503.png" alt="vhuijieymsft_1-1735095409503.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the following code to save it to the file section of lakehouse, where the path uses the File API Path.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# File API path
lakehouse_dir = "/lakehouse/default/Files/"
lakehouse_path = lakehouse_dir + "test.json"

if not os.path.exists(lakehouse_dir):
    os.makedirs(lakehouse_dir)

# Use shutil.copy to copy files to the target location
shutil.copy(temp_path, lakehouse_path)

print(f"Schema saved to {lakehouse_path}")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_2-1735095442067.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1219448i565A4E1A909C339E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_2-1735095442067.png" alt="vhuijieymsft_2-1735095442067.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_3-1735095442068.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1219447i9EE58E2320B58591/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_3-1735095442068.png" alt="vhuijieymsft_3-1735095442068.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally you can use this code to see if your stored json output is correct.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;import json
import pandas as pd

# set Lakehouse path
lakehouse_path = "/lakehouse/default/Files/test.json"

# use pandas to read JSON file
df = pd.read_json(lakehouse_path, orient='records', lines=True)

schema_loaded = json.loads(df.to_json(orient='records'))

print("Loaded schema:")
print(json.dumps(schema_loaded, indent=4))&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vhuijieymsft_4-1735095466232.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1219449iD460CFAA82B215E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vhuijieymsft_4-1735095466232.png" alt="vhuijieymsft_4-1735095466232.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By using notebook, you'll be able to save the json file in lakehouse's file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any other questions please feel free to contact me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Dec 2024 03:00:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Azure-Pipeline-Lookup-and-CopyData/m-p/4342540#M5763</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-25T03:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Azure Pipeline - Lookup and CopyData</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Azure-Pipeline-Lookup-and-CopyData/m-p/4343010#M5770</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hey @Anonymous&amp;nbsp;, thank you for your suggestion. It's really interesting, and I will implement it. I'd like to add some important observations about the process of passing parameters to the notebook:&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;String conversion: In my tests, it was necessary to convert the output to a string before passing it as a parameter to the notebook. This is crucial to ensure that the data is transmitted correctly.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Parsing in the notebook: If you want to work with a real JSON at the end of your process, it's essential to perform parsing in the notebook after receiving the output from the variable. This can be done as follows:&lt;/SPAN&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;Python&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;array_json &lt;SPAN class=""&gt;=&lt;/SPAN&gt; json&lt;SPAN class=""&gt;.&lt;/SPAN&gt;loads&lt;SPAN class=""&gt;(&lt;/SPAN&gt;JsonVar&lt;SPAN class=""&gt;)&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN&gt;Where 'JsonVar' is the parameter received in the notebook.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Complete flow:&lt;/SPAN&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Pipeline: Convert the Lookup output to a string.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Parameter passing: Use the string as a parameter for the notebook.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Notebook: Parse the string back into a JSON object.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN&gt;This process ensures that you can work with complex data structures while maintaining data integrity during the transfer between the pipeline and the notebook.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does that make sense? This approach provides flexibility and robustness when dealing with JSON data in Azure Data Factory or Synapse Analytics pipelines.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for your support.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Dec 2024 20:02:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Azure-Pipeline-Lookup-and-CopyData/m-p/4343010#M5770</guid>
      <dc:creator>Tom_CA</dc:creator>
      <dc:date>2024-12-25T20:02:18Z</dc:date>
    </item>
  </channel>
</rss>

