Skip to main content

My First Azure Function app using CLI

Goal:
    Here we will learn about creating and deploying our first azure function app on azure cloud, everything from command line.
 
Steps:
    First we will start with installing all preliminary command line utilities. And then we will create function locally to test, debug and then we will deploy it on the azure cloud function app.
  1. Install npm as most of azure utilities written in node, so to download all dependencies we will require npm.
  2.  sudo apt install npm

  3. Install python3 pip, virtual env with few other python development dependencies as we gonna develop our first app in python.
  4.  sudo apt install -y python3-pip python3-venv build-essential libssl-dev libffi-dev python3-dev

  5. Install azure function command line utility to initialize, debug and publish functions and azure cli to interact with azure cloud.
  6.  sudo npm install -g azure-functions-core-tools
     func --version
     curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
     az --version

  7. Create virtual env in python and activate it.
  8.  python3 -m venv my_env
     source my_env/bin/activate

  9. Initialize first function project
  10.  func init LocalFunctionProj --python

  11. Create first azure function on local system.
  12.  cd LocalFunctionProj/
     func new --name BasicHttpExample --template "HTTP trigger"

  13. Start your function and test it locally.
  14.  func start

  15. Test using curl commands
     curl http://localhost:7071/api/BasicHttpExample
     curl http://localhost:7071/api/BasicHttpExample?name=piyushMandovra

  16. Login using azure cli so that you can deploy on azure cloud from command line. It will take you to browser to login your azure account.
  17.  az login

  18. Publish it on azure cloud function app you have created from browser. Make sure function app is already created and you don't have any other function already deployed on function app other wise it will overwrite with whatever local version you have.
  19.  func azure functionapp publish FunctionAPPName
     
Hope it helped you in creating and deploying your first azure function. Let me know in comments in case you have faced any difficulty. I will try to help ASAP.
 

Comments

Post a Comment

Popular posts from this blog

Useful MongoDB commands

To export JSON from MongoDB Collection   mongoexport -h replicaSet/primaryHost,secondaryHost -u username -p pwd --db dbName -c collectionName --quiet > collectionExport.json To export BSON from MongoDB Collection mongodump -h replicaSet/primaryHost,secondaryHost -u username -p pwd --db dbName -c collectionName -o - > collectionDump.bson To export some fields in csv from MongoDB Collection mongoexport --host primaryHost --db dbName --collection collectionName --fields 'field1,field2,field3' --out collection.csv --csv -u userName -p To run javascript on MongoDB mongo replicaSet/primaryHost,secondaryHost/dbName -u userName mongoScript.js -p To restore bson in MongoDB mongorestore --host primaryHost --db dbName --collection collectionName -u userName -p --drop  collectionName .bson

Install Central Logging on Amazon Linux

Goal: In these tutorial we gonna cover setup of central logging system on amazon linux (CentOs) in same aws vpc . We will setup one central log server to receive log using rsyslog, after that we will setup one client to forward apache & syslog to central server. we already covered forward logs from central log server to ELK stack for analyzing. Logging Stack Component: Central Log server Multiple logging client server/Any apache web server generating logs Rsyslog: we setup with rsyslog v8-stable. You can use any rsyslog  version after rsyslog-6, because we encountered rsyslog drop message in earlier version. Prerequisites: Rsyslog is quite light weight, we doesn't requirement any high configuration machine, aws t2.micro should be enough. We are running t2.micro in production for central log server to receive around 1000 log entry/second, server is using less then 2 percent/sec within same vpc. Now Let's Start we gonna break these tutorial in two pa...