I have an azure functions app (.NET 5 isolated) that has swagger enabled. Everything works fine locally in both release and debug builds. Once deployed to azure, the actual functions themselves works fine (they're all HTTP triggers). However, none of the swagger endpoints work. They all return a status code of 500 with the error message
Object reference not set to an instance of an object
I've scoured the interwebs and have come up completely empty. App Insights doesn't tell me anything. Anyone ever run into this? Thanks in advance.
CodePudding user response:
the file requirements.txt have to be manually amended with the libraries , if that didn't work please head to appinsight => live metrics
CodePudding user response:
I've been able to figure this out. The trick was understanding that it works fine locally but fails when deployed in Azure. The question I raised to myself "what's different in Azure than when running locally?" It turns out the HTTP trigger authorization level. By switching all HTTP trigger authorization levels to Anonymous the OpenAPI UI endpoint actually works. Without looking into the Open API package code, I'm assuming that somehow Anonymous authorization needs to exist for the reflection code to successfully execute.
So, this means that if you want Open API to work for your function app when deployed you need to do something else to secure the API surface other than simply relying on the function key. Arguably, you should do that anyway.