This will be a continuation of my previous article on how to get started with AWS Serverless locally, although this time we will be using Azure as our provider. I haven’t updated the previous, hence, a lot of updates on the versions needs to be taken into account. Below are the current versions that is compatible with both AWS and Azure:
Azure Function already has support for NodeJS 16 and a preview of 18 LTS, in our case we will still use the lower version which is compatible as well with AWS. We now the issue the command below, similar to what we did before:
sls create -t azure-nodejs -p user
We go inside our project directory and navigate to serverless.yml.
By default, the template provided uses NodeJS 12, we will replace it with NodeJS 14 runtime and install our serverless-offline plugin.
npm install serverless-offline — save-dev
For Azure Functions in Serverless Framework to work, we have to install the serverless-azure-functions, fortunately, upon creation of our service through azure-nodejs template, the plugin will already be present and installing will be for us to execute:
npm install
Upon installation, if your node is configured to log what is being downloaded, it might be interesting to see the following:
Right after the installation, we can proceed now on running it offline:
sls offline
By default there are 2 APIs that are already configured, hello and goodbye. We’ll test them against our postman to see it in action:
We were able to successfully call and invoke our API.