First, add the following export to your root
index.js. If there's an existing export there, typically for AWS Lambda, remove it. This function is what gets called by the Azure Functions language worker process when an HTTP request comes in.
Second, create a new file called
host.json in the same directory as your
index.js, with the following contents. This indicates to Azure Functions that this is a valid function app and that the much better v2 runtime should be used.
Finally, create a new file called
function.json in a subdirectory named
webhook with the following contents. You can name the directory anything you want, it's just the endpoint name for your function.
Typically you should never need to run the function locally, using instead the
run command of the Jovo CLI to launch the webhook. If you do wish to run it locally inside the Azure Functions runtime, here's how to do that.
First, install the Azure Functions Core Tools:
Then run the following command from the root of your project (where
You should see the runtime initialize and highlight the URL of your webhook.
npm ci --only=prodto install just the production dependencies in
That's it! When initially setting up your function app in the Azure Portal before the first deployment, make sure to set the
WEBSITE_RUN_FROM_PACKAGE app setting to
1 to enable Run from Package. You'll also want to set the
The FilePersistence database integration is strongly discouraged on Azure Functions. It also doesn't work at all when you use Run From Package, which makes the file system read-only (and greatly speeds up the deployment and cold start of your function). It is encouraged to switch to DynamoDB or to simply not use any database integration at all. You can do the latter by setting
saveUserOnResponseEnabled: false on your Jovo config object.
Azure Cosmos DB would be the ideal database integration, but no one's written one for it yet. Contributions appreciated!
Any specific questions? Just drop them below. Alternatively, you can also fill out this feedback form. Thank you!