Skip to content

"Failed to fetch http://localhost:57773/api/swagger.json" when running from Azure Functions with Aspire #692

@schuettecarsten

Description

@schuettecarsten

Description

I've created a new Azure Functions project with new Aspire in Visual Studio 2022 using net9.0. Then, I've added NuGet depencency Microsoft.Azure.Functions.Worker.Extensions.OpenApi in version 1.5.1. When starting this, the default Function1 and Swagger UI is listed in console output of the App as expected:

Functions:
 
	Function1: [GET,POST] http://localhost:7227/api/Function1
 
	RenderOAuth2Redirect: [GET] http://localhost:7227/api/oauth2-redirect.html
 
	RenderOpenApiDocument: [GET] http://localhost:7227/api/openapi/{version}.{extension}
 
	RenderSwaggerDocument: [GET] http://localhost:7227/api/swagger.{extension}
 
	RenderSwaggerUI: [GET] http://localhost:7227/api/swagger/ui

When I now open http://localhost:7227/api/swagger/ui, I get an error Failed to load API definition. and Fetch error, Failed to fetch http://localhost:57773/api/swagger.json. It looks like the Aspire port 7227 is not picked up by Swagger UI so it tries to load definitions from a wrong address.

Image

Steps to reproduce

See description.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions