question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Precompiled Azure Functions with Dependency Error

See original GitHub issue

Hi, Team.

I know how to use precompiled Azure Functions by following the official document. It just works fine.

However, when I put the TraceWriter instance like:

using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;

using Microsoft.Azure.WebJobs.Host;

namespace PrecompiledLibraries
{
    public class MyHttpTrigger
    {
        public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
        {
            log.Info($"C# HTTP trigger function processed a request. RequestUri={req.RequestUri}");

            // parse query parameter
            string name = req.GetQueryNameValuePairs()
                .FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0)
                .Value;

            // Get request body
            dynamic data = await req.Content.ReadAsAsync<object>();

            // Set name to query string or body data
            name = name ?? data?.name;

            return name == null
                ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body")
                : req.CreateResponse(HttpStatusCode.OK, "Hello " + name);
        }
    }
}

It throws an error like below:

The following 1 functions are in error:

HttpTriggerCSharp: Could not load file or assembly ‘Microsoft.Azure.WebJobs.Host, Version=1.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.

That library actually a dependency of Azure Functions and there’s no need to load.

Not sure this is a bug of either:

  • Azure Functions itself,
  • Azure Functions CLI,
  • Visual Studio Tooling, or
  • something else

Could you have a look into this, please?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fabiocavcommented, Jan 19, 2017

We have a couple of ideas to make that better than just relying on docs. One of them being a meta-package you can reference that would ensure you have the right dependencies.

0reactions
christopherandersoncommented, Jan 20, 2017

Resolved

Read more comments on GitHub >

github_iconTop Results From Across the Web

Precompiled Azure Function Dependency Error
This now works fine in Azure Functions. In short, look at the dependencies, isolate them in an assembly then include that in your...
Read more >
Azure Functions v3 dependency injection issue
Hello, When trying to use DI with [FromServices], it fails with the following build error: Error Mono.Cecil.
Read more >
Precompiled Azure Function Dependency Error
I fixed my problem by placing the code using the resource manager API into one assembly and just used that. This now works...
Read more >
Azure function precompiled timerTrigger error
I have a timer trigger working on a precompiled function using a slightly different definition of the Run function. using System; using System.Collections....
Read more >
Netwontsoft.Json dependency conflicts with Azure Functions ...
If you're encountering an error with Newtonsoft.Json dependency conflicts in Azure Functions (both .net Framework V1 or .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found