question

MitchelSarauer-4005 avatar image
0 Votes"
MitchelSarauer-4005 asked sadomovalex answered

My Azure functions are working locally, but not when deployed

I have a Static Web App, with Azure functions for a backend. Using local development, I can get the functions to work, but when deployed they return 500 or 404. The functions work locally when I use fetch with localhost:7071 i.e. fetch('https://localhost:7071/api/getName?game=slug') but not with fetch('/api/getName?game=slug').

I'm using a SvelteKit front-end, with the svelte-adapter-azure-swa. I'm really confused because I've gotten other similar applications to work (with React front end).





azure-functionsazure-static-web-apps
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

What do the function logs say?

0 Votes 0 ·

@MitchelSarauer-4005 ,

What happens when you launch the Function url directly in the browser instead of the static web app? Please let me know the outcome of this approach. Also have you enabled any authentication at the function app ?

0 Votes 0 ·
MughundhanRaveendran-MSFT avatar image MughundhanRaveendran-MSFT MughundhanRaveendran-MSFT ·

@MitchelSarauer-4005 , Could you please provide your inputs for the queries asked in the above comment? Thanks

0 Votes 0 ·

1 Answer

sadomovalex avatar image
0 Votes"
sadomovalex answered

what is the full (absolute) url when the following method is called:

 fetch('/api/getName?game=slug')

Does it really point to function app url? Also did you try to trigger it from Azure portal (Function app > Functions > {functionName} > Code + Test > Test/Run)?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.