Code Monkey home page Code Monkey logo

azure-functions-template's Introduction

Azure-Functions-Template

This repository acts as a template for azure functions.



Prerequisites

Description

The function_builder file is a batch file designed to automate the setup of a Python-based Azure Function within a virtual environment. To activate it, just put the batch file inside the root directory and execute it.

Here are the main steps of the process:

  • Creating a Virtual Environment: The script then creates a Python virtual environment in the current directory. This isolates the Python environment for the Azure Function, preventing any conflicts with other Python projects on the same system.

  • User Input for Function Name: The script prompts the user to enter a name for the Azure Function.

  • Creating the Azure Function: The script creates a new directory named "Azure Functions", navigates into it, and then creates a new Azure Function with the provided name. The function is created with the Python worker runtime, using the v2 model, and the "Http Trigger" template for demo purpose..

  • Updating the Requirements File: The script navigates into the newly created Azure Function's directory and overwrites the requirements.txt file with a new set of dependencies.

Next Steps (Local)

  • Activate the Virtual Environment To activate the virtual env you have to run one of the activation applications inside the terminal. For PowerShell use the following command: bash PS C:\> <venv>\Scripts\Activate.ps1
  • Install the dependencies inside the function directory: pip install -r ./requirements.txt
  • Start the local azure function: func host start

    If the function does not return an exception you should see the localhost:// paths that are now active.

Next Steps (Deployment)

  • Make sure that you login with the azure CLI:
    az login
  • Create a resource group (either on portal.azure or with the following command):
    az group create --name <RESOURCEGROUPNAME> --location <LOCATION>
  • Create a storage account (either on portal.azure or with the following command):
    az storage account create --name <STORAGEACCOUNTNAME> --location <LOCATION> --resource-group <RESOURCEGROUPNAME> --sku Standard_LRS
  • Create a functionapp (either on portal.azure or with the following command):
    az functionapp create --resource-group <RESOURCEGROUPNAME> --consumption-plan-location <LOCATION> --runtime <RUNTIME> --functions-version 3 --name <FUNCTIONAPPNAME> --storage-account <STORAGEACCOUNTNAME> --os-type Linux
  • To download remote application settings:
    func azure functionapp fetch-app-settings <FUNCTIONAPPNAME>
  • To deploy your created function, use the following command:
    func azure functionapp publish <FUNCTIONAPPNAME>

Deployment with Github Actions

In order to use Github Actions for automatic deployment you have to adjust some settings. First make sure that you save the publish profile from your function:

  • In your Repo, go to [SETTINGS > SECRETS AND VARIABLES > ACTIONS] and store the publish profile from your azure function.
  • Go to the workflow and adjust the commented parts (the ones that start with "set this to your.....") to fit your own situation

Now when your code is ready for production, merge your code to the ["azure-production"] branch and the github action will deploy.

azure-functions-template's People

Contributors

dependabot[bot] avatar marcel-to avatar

Stargazers

 avatar

Watchers

 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.