This is a sample function just for testing. PHP is a language that is in experimental mode for now. There is not support for this right now.
You can use this repository to deploy to an Azure Function.
You need to create the Azure Function first in portal.
This demo is designed for hosting a function inside App Service Plan because the host.json file has not limit for timeout. For Consumption Plan you will have 5 mins by default, you can increase it from 1 second to 10 minutes. You need to add this value in host.json file.
{
"functionTimeout" : "00:10:00"
}
For printing variables in console, some examples:
echo "Printing in console with echo \r\n";
fwrite function
fwrite(STDOUT, "Printing in console with fwrite \r\n");
using print_r
print_r("Printing in console with print_r \r\n");
For Azure Functions you can get environment the data using these variables:
- REQ_ORIGINAL_URL
- REQ_METHOD
- REQ_QUERY
- REQ_QUERY_
- REQ_HEADERS_
- REQ_PARAMS_
$req_original_url = getenv('REQ_ORIGINAL_URL');
$id = getenv('REQ_PARAMS_id');
I have added a route inside function.json
"route": "users/{id:int?}",
This demo is just for GET method, so I can request my function like this: [https://{azurefunctionname}.azurewebsites.net/api/users/{id}?code=/{somerandomcode}¶m1=value¶m2=value]
- Http Functions - Azure Function Http Functions
- Types of Functions - Azure Functions scale and hosting
- Samples and content - Wiki
- Azure Function On Linux - Using a Custom image (Preview)