0

Is it possible to add the reference for ExcelDataReader and ExcelDataset in Azure functions? I uploaded dll file of NuGet packages (exceldatareader.3.4.0.nupkg) to the program. But I'm not sure how actually it has to be used. Can anyone help me to achieve this.

#r "Microsoft.WindowsAzure.Storage"
#r "System.IO"
#r "System.Data"
#r "exceldatareader" //*I'm not able to add this reference|*
using System;
using System.IO;
using System.Net;
using System.Runtime.Serialization.Formatters.Binary;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.Auth;
using ExcelDataReader;
using System.Data;

Thank you.

5
  • what the error or difficulty you faced, what are you tried Commented Aug 1, 2018 at 12:36
  • please see the whole process - dotnetfunda.com/articles/show/3489/… Commented Aug 1, 2018 at 12:51
  • I have added the reference I tried to add in the question above Commented Aug 1, 2018 at 12:56
  • check this - stackoverflow.com/questions/27634477/… Commented Aug 1, 2018 at 13:00
  • @ajay2707 That article is regarding console application right. I'm able to complete my task in the console application. I want to implement the same using the Azure functions. using ExcelDataReader; throws error saying, 'reference is missing'. Commented Aug 1, 2018 at 13:04

1 Answer 1

1

To install packages for Azure functions on portal, we need to create dependencies file under function folder. Click View files on the right of function panel, Add file according to runtime.

If your function runtime is ~1, create project.json with following content.

{
  "frameworks": {
    "net46":{
      "dependencies": {
        "ExcelDataReader.DataSet": "3.4.0"
      }
    }
   }
} 

If your function runtime is ~2, create function.proj as below.

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="ExcelDataReader.DataSet" Version="3.4.0"/>
    </ItemGroup>
</Project>

After file created, assemblies will be added to function host environment. Also need to remove unnecessary #r "exceldatareader" or you will got error.

Sign up to request clarification or add additional context in comments.

1 Comment

I have already found the solution. Thank you for your time and help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.