Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create multiple functions in one Azure Function App

I want to create multiple python Azure Functions within one Azure Functions App using the azure cli/core tools. One http triggered function and one blob triggered function.

I have the following folder structure:

├── azure-functions
│   ├── az-func-blob
│   │   ├── .python_packages
│   │   ├── .vscode
│   │   ├── .gitignore
│   │   ├── function_app.py
│   │   ├── host.json
│   │   ├── local_settings.json
│   │   ├── requirements.txt
│   ├── az-func-http
│   │   ├── .python_packages
│   │   ├── .vscode
│   │   ├── .gitignore
│   │   ├── function_app.py
│   │   ├── host.json
│   │   ├── local_settings.json
│   │   ├── requirements.txt
│   ├── README.md

Note: I created the individual function directories with the following commands within my project dir "azure-functions":

  1. Blob function:

    func init az-func-blob --worker-runtime python --model V2

    cd az-func-blob

    func new --template "Blob trigger" --name BlobTrigger

  2. Http function:

    func init az-func-http --worker-runtime python --model V2

    cd az-func-http

    func new --template "HTTP trigger" --name HTTPTrigger

If I navigate to the directory of one of these functions and run the command func azure functionapp publish SPIEFUNC2 it works fine. However running this command again in the other function directory will overwrite the Trigger/Function in Azure instead of appending a new one even though the trigger names are different. Apparently that's just how it works in Azure but I don't know how to create multiple functions within one Function app.

I saw this post here where someone suggested to use the same "host.json" for all functions. I don't know how to do this as every host.json is exactly the same anyway and looks like this:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  }
}

Can someone please explain in detail how to get set this up using only one Azure Function App instead of multiple function apps?

like image 229
Daniel Avatar asked Sep 09 '26 19:09

Daniel


1 Answers

Can someone please explain in detail how to get set this up using only one Azure Function App instead of multiple function apps?

I am able to deploy multiple functions to a Function App using func azure functionapp publish <function_APP_Name> command.

Thanks @Thomas for the comment, you need to run func init --worker-runtime python --model V2 command once and func new twice.

  • I have created one Http Triggered Function and Blob Triggered Function as shown below-

enter image description here

  • When you will run func init --worker-runtime python --model V2, all the default files will get created for a function. Upon running func new, it will add the triggers in it.

I have deployed the functions to the function app and got successful deployed output.

enter image description here enter image description here

I am able to see the functions in the function app.

enter image description here

Output-

enter image description here

like image 125
Ikhtesam Afrin Avatar answered Sep 11 '26 09:09

Ikhtesam Afrin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!