How to install nuget packages from ADLS to synapse notebooks ?

Radha Pusarapu (Ernst & Young LLP) 31 Reputation points Microsoft Vendor
2022-07-18T04:19:52.94+00:00

Hi,

Previously in our project we have used #r command to install the nuget packages.
But due to private endpoint restrictions we are unable to install directly.

Can anyone help me how can I use the nuget packages from ADLS primary storage to Synapse notebooks please

Thanks and Regards,
Radha Pusarapu

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,121 questions
{count} votes

1 answer

Sort by: Most helpful
  1. BhargavaGunnam-MSFT 23,931 Reputation points Microsoft Employee
    2022-08-03T03:38:30.693+00:00

    Hi @Radha Pusarapu (Ernst & Young LLP) ,

    Sorry for the delayed response.

    If your NuGet packages are already uploaded to the Synapse Primary Gen2 account, you can install them using the notebook.

    Here are the Steps:

    1) upload file to primary gen2 storage

    For this, you can use Azure storage explorer or Azure portal to upload the nuget package

    2) copy your file to the synapse session

    Here is the command

      %%csharp  
      #!pwsh   
      /bin/bash -c " hdfs dfs -get /nuget/nuget.sample.package.1.0.0.18279 /tmp/nuget.sample.package.1.0.0.18279.nupkg"  
    

    Here, I have uploaded the sample NuGet package to the workspace's default account root container named nuget.
    The root container is automatically available to the session runtime.

    With the package file in a usable location, we need to copy it to the session’s local file system. The underlying location path changes every time you create a new session. The /tmp folder is always accessible to the session.

    3) update the package reference location

    %%csharp  
    #i "/Tmp"   
    

    When it runs successfully, you will receive the below message

    Restore sources

    4) install the package

    %%csharp  
     #r "nuget:nuget.sample.package.1.0.0.18279"  
    

    Please let me know if you have any questions here.