How can I host a Laravel-PHP API and React frontend on Azure, while passing .env data in?

126 Views Asked by At

I'd like to create a Laravel-PHP API service that is hosted on the Azure cloud, and I also need the front end react to be hosted on Azure. Can anyone help?

I tried using the Azure app service, but I'm not sure how to get through.env datas to app service is also receiving a build error indicating that the php version is incompatible. Can someone offer a solution for hosting the php-Laravel framework on the Azure cloud?

1

There are 1 best solutions below

0
Florian Vuillemot On

You can put all your .env values in app settings. If you have secrets, it's best to use an Azure Key Vault and make a reference from your app settings to an Azure KeyVault.

You can get the available PHP versions:

az webapp list-runtimes --os linux | grep PHP
"PHP:8.2",
"PHP:8.1",
"PHP:8.0",

See this documentation for Laravel specifics on Azure App Service.