skip to Main Content

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


  1. Chosen as BEST ANSWER

    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}
    

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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search