navneetlal / message-service-azure-serverless

Serverless function to post and get message filtered by name

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Azure Functions Message Service

Deploy to Azure

  • Function App
  • ConsmosDB (MongoAPI)

Pre-requisite

Steps

Step 1

  • Fork this repository into your namespace.
  • Click the Deploy to Azure Button on top of this page.
    • It will ask for the resource group, site name, database name, collection name.
    • After filling all the required field, click on verify + create

Step 2

After completion of step 1, you have a Function App and CosmosDB Database with Mongo API.

Next step will involve creating functions inside function app.

$ git clone https://github.com/<your-github-username>/message-service-azure-serverless
$ cd message-service-azure-serverless
$ npm i
$ npm run build

> message-service@1.0.0 build /home/<username>/<your-workspace>/message-service-azure-serverless
> tsc

$ func azure functionapp publish <function-app-name>

Getting site publishing info...
Creating archive for current directory...
Uploading 12.98 MB [##############################################################################]
Upload completed successfully.
Deployment completed successfully.
Syncing triggers...
Functions in <function-app-name>:
    RetrieveMessage - [httpTrigger]
        Invoke url: https://<function-app-name>.azurewebsites.net/api/retrievemessage

    SendMessage - [httpTrigger]
        Invoke url: https://<function-app-name>.azurewebsites.net/api/sendmessage

You will provided with the two invoke url for the functions

End Result and Testing

$ curl -X POST -H "Content-Type: application/json" \
    -d '{"message": "Hi David, How are you?"}' \
    https://<function-app-name>.azurewebsites.net/api/sendmessage?name=David

$ curl -X GET https://<function-app-name>.azurewebsites.net/api/retrievemessage?name=David

About

Serverless function to post and get message filtered by name


Languages

Language:TypeScript 100.0%