'How do I get my Azure C# function app to return json?

I have a function app which I run locally to test and all is fine

http://localhost:9999/api/DataFunction

This returns a json string no problem.

However when I publish and connect to the url from Azure I just get the "Your Functions 4.0 app is up and running" page.

https://datafunctionxxxxxxxxxxxxx.azurewebsites.net/

The app has hard coded data as I am new to Function Apps and this was a test.

What have I missed, do I need to do something else? I published from VS2022 to Azure with all the default settings.



Solution 1:[1]

Have you tried appending api/DataFunction on to the end of your URI:

https://datafunctionxxxxxxxxxxxxx.azurewebsites.net/api/Datafunction

If you are using function level authentication then you will also have an authentication key as a query string.

https://datafunctionxxxxxxxxxxxxx.azurewebsites.net/api/Datafunction&code=<keyhere>

You can obtain this from the Azure Portal

Get function URL

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1