@Abhay Vijay Pai I have tested your code and changed the host.json Microsoft.Azure.Functions.ExtensionBundle version to [1.*, 4.0.0) and defaultExecutablePath to php. For your reference sharing the same
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 4.0.0)"
},
"customHandler": {
"description": {
"defaultExecutablePath": "php",
"arguments": [
"-S",
"0.0.0.0:%FUNCTIONS_CUSTOMHANDLER_PORT%",
"worker.php"
]
},
"enableForwardingHttpRequest": false
},
"logging": {
"logLevel": {
"Function.HttpTrigger.User": "Information",
"default": "Warning"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true
}
}
}
}
In your index.php file I have changed the below to make it simple and I have tested the same after modifying the above and below changes.
<?php
function run(FunctionContext $context) {
$req = $context->inputs['req'];
//$context->log->information(json_encode($req));
$context->log->information('Http trigger invoked');
$query = 'This is test response';
return [
'body' => $query,
'headers' => [
'Content-type' => 'text/plain'
]
];
}
?>
Note: Your most of the error will be solved if you update the host.json with the right value and make sure to run your visual studio code in administrative mode. You also need to make sure that you have PHP installed and the environment path is correctly reflected to your path where your php folder exists and php folder\ext