Coder Social home page Coder Social logo

serverless-http-call's Introduction

Serverless HTTP Call (outbound)

Show an http call to a flask app from a serverless function in Azure Functions using Python.

HTTP Call Chain Azure Function (Python) --> Flask App

Getting Started

Deploy the flask app

change director to the flask app and execute the build and deploy script.

cd ./flaskapp
./build_deploy.sh

This will create an Azure Resource Group with a Container Registry. It will build the flask app into a Docker container, then deploy the container to an Azure Container Instance.

After it's deployed, note the hostname of the container instance that's printed out from the script to standard out. you can also get the information yourself running the CLI command:

az container list -g flaskapp --output json

Deploy the Function App

Follow the instructions to deploy the function to Azure using the following options:

NOTE: regardless of deployment method, target the flaskapp resource group. This will make it easy to clean up the resources when done with the example

Test the demo

Make an HTTP call out to the Function App endpoint for the http triggered function. An example local call:

curl http://localhost:7071/api/httpRequestResponse\?host\=flaskapp-demo.eastus.azurecontainer.io

[2021-08-19T16:29:43.003Z] Executing 'Functions.httpRequestResponse' (Reason='This function was programmatically called via the host APIs.', Id=6ad47ecb-6000-4a14-ab22-b9a7ebd67924)
[2021-08-19T16:29:43.191Z] Response from flaskapp-demo.eastus.azurecontainer.io:
[2021-08-19T16:29:43.191Z] request received = 16:29:42.

Cleanup

Azure resources

az group delete -n flaskapp --no-wait --yes

serverless-http-call's People

Contributors

kevinhillinger avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.