Azure Classroomnotes 01/Mar/2022

Azure Functions (Contd..)

  • Scenarios: Here are list of few scenarios
    • Build a Web API
    • Process file uploads
    • Responding to database changes
    • Running scheduled tasks
    • Analyze IOT data streams
    • Process data in Realtime
  • As we build Azure fuctions, we have the following options
    • Language: C#, Java, Python, Powershell
    • Automate Deployment
    • Flexible Pricing
  • Refer Here for Azure Functions runtime versions

Creating an Azure Function

  • Refer Here for the official article
  • Install Azure Functions Core Tools Refer Here
  • Ensure Azure Functions Extension is added to Visual Studio Code
    Preview
  • Create a local project Refer Here
  • Refer the classroom video for the sample Azure function created and tested
import logging

import azure.functions as func


def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    isValid = True
    try:
        req_body = req.get_json()
        p = req_body['principal']
        t = req_body['time']
        r = req_body['rate']
        si = p * t * r /100
    except ValueError:
        isValid = False


    if isValid:
        return func.HttpResponse(f"Simple Intrest is {si}")
    else:
        return func.HttpResponse(
             "Ensure you send a json body with principal time and rate",
             status_code=200
        )

Preview
*

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner