DEV Community

Guido Zambarda
Guido Zambarda

Posted on • Originally published at iamguidozam.blog on

Change or remove the base /api path in Azure Functions

Cit: “Everything works and I like it, but I don’t want the /api in the URL, can you remove it?”.

That was the incipit to this post.

Before that I never wondered if there is a configuration or something to change or remove the /api base URL in Azure Functions.

After searching for a bit I found an answer and that was: yes, you can.

However the answer might change based on the host.json schema version.

For host.json file with version older than 2.0

In the host.json file there’s a property http where you can specify the base route prefix:

{ "http": { "routePrefix": "" }}
Enter fullscreen mode Exit fullscreen mode

For version 2.0 of the host.json file

In the version 2.0 of the host.json file the schema has changed and now to achieve the same result you have to incapsulate the http property inside the extensions property:

{ "version": "2.0", "extensions": { "http": { "routePrefix": "" } }}
Enter fullscreen mode Exit fullscreen mode

Hint

If you want to maintain a base URL but don’t want to keep the /api default you can change it specifying the new route prefix, for example:

{ "version": "2.0", "extensions": { "http": { "routePrefix": "ask" } }}
Enter fullscreen mode Exit fullscreen mode

In this way instead of having the /api we will have /ask.

If you want to check a sample you can view it here.

Hope that helps!

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more