There is no need to specify the script file.
Below works both on local and azure:
**`index.js`**
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
var message = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
context.log(message);
context.bindings.firstStep = message;
context.res = {
// status: 200, /* Defaults to 200 */
body: "test"
};
}
**`function.json`**
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"name": "firstStep",
"type": "serviceBus",
"queueName": "firststepqueue",
"connection": "MyServiceBus",
"direction": "out"
}
]
}
**`local.settings.json`**
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"MyServiceBus":"Endpoint=sb://bowman1012.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xxxxxx"
}
}
**`host.json`**
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 3.1.0)"
}
}
**`Configuration Settings on Azure`**
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/bcQVU.png
Try below and it will works fine:
**`host.json`**
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}
**`__init__.py`**
import logging
import azure.functions as func
def main(req: func.HttpRequest, msg: func.Out[str]) -> func.HttpResponse:
msg.set("This is test. 1227")
return func.HttpResponse("This is a test.")
**`function.json`**
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
},
{
"type": "queue",
"direction": "out",
"name": "msg",
"queueName": "outqueue",
"connection": "AzureStorageQueuesConnectionString"
}
]
}
**`local.settings.json`**
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureStorageQueuesConnectionString":"DefaultEndpointsProtocol=https;AccountName=0730bowmanwindow;AccountKey=xxxxxx==;EndpointSuffix=core.windows.net"
}
}