Hi,
I have an Azure function (V3) and, for DI, I would like to use the FunctionsStartup rather than implementing IWebJobsStartup. When I implement IWebJobsStartup this works but not when I inherit from FunctionsStartup. I am pretty sure that, I am doing something fundamentally wrong here, but almost all of the search results lead to a solution which implements IWebJobsStartup directly.
Below is the error which I get. Any help is highly appreciated!
Microsoft.Azure.WebJobs.Host: Error indexing method 'Swagger'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'swashBuckleClient' to type ISwashBuckleClient. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), build
er.AddTimers(), etc.).
My startup class is as below,
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
var services = builder.Services;
RegisterSwaggerDocumentation(services);
}
private void RegisterSwaggerDocumentation(IServiceCollection services)
{
if (services == null)
{
return;
}
services.AddSwaggerGen();
//services.AddSwaggerGen(options =>
//{
// options.SwaggerGeneratorOptions = new SwaggerGeneratorOptions
// {
// DescribeAllParametersInCamelCase = true
// };
//});
}
}
The function I am testing is this,
public class GetTodoFunction
{
private readonly ILogger<GetTodoFunction> _logger;
public GetTodoFunction(ILogger<GetTodoFunction> logger)
{
_logger = logger;
}
[FunctionName(nameof(GetTodoFunction))]
public async Task<IActionResult> GetTodoAsync([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "todos/{id}")]
HttpRequest request, string id)
{
_logger.LogInformation($"{nameof(GetTodoFunction)} started.");
await Task.Delay(TimeSpan.FromSeconds(1));
return new OkObjectResult($"{id}");
}
}
Hi, I have an Azure function (V3) and, for DI, I would like to use the
FunctionsStartup
rather than implementingIWebJobsStartup
. When I implementIWebJobsStartup
this works but not when I inherit fromFunctionsStartup
. I am pretty sure that, I am doing something fundamentally wrong here, but almost all of the search results lead to a solution which implementsIWebJobsStartup
directly.Below is the error which I get. Any help is highly appreciated!
My startup class is as below,
The function I am testing is this,
The swagger functions are,