I have an Azure Function App ver4 (net6) with HttpTrigger using OpenAPI and it raises exception ‘The host has not yet started’.
Does the following error let me know to remove the character ‘/’ that precedes my Route string value /blog/{blogId}/post/{postId}
:
A host error has occurred during startup operation ‘2397a6d1-fa1c-4895-b062-f7e4faf57970’.
[2022-12-31T08:12:29.716Z] Microsoft.AspNetCore.Routing: An error occurred while creating the route with name ‘GetBlogPost’ and template ‘api//blog/{blogId}/post/{postId}’. Microsoft.AspNetCore.Routing: The route template separator character ‘/’ cannot appear consecutively. It must be separated by either a parameter or a literal value. (Parameter ‘routeTemplate’). Microsoft.AspNetCore.Routing: The route template separator character ‘/’ cannot appear consecutively. It must be separated by either a parameter or a literal value.
Yes / No ?
Thanks!
2
Answers
I resolved this by removing the preceding
/
in the Route parameter value string. Therefore, thischange to
I tried to reproduce this scenario in my environment and was able to resolve the error:-
Yes,
When I tried to remove the appending first “/” in my azure function Open API Http trigger route
My function app ran successfully like below :-
And when I tried to append the “/” before blog in the
route> I was able to get the same error code as yours while running the function app :-
Error :-
Kindly, Remove the appending “/” while routing your api with the function app.
Reference :-
Azure Function app down due to wrong routing template in http
trigger binding of a functions – Stack
Overflow
c# – The route template separator character ‘/’ cannot appear
consecutively – Attribute routing issue – Stack
Overflow