Can't load metadata ... this time in Azure Functions
See original GitHub issueDescribe the bug I’m opening this because I’m experiencing the same behavior as #127 but this time in an Azure Functions app:
Can't load metadata reference from the entry assembly. Make sure PreserveCompilationContext is set to true in *.csproj file
To Reproduce Try the following Azure Function (using Azure Functions v2):
[FunctionName("Function1")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
var engine = new RazorLightEngineBuilder()
.UseMemoryCachingProvider()
.Build();
var template = "Hello, @Model.Name";
var model = new ViewModel { Name = "Adrian" };
var result = await engine.CompileRenderAsync("templateKey", template, model);
return new OkObjectResult(result);
}
Information (please complete the following information):
- OS: Windows 10
- Platform .Net Core 2.1
- RazorLight version 2.0-beta1
Additional context I have PreserveCompilationContext true in the functions csproj file … but I suspect that this is probably not what’s meant by the entry assembly. It looks as if there a number of infrastructure assemblies involved before my function ever gets called.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:5
Top Results From Across the Web
Triggering Durable Function throws Null Reference exception
Azure.WebJobs.Script.WebHost: Unable to load metadata for function 'OrchestrateTest'. Function 'OrchestrateTest (Orchestrator)' was aborted.
Read more >Unable to generate Azure Functions extensions metadata file
Unable to generate Azure Functions extensions metadata file. 2> at ExtensionsMetadataGenerator.ExtensionsMetadataGenerator.Generate(String ...
Read more >Troubleshoot Python errors in Azure Functions
In your text editor, open the METADATA file and check the Classifiers: section. If the section doesn't contain Python :: 3 , Python...
Read more >Azure function fails but the reason is not defined in the log
Hello, I have a couple of issues with azure function (Python) My function extracts data from SQL DB and put it to the...
Read more >Azure functions intermittent function loading issue
Hi, we have an Azure function app running two functions in python on a shared Linux app service plan. Both functions run based...
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
I don’t believe this bug should be closed as it currently stands. The above issue as detailed still exists with
SetOperatingAssembly(Assembly.GetExecutingAssembly())
. Can we please get the fix which exists on the Unofficial packaged moved up to the Official package?Same Problem: .NET Standard 2.0, Azure Function 2.0 Since the entry assembly is coming from the Azure Functions runtime, I cannot control this setting there, so I need a workaround…
UPDATE: I made it work with the following workaround:
I used .SetOperatingAssembly(currentAssembly) to use my own assembly (with PreserveCompilationContext = true) as a starting point. By setting the assembly here it does not use the entry assembly (which is part of Microsoft Azure).
I had to switch from Beta1 to the “unofficial” beta1.3 because otherwise I got a NullPointerException.
Maybe that could be added to the documentation.