0

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!

Adam Cox
  • 3,341
  • 1
  • 36
  • 46

2 Answers2

1

I tried to reproduce this scenario in my environment and was able to resolve the error:-

The route template separator character ‘/’ cannot appear consecutively. It must be separated by either a parameter or a literal value
Yes / No ?

Yes,
When I tried to remove the appending first “/” in my azure function Open API Http trigger route

public async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "blog/{blogId}/post/{postId}")] HttpRequest req)

 

My function app ran successfully like below :-
enter image description here
enter image description here

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 :-

public async Task<IActionResult> Run(
   [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "/blog/{blogId}/post/{postId}")] HttpRequest req)

 

Error :-
enter image description here

Kindly, Remove the appending “/” while routing your api with the function app.

Reference :-

Sourav
  • 814
  • 1
  • 9
0

I resolved this by removing the preceding / in the Route parameter value string. Therefore, this

/blog/{blogId}/post/{postId}

change to

blog/{blogId}/post/{postId}
Adam Cox
  • 3,341
  • 1
  • 36
  • 46