Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endpoints visible locally but not when deployed on azure #122

Closed
kaluznyt opened this issue May 20, 2021 · 21 comments · Fixed by #217
Closed

Endpoints visible locally but not when deployed on azure #122

kaluznyt opened this issue May 20, 2021 · 21 comments · Fixed by #217
Labels
bug Something isn't working resolved Request has been resolved v0.9.0

Comments

@kaluznyt
Copy link

I have some strange issue, when adding the references, and some basic attributes to the function to see if that will work, everything is OK locally, but when deployed on Azure Function app there are no endpoints:

[FunctionName("InProgress")]
[OpenApiOperation(operationId: "inProgress", tags: new[] { "Events In Progress" }, Summary = "Gets the name", Description = "Get the events that are processing at the moment.", Visibility = OpenApiVisibilityType.Important)]        
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(string), Summary = "The response", Description = "This returns the response")]
public async Task<IActionResult> InProgress([HttpTrigger(AuthorizationLevel.Function, "GET", Route = "monitoring/events/in-progress")] HttpRequest req, CancellationToken cancellationToken)

I tried to comment out the OpenApiSecurity attribute and no success.

Do you have any clue why the difference ? Does it matter that the function is running in ASE ?

This is what I See on Azure:
image

This is what I see locally on the same project:
image

@spboyer
Copy link
Member

spboyer commented May 20, 2021

You want to set the AuthLevel to anonymous AND remove the OpenAPISecurity attribute.

The other option is to pass the authkey in the url for SwaggerUI

@justinyoo
Copy link
Contributor

@kaluznyt Thanks for the issue!

Would you please let us know how to repro the issue so that we can dig in, on our end? Based on the code snippet, I don't see any issue why it's not coming up on Azure when it's deployed.

@kaluznyt
Copy link
Author

Thanks for inputs, I will try to reproduce it from scratch, however it might be specific to that project/function, will try to provide more info.

Also, some months ago I had introduced the OpenAPI e through the AlienCube package, and there everything works fine (different function, but same azure environment).

How are these related ? Is the official Microsoft package using AlienCube underneath or it's non related ? Meaning is it going to be recommended to migrate to the official one ?

@kaluznyt
Copy link
Author

@spboyer I cannot make these functions anonymous (requirements), however, the examples on the github page (https://github.com/Azure/azure-functions-openapi-extension/blob/main/docs/openapi-core.md) are always using AuthLevel of Function. I might try with anonymous just to see if the functions are visible.

@kaluznyt
Copy link
Author

I made the function anonymous and removed the open api security attribute, but it's still the same, will try with AlienCube package

@kaluznyt
Copy link
Author

I migrated to AlienCube - and everything seems ok even with the AuthLevel = Function both locally and in Azure
image

@kaluznyt
Copy link
Author

Not sure if I can help with debugging on what went wrong with the azure.openapi extension since I can see no logs indicating that something went wrong

@justinyoo
Copy link
Contributor

It's interesting.

I just created a new Azure Functions project with Visual Studio 2019 16.10 preview 4 and deploy the function app to Azure and it works as expected. I had no changes made at all.

Could you please deploy the basic (or default) Azure Functions app to Azure, with this extension and have a look?

@justinyoo
Copy link
Contributor

Also, some months ago I had introduced the OpenAPI e through the AlienCube package, and there everything works fine (different function, but same azure environment).

How are these related ? Is the official Microsoft package using AlienCube underneath or it's non related ? Meaning is it going to be recommended to migrate to the official one ?

This is a successor of the Aliencube package, which will be archived soon.

@brandonjpetersen
Copy link

I'm having the same issue as well, locally it works perfect with all endpoints appearing. Deploying to Azure, I see the 'No operations defined in spec!' message.

I'm noticing that the 'paths' node of swagger.json is empty on Azure, but has full details on my local machine.

@justinyoo
Copy link
Contributor

@brandonjpetersen Make sure that all four endpoints starting with Render- are only shown in your local machine, not on Azure because they are encapsulated.

Unfortunately, I can't reproduce this issue. Have you tried the sample app in this repo and seen the same symptom?

@brandonjpetersen
Copy link

brandonjpetersen commented May 27, 2021

To troubleshoot:

Started a new project in Visual Studio Version 16.9.4.

  • From the VS Project template chose the 'Azure Functions' template
  • Selected 'Azure Functions v3 (.Net Core)' and then chose 'Http trigger with OpenAPI'
  • Set the Authorization Level to 'Anonymous'

With the initial template code, deployed through Azure Dev Ops to a Azure Function App. Everything worked perfectly, the Swagger Doc generated correctly for the basic 'Function1' HTTP Trigger.

Then I made the adjustment to add 'Dependency Injection' and 'Entity Framework Core' to the solution. I added a Startup.cs file and the following Nuget packages:

  • Microsoft.Azure.Functions.Extensions (1.1.0)
  • Microsoft.EntityFrameworkCore (3.1.15)
  • Microsoft.EntityFrameworkCore.Design (3.1.15)
  • Microsoft.EntityFrameworkCore.SqlServer (3.1.15)

The Azure Dev Ops deployment executed without any errors, but the Swagger Docs no longer generated. I'm now testing to see which part caused the issue.

@brandonjpetersen
Copy link

brandonjpetersen commented May 27, 2021

Test 1: Adding only the Nuget package (Microsoft.Azure.Functions.Extensions (1.1.0)) - Working
Test 2: Adding the Startup.cs file - Working
Test 3: Adding EF Core Nuget packages back - Stopped Working

Note: Each of the above works locally, but Test 3 doesn't work on Azure

@spboyer
Copy link
Member

spboyer commented May 27, 2021

@brandonjpetersen - be sure to use Visual Studio 16.10 now available.

@brandonjpetersen
Copy link

Thanks everything is working now after recreating it with VS 16.10. I also had to downgrade EF Core to 3.1.13.

@rockgecko-development
Copy link

I have the same issue, using Azure Functions core 3.1 project, with references to EF Core 3.1.14. Works fine locally, but empty when deployed to Azure.
Previously I was using v 0.5.1-preview of this package which worked, I'll downgrade to that for now.

@Mastercut0r
Copy link

I can confirm this issue with no endpoints (Message: No operations defined in spec!) if deployed to azure but working fine locally.
Package version 0.7.2-preview.
Now i followed the advice of rockgecko-development to downgrade the package to 0.5.1 and it worked like a charm not only locall but after deployment to azure as well.

@davidfallan
Copy link

Only seems to be an issue deploying to azure via a pipeline. Manually publishing direct to azure seems to work fine. Changing to 0.5.1. resolved the pipelines problem for me.

@runceel
Copy link

runceel commented Aug 13, 2021

I'm facing this issue on 0.8.1-preview.

@dominicusmento
Copy link

I face the problem locally too when running via powershell by 'func host start'.. When running f5 from visual studio, swagger is populated correctly which means that it is somehow VS dependent which is definitely wrong.. This needs to be solved..

@justinyoo justinyoo added bug Something isn't working v0.9.0 resolved Request has been resolved and removed triage labels Aug 31, 2021
@justinyoo
Copy link
Contributor

It's resolved, and @vincentbitter 's contribution has been merged to the main repo (not yet published).

Would you please try the new change on your end and let us know?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved Request has been resolved v0.9.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants