I'm struggling a bit with setting up a function app with a static web app on Azure.
I'm making an PWA for field technicians on Static Web Apps that is backed by a Function App. I had to make a separate Function app since I needed to run it in a Premium Plan so I can get a public IP for some external services.
I want technicians and office personel to use the app via the web, but I also need to integrate a lot of the functions into other workflows and to be able to start functions both from the app and automatically from other systems on certain events.
But I can't seem to get a good setup for both authenticating users and systems/scripts.
I see the following setups:
Linking the SWA with the function app and setting functions authLevel to anonymous. Now it works perfectly for users of the app. But I can't use the functions from outside of the SWA. I can add an identity provider for the function app and login using the browser but that is not a smooth way to integrate other systems.
I can link the SWA and the function app and set the functions authLevel to function. Now I can use API-keys for the functions which will make it easy for other systems to use the functions. But I also need to add a function key in every api call from the SWA. Which will expose the API key in the browser and make it possible to use it to call the functions without going through the app.
I could set up the Function App separately and not link it to the SWA. Then using function api key I could set up managed functions in SWA that mirrors the functions I need to call. This would make it easy to integrate the functions to other systems via API-keys and the API key would not be exposed in the browsers since the managed function does not need it. But now I have double the amount of functions that I need to keep in sync.
So am I missing something? Option 3 seems like the most versatile approach but also annoying.
I would like option 1 but I don't know how I would authenticate webhooks, scripts, and other applications against the AD identity provider.