Skip to content

Generating the Azure Functions

Karlo K edited this page Dec 11, 2020 · 1 revision

Creating the Function Apps consists of two steps. The first is by editing the generator_config.json file. Its typical structure looks something like this:


{
  "persistorServices": [
    ["EVENT_GRID_BINDING", "eventGridTest"],
    ["EVENT_HUB_BINDING", "eventHubbindingTest", {"cardinality":  "many"}],
    ["SERVICE_BUS_BINDING", "serviceBusbindingTest", {"sb_type":  "topic"}],
    ["EVENT_HUB_PULL", "eventHubPullTest", {"append":  "true"}],
    ["EVENT_HUB_PULL", "eventHubPullTestWithInvoker", {"invoker":  "true"}],
    ["SERVICE_BUS_PULL", "serviceBusPullTest", {"sb_type":  "topic"}],
    ["SERVICE_BUS_PULL", "serviceBusPullTestWithInvoker", {"invoker":  "true", "sb_type":  "topic"}]
  ],
  "output": "../output/test"
}

The "output" key contains the path to the folder in which you will be deploying your Function Apps. Note that, in this case, "test" is not the name of the Function App, but rather the folder in which one or several Function Apps folders will be placed in.

The "output" folder need not exist beforehand. Running the generator multiple times with the same destination folder will overwrite the existing functions. However, if the generator is run, and some of the functions are removed from the configuration JSON, and the generator is re-run (with the same output folder), the functions removed from the configuration JSON will NOT be removed from the output folder.

If you are using a relative path when setting the "output" value, please note that it is relative to the active directory you are running the function generator script from!

The "persistorServices" key contains a list. Each item of this list represents a separate, isolated Function App to be generated. Each of these Function Apps are one independent versions of the Persistor. The items themselves are another list consisting of three members, all laid out in a specific order:

  • The first is the TYPE of Persistor you've chosen to use. The allowed options are:
EVENT_GRID_BINDING, EVENT_HUB_BINDING, SERVICE_BUS_BINDING, EVENT_HUB_PULL, SERVICE_BUS_PULL 
  • The second is the NAME of the Function App you wish to create. Note that, depending on how you set the "output" folder, you can set this to a name of an existing Function App folder structure, and make the Persistor into just one function that's a part of it, instead of the whole app.

  • The third is an EXTRA CONFIGURATION dictionary. This allows to deploy the Persistor with some additional features. For instance, if you use the Persistor variant that uses the invoker function, along with a Service Bus "PULL" variant, you would put a dictionary like so:

["SERVICE_BUS_PULL", "serviceBusPullTestWithInvoker", {"invoker":  "true"}]

For a full list of possible configurations and how they work, please consult the generator's expanded dedicated page with further information.

After setting the generator configuration file, simply run the generator (when positioned in the function_generator directory) with:

python generator.py

Your function Apps should be ready near-instantaneously. Note that running the generator does NOT clear out the output destination folder, if content exists within in. For further clarification on what this implies, please visit the generator's expanded dedicated page.