Easy Auth enabled on Azure portal for function app not allowed to exposed Swagger endpoints
Describe the issue We are using azure-functions-openapi-extension version 1.5.1 for our existing azure function app built with netcoreapp3.1, its working locally fine but when deployed to azure portal and try to access ttps://[somefunctionapp].azurewebsites.net/api/swagger/ui? returning 401 or "You do not have permission to view this directory or page." However azure function define AllowAnonymous Access in code but using the Latest version of Easy Auth at Azure portal. Please suggest any workaround or fix?
To Reproduce Steps to reproduce the behavior:
- Deploy Azure function to azure portal with Easy Auth enabled
- expose url https://[somefunctionapp].azurewebsites.net/api/swagger/ui
- See error
Expected behavior It should render Swagger UI page as working on locally(localhost)
Environment (please complete the following information, if applicable):
- OS: Windows
- Browser edge, chrome, firefox, safari
Additional context Add any other context about the problem here.
I've got this working by excluding the following paths from EasyAuth:
- /swagger.json
- /openapi/
- /swagger/ui
This can be configured using either Bicep:
resource functionAppService 'Microsoft.Web/sites@2023-12-01' existing = {
name: 'myFunction'
}
resource functionAppConfig 'Microsoft.Web/sites/config@2023-12-01' = {
parent: functionAppService
name: 'authsettingsV2'
properties: {
platform: {
enabled: true
}
globalValidation: {
requireAuthentication: true
unauthenticatedClientAction: 'RedirectToLoginPage'
redirectToProvider: 'azureactivedirectory'
excludedPaths: [
'/swagger.json'
'/openapi/'
'/swagger/ui'
]
}
// omitting the rest for brevity...
or File-based configuration in Azure App Service authentication.