How can I have multiple endpoints within a single function.json file?

2023-02-28T15:11:33.2766667+00:00

I have an application written in golang, gin and libpq

this app has many endpoints, and i have deployed this app on azure function..

the problem occurs when generating the endpoints in azure, in my golang application the routes are already well defined, but to generate a different endpoint i need to create a folder with the name of the endpoint i need + a function.json file inside this folder , getting very unfeasible because I have several endpoints..

Is there any way I can concentrate all my endpoints in just one function.json file? or some other way for me to work better

my package main:



my package routes:



as you can see, everything is already well defined, just missing the endpoints in azure that is giving me a lot of headache ..

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
2,780 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 52,601 Reputation points
    2023-03-01T08:51:07.0533333+00:00

    @Guilherme Rodrigues Silva de Jesus Thanks for reaching out.

    Unfortunately, it is not possible to concentrate all your endpoints in just one function.json file in Azure Functions. Each endpoint must be defined in its own function.json file.

    However, you can use the Azure Functions Proxies feature to surface your API through a single endpoint. Azure Functions Proxies allows you to forward requests to other resources. You define an HTTP endpoint just like with an HTTP trigger, but instead of writing code to execute when that endpoint is called, you provide a URL to a remote implementation. This allows you to compose multiple API sources into a single API surface, which is easy for clients to consume.

    References:

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-serverless-api

    https://learn.microsoft.com/en-us/azure/azure-functions/legacy-proxies