Coder Social home page Coder Social logo

azure_function_python_remote_build's Introduction

Python Azure Function Remote Build

Example repository for this blogpost to show how a relatively minimal Python application can be provisioned with Terraform in Azure, and then built and deployed remotely with a .zip file as Azure function app.

The README is written by a Linux user. Modify the examples for your platform where necessary.

Prerequisites

The following tools should be installed and available on your terminal PATH:

  • azure (az)
  • terraform
  • zip

Also, you should be logged in to your Azure account (az login) and have selected your desired Azure subscription (see e.g. az-account-switcher)

Deploy Azure resources with Terraform

Follow these steps to deploy the Azure resources with Terraform:

  1. Update the default values in terraform/variables.tf. You can additionally check if the naming conventions used in main.tf follow your (company's) style.
  2. Go to the terraform folder on the command line ({project root}/terraform/).
  3. Run terraform init to setup Terraform (download providers and setup initial state).
  4. Run terraform apply.

Besides deploying the resources in Azure, the last step also creates the deployment script as {project root}/scripts/deploy_function_app.sh.

Deploy the function app

In the previous step Terraform created the deploy script at {project root}/scripts/deploy_function_app.sh. This script consists of two steps, first building the zip, then using the Azure cli to trigger the remote build and deployment.

The script must be run from the project root so that the path references are correct. There are many ways to run a script on the commandline, I like:

sh scripts/deploy_function_app.sh

Note: in case you're extending this example application, the zip file should contain:

  • all files and folders required for the 'business logic' (in this example the app folder)
  • all functions folders (in this example there's only one function: the function folder)
  • the host.json file
  • the requirements.txt file

Smoke test

You can perform a simple smoke-test with curl to check that the function is running. The command looks like this for the default values in {project root}/terraform/variables.tf

curl https://dev-zipdeploy-functions.azurewebsites.net

azure_function_python_remote_build's People

Contributors

jjbankert avatar

Stargazers

 avatar

Watchers

 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.