Azure / Azure/azure-functions-host

"function runtime is unable to start" when trying to add Mvc Core

Open
#5,205 5 comments 0 reactions 0 assignees View on GitHub
docs
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

Hi,
I am trying to use Razor Engine as a templating engine in a V2 function. I have it running locally, but not when deployed as a function. When selecting the function name from the portal, it gives "The function runtime is unable to start."

I've managed to strip everything down to a sample function with bare code and tried a lot of combinations with the basic initialization code, but not resolved.

#### Investigative information

Please provide the following:

- Timestamp: 2019-11-05T11:10:59.502Z
- Function App version (1.0 or 2.0): V2
- Session ID: 3735937f63d6477e826a152120f99a3e
- Region: West Europe
No invocation id, the runtime does not start.

#### Repro steps

I've built a sample HttpTrigger function from VS2019 template, and just added this:

```csharp
[assembly: FunctionsStartup(typeof(TestFunction.Startup))]
namespace TestFunction
{
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
ConfigureServices(builder.Services);
}

private void ConfigureServices(IServiceCollection services)
{
// This line causes error in runtime
services.AddMvcCore();
}
}
}
```

I also tried with a more complex startup adding logging etc. but it gives the same error on the "AddMvcCore" line. If I comment that line, it works.

#### Actual behavior

Function does not run. Runtime does not start.
Navigating to the function name tab in the portal shows a "function runtime is unable to start" error.

#### Related information

Provide any related information

* Programming language used: C#
* Links to source: Can provide them if required.
* Bindings used: HttpTrigger, not relevant. Same problem with QueueTrigger

Contributor guide

Open the contributing guide

Research direction

Start with the V2 HttpTrigger sample and the FunctionsStartup.ConfigureServices method shown in the report, focusing on the services.AddMvcCore() call that prevents the deployed runtime from starting. Reproduce it locally and when deployed, then confirm that the function runtime starts with AddMvcCore enabled and that the portal no longer reports a startup failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.