data-api-builder icon indicating copy to clipboard operation
data-api-builder copied to clipboard

Config property: Customize hosting port(s) beyond 5000/5001

Open sajeetharan opened this issue 2 years ago • 4 comments

What happened?

We need to provide CLI or config file option for choosing ports other than 5000 or 5001 for http and https.

For example : While developing locally or host two APIs simultaneously on distinct ports.

Version

0.6.14

What database are you using?

CosmosDB NoSQL

What hosting model are you using?

Local (including CLI)

Which API approach are you accessing DAB through?

GraphQL

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

sajeetharan avatar May 07 '23 18:05 sajeetharan

Maybe just use the appsettings file and override the Kestrel or IIS endpoint(s) there? Dab uses aspnet, so if not hardcoded, you can use its config to change ports. Lots of options in the docs: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/endpoints?view=aspnetcore-6.0

Bysza avatar Oct 03 '23 12:10 Bysza

This needs more discussion to accommodate or exclude swa and hot reload. Kestrel config occurs before any config read/parsing mechanism takes place.

seantleonard avatar Feb 08 '24 19:02 seantleonard

Some other option to use it, is to run DAB by Docker Container with custom port config.

docker run -it --rm -v "%cd%\swa-db-connections:/App/swa-db-connections" -p 5033:5000 --env DATABASE_CONNECTION_STRING="%DATABASE_CONNECTION_STRING%" mcr.microsoft.com/azure-databases/data-api-builder:0.10.21 --ConfigFileName ./swa-db-connections/staticwebapp.database.config.json

Would be nice to have port configuration in CLI.

wrutkowski-xebia avatar Mar 21 '24 13:03 wrutkowski-xebia

Maybe just use the appsettings file and override the Kestrel or IIS endpoint(s) there? Dab uses aspnet, so if not hardcoded, you can use its config to change ports. Lots of options in the docs: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/endpoints?view=aspnetcore-6.0

Hi @wrutkowski-xebia Until DAB cli offers the ability to update port, please consider using @Bysza's suggestion. The port settings are picked up from appsettings.json

seantleonard avatar Mar 26 '24 16:03 seantleonard