Azure / azure-functions-openapi-extension

This extension provides an Azure Functions app with Open API capability for better discoverability to consuming parties

Home Page:https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.OpenApi/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.NET framework Isolated - The system cannot find the file specified.

mathiasbl opened this issue · comments

Describe the issue
The swagger endpoints do not work for projects that target .net framework isolated.

To Reproduce
Steps to reproduce the behavior:

  1. Create new Azure Function project that targets .NET framework Isolated v4 with a HttpTrigger function.
  2. Add Microsoft.Azure.Functions.Worker.Extensions.OpenApi package
  3. Modify program.cs according to the docs
var host = new HostBuilder()
     .ConfigureFunctionsWorkerDefaults(worker => worker.UseNewtonsoftJson())
  1. Add decorator the function app (Taken from the docs)
[OpenApiOperation(operationId: "greeting", tags: new[] { "greeting" }, Summary = "Greetings", Description = "This shows a welcome message.", Visibility = OpenApiVisibilityType.Important)]
     [OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
     [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "text/plain", bodyType: typeof(string), Summary = "The response", Description = "This returns the response")]
  1. Start project
  2. Navigate to http://localhost:xxx/api/swagger/ui
  3. See error: The system cannot find the file specified.

Screenshots

image

Environment (please complete the following information, if applicable):

  • OS: Windows
  • Core Tools Version: 4.0.5455 Commit hash: N/A (64-bit)
  • Function Runtime Version: 4.27.5.21554
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net48</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <OutputType>Exe</OutputType>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.OpenApi" Version="1.5.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.4" />
    <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.1.0" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Properties\" />
  </ItemGroup>
</Project>