Open vabed opened 6 years ago
Your title mentions Azure Functions, does that mean that you don't have any problem when running your program on a local machine?
"Application break down" sounds like an unhandled expcetion, that causes the program to terminate.
If that is the case, try wrapping the code in side a Try/Catch
to see which type of exception is thrown and what the exception message is.
What version of GribApi do you use?
Have you had a look at #52 ? It also described a problem when running in Azure Functions.
When I use it in Console project everything works. I surround this code with Try/Catch but it doesn't throw any exceptions and application just break down (maybe exception throws on lower levels). I use version 0.7.1 and I also looked at #52 but there used version 1.0.0
Please try upgrading to newest beta to see if that solves your problem. There once was a problem with uncatchable exceptions being thrown, but that should have been solved.
I have updated the package to beta version, after it I can run functions on my local PC but when I publishing on Azure and call the function the exception about Environment shows
GribEnvironment::DefinitionsPath must be a valid path. Please see GribApi.NET's documentation for help. Path:
What is the value of GribEnvironment.DefinitionsPath
?
Is the folder Grib.Api
correctly copied from the nuget package to the code you deploy?
The message you see indicates that GribApi.NET could not locate the definitions
folder.
The value for GribEnvironment.DefinitionsPath looks like string.Empty from the exception message. Yes I copy Grib.Api folder to the wwwroot folder on Azure Functions and Grib.Api folder contains definitions folder, but it all doesn't help, I still get the same mistake
Have you to explictly set GribEnvironment.DefinitionsPath
to the absolute path pointing to Grib.Api/definitions
?
GribApi.NET has some heuristics to search for the definitions folder, but it won't do an exhaustive search for it.
Yes, it helps. But now I face the same problem as here #52. As I understand the solution is to manually copy Grib.Api.Native.dll to bin folder?
Glad it helped.
To my knowledge there is no "official" way to make it work.
If it was me, I would add a link in the csproj file to the right Grib.Api.Native.dll
to force it being copied to the root of the bin
folder.
I hurried up with results(
GribEnvironment.DefinitionsPath = @"D:\somepath\wwwroot\Grib.Api\definitions"; log.Info("defPath: " + GribEnvironment.DefinitionsPath);
when I run this code on AzureFunctions logs show me
2018-05-13T14:45:31.214 [Info] defPath:
and then I still get an exception about GribEnvironment::DefinitionsPath must be a valid path
.
It looks like setter for GribEnvironment.DefinitionsPath doesn't work correctly.
UPD: the same behavior is on my local PC also
UPD: I achive running beta-4 on Azure Functions, but setter for DefinitionsPath is still doesn't work.
Could you put a few words on how you got it working? It will help others with similar problems.
OK, maybe not all of this steps are obligatory but it helps me
private static void SetGribEnvironment(TraceWriter log) { Random rand = new Random(); try { GribEnvironment.Init(); } catch (Exception e) { log.Error(e.Message); Thread.Sleep(4000 + rand.Next(2000)); SetGribEnvironment(log); } }
When I call GribFile constructor at first time everything goes fine, but when I try iterate throught it application breaks down and exit.
using (GribFile file = new GribFile(@"file_name.grib2")) { var msg = file.First(); }
It all looks similar to issue #22