Krishh
Krishh

Reputation: 4231

Error in Azure Functions when running locally which has nuget package reference

I tried the approach that was discussed over here to run Azure Functions on local machine. I was able to compile and run locally fine with the samples. But when I tried referencing nuget package by adding a project.json file and adding the namespace in my function it started throwing compilation error. On the portal it works fine. Am I missing any step?

project.json

{
  "frameworks": {
    ".NETFramework,Version=v4.6": {
      "dependencies": {
        "Microsoft.Azure.DocumentDB": "1.6.3"
      }
    }
  }
}

run.csx

using System;
using System.Diagnostics;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.Documents;

public static void Run(TimerInfo input, TraceWriter log)
{
    log.Verbose("C# Timer trigger function executed.");
}

Thanks!

Upvotes: 2

Views: 873

Answers (1)

Fabio Cavalcante
Fabio Cavalcante

Reputation: 12538

Krishh,

This should definitely work locally. You may need to check the following:

  • Due to the way NuGet references are currently processed, please make sure you "touch" that file while the host is running. The host watches for file modifications and initiates a restore when it detects changes
  • NuGet.exe (3.3.0 recommended) must either be in your path or you must have an environment variable named AzureWebJobs_NuGetPath set, with the path to nuget.exe

Hope this helps!

Upvotes: 2

Related Questions