Azure Function App : Dependency not found
See original GitHub issueHi,
I had a little Azure Function App, using blob trigger scenario in c#. This app has a simple job : json validation using newtonsoft. I validate json with schema generated by model annotations.
Here is my validation code:
#r "System.Linq"
#r "Newtonsoft.Json"
#r "Newtonsoft.Json.Schema"
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Schema.Generation;
public static class Json
{
public static T Deserialize<T>(string content, bool validate = true)
where T : class, new()
{
if (validate)
{
var errors = Validate<T>(content);
if (errors.Any())
{
//log.Error(string.Join("\n", errors));
return null;
}
}
var serializerSettings = new JsonSerializerSettings
{
Error = (sender, e) =>
{
//log.Error(e.ErrorContext.Error.Message);
e.ErrorContext.Handled = true;
}
};
return JsonConvert.DeserializeObject<T>(content, serializerSettings);
}
private static IList<string> Validate<T>(string content)
{
// Generates schema
var generator = new JSchemaGenerator();
var schema = generator.Generate(typeof(T));
var data = JObject.Parse(content);
IList<string> messages;
// Validates
data.IsValid(schema, out messages);
if (messages.Any())
{
//log.Error($"\n// Generated schema for '{typeof(T).Name}' class:\n" + schema);
}
return messages;
}
}
This code does not compile and I have these logs :
json.csx(5,1): error CS0006: Metadata file 'Newtonsoft.Json.Schema' could not be found
json.csx(12,30): error CS0234: The type or namespace name 'Generation' does not exist in the namespace 'Newtonsoft.Json.Schema' (are you missing an assembly reference?)
json.csx(44,29): error CS0246: The type or namespace name 'JSchemaGenerator' could not be found (are you missing a using directive or an assembly reference?)
Compilation failed.
My function.json
file seems to be good:
"frameworks": {
"net46": {
"dependencies": {
"Newtonsoft.Json": "10.0.2",
"Newtonsoft.Json.Schema": "2.0.10"
}
}
I run the same code locally in a console app without troubles.
If it can help, the package Newtonsoft.Json.Schema
adds extension methods to Newtonsoft.Json
package classes and extends Newtonsoft.Json.Schema
namespace.
I triple check every setup … help 😃
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Azure Functions for Python - Dependencies cannot be found
I've already tried my code in diffrent environments (also Ubuntu, which should be the same image Azure functions is using) and always used...
Read more >Troubleshoot Python errors in Azure Functions
Go to your local function project folder, and use func azure functionapp publish <app-name> --build-native-deps for deployment.
Read more >Azure Functions Not Loading My Dependencies, What Have I ...
I was setting up a new Azure Function application to show off some further configuration settings usage but it wasn't working.
Read more >Azure function app: Dependencies installed but some are not ...
Coding example for the question Azure function app: Dependencies installed but some are not found.
Read more >Netwontsoft.Json dependency conflicts with Azure Functions ...
Our application will be running with the expected version of Newtonsoft.Json v12.0.1, but the Azure Functions Runtime on the server may not ( ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello everyone, I am having a situation trying to setup my Power BI Embed function to generate my code.
project.json
{ "frameworks": { "net46":{ "dependencies": { "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.19.4", "Microsoft.PowerBI.Api": "2.0.12" } } } }
run.csx
`#r “System.Web.Extensions” using System.Configuration; using System.Net; using System.Text; using System.Web.Script.Serialization; using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.PowerBI.Api.V2; using Microsoft.PowerBI.Api.V2.Models; using Microsoft.Rest;
// Static Values static string authorityUrl = “https://login.windows.net/common/oauth2/authorize/”; static string resourceUrl = “https://analysis.windows.net/powerbi/api”; static string apiUrl = “https://api.powerbi.com/”; static string clientId = ConfigurationManager.AppSettings[“PBIE_CLIENT_ID”]; static string username = ConfigurationManager.AppSettings[“PBIE_USERNAME”]; static string password = ConfigurationManager.AppSettings[“PBIE_PASSWORD”]; static string groupId = ConfigurationManager.AppSettings[“PBIE_GROUP_ID”]; static string reportId = ConfigurationManager.AppSettings[“PBIE_REPORT_ID”];
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) {
}
public class EmbedContent { public string EmbedToken { get; set; } public string EmbedUrl { get; set; } public string ReportId { get; set; } } `
I am new to .NET. I just need to get my Power BI Embed functionality working. Is there a better way to have written this function.
I get the error as follows:
2018-11-16T19:33:30.532 [Error] run.csx(1,1): error CS0006: Metadata file ‘System.Web.Extensions’ could not be found 2018-11-16T19:33:30.624 [Error] run.csx(5,18): error CS0234: The type or namespace name ‘Script’ does not exist in the namespace ‘System.Web’ (are you missing an assembly reference?) 2018-11-16T19:33:30.833 [Error] Executed ‘Functions.HttpTrigger1’ (Failed, Id=fdb35668-e024-4ba7-9dc9-ab1bf3e84c2a)
I would appreciate any help I can get at this point. Thanks guys.
Hi Oluwaseun, Try having a look at this article. https://blogs.msdn.microsoft.com/cjaliaga/2018/01/21/installing-nuget-packages-in-azure-functions-2-x-runtime-preview/
Best Regards, Peter Selch Dahl Azure MVP