states.azurerm.web.function_app

Azure Resource Manager (ARM) Function App State Module

New in version 3.0.0.

maintainer:

<devops@eitr.tech>

configuration:

This module requires Azure Resource Manager credentials to be passed via acct. Note that the authentication parameters are case sensitive.

Required provider parameters:

if using username and password:
  • subscription_id
  • username
  • password
if using a service principal:
  • subscription_id
  • tenant
  • client_id
  • secret

Optional provider parameters:

cloud_environment: Used to point the cloud driver to different API endpoints, such as Azure GovCloud. Possible values:

  • AZURE_PUBLIC_CLOUD (default)
  • AZURE_CHINA_CLOUD
  • AZURE_US_GOV_CLOUD
  • AZURE_GERMAN_CLOUD

Example acct setup for Azure Resource Manager authentication:

azurerm:
    default:
        subscription_id: 3287abc8-f98a-c678-3bde-326766fd3617
        tenant: ABCDEFAB-1234-ABCD-1234-ABCDEFABCDEF
        client_id: ABCDEFAB-1234-ABCD-1234-ABCDEFABCDEF
        secret: XXXXXXXXXXXXXXXXXXXXXXXX
        cloud_environment: AZURE_PUBLIC_CLOUD
    user_pass_auth:
        subscription_id: 3287abc8-f98a-c678-3bde-326766fd3617
        username: fletch
        password: 123pass

The authentication parameters can also be passed as a dictionary of keyword arguments to the connection_auth parameter of each state, but this is not preferred and could be deprecated in the future.

idem_azurerm.states.azurerm.web.function_app.absent(hub, ctx, name, resource_group, connection_auth=None, **kwargs)

New in version 3.0.0.

Ensure a Function App does not exist within the specified resource group.

Parameters:
  • name – The name of the Function App.
  • resource_group – The name of the resource group of the Function App.
  • connection_auth – A dict with subscription and authentication parameters to be used in connecting to the Azure Resource Manager API.

Example usage:

Ensure function app is absent:
    azurerm.web.function_app.absent:
        - name: my_app
        - resource_group: my_group
idem_azurerm.states.azurerm.web.function_app.present(hub, ctx, name, resource_group, functions_file_path, os_type, runtime_stack, storage_account, storage_rg=None, app_service_plan=None, functions_version=2, enable_app_insights=None, app_insights=None, tags=None, connection_auth=None, **kwargs)

New in version 3.0.0.

Ensure that a Function App exists.

Parameters:
  • name – The name of the Function App.
  • resource_group – The name of the resource group of the Function App.
  • functions_file_path

    The file path of the compressed (zip) file containing any Azure Functions that should be deployed to the Function App. The Azure Functions inside of this zip file should be using the same runtime stack or language that is specified within the runtime_stack parameter. This file will be uploaded every successfully run of this state. If there is a prior version of the zip file it will be overwritten. IMPORTANT: The code for all the functions in a specific function app should be located in a root project folder that contains a host configuration file and one or more subfolders. Each subfolder contains the code for a separate function. The folder structure is shown in the representation below:

    | functionapp.zip
    |   - host.json
    |   - MyFirstFunction/
    |     - function.json
    |     - ..
    |   - MySecondFunction/
    |     - function.json
    |     - ..
    |   - SharedCode/
    |   - bin/
    
  • os_type – The operation system utilized by the Function App. This cannot be changed after the Function App has been created. Possible values are “linux” or “windows”.
  • runtime_stack – The language stack to be used for functions in this Function App. Possible values are “dotnet”, “node”, “java”, “python”, or “powershell”.
  • storage_account – The name of the storage account that will hold the Azure Functions used by the Function App. This storage account must be of the kind “Storage” or “StorageV2”. If not already present, a container named “function-releases” will be created within this storage account to hold the zip file containing any Azure Functions.
  • storage_rg – (Optional, used with storage_account) The resource group of the storage account passed. This parameter is only necessary if the storage account has a different resource group than the one specified for the Function App.
  • app_service_plan – The name of the App Service (Consumption) Plan used by the Function App. If this parameter is not provided or the provided name is invalid/does not exist, then an App Service (Consumption) Plan will be built for the Function App with the name “plan-{name}”. This plan should have the same OS as specified by the os_type parameter.
  • functions_version – The version of Azure Functions to use. Additional information about Azure Functions versions can be found here: https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions. Possible values include: 1, 2, and 3. Defaults to 2.
  • enable_app_insights – Boolean flag for enabling Application Insights.
  • app_insights – (Optional, used with enable_app_insights) The name of the Application Insights Component to use for the Function App. If the specified Application Insights Component does not exist, then it will be created. If this parameter is not specified, then an Application Insights Component named “app-insights-{name}” will be created and used.
  • tags – A dictionary of strings representing tag metadata for the Function App.
  • connection_auth – A dict with subscription and authentication parameters to be used in connecting to the Azure Resource Manager API.

Example usage:

Ensure function app exists:
    azurerm.web.function_app.present:
        - name: my_app
        - resource_group: my_group
        - functions_file_path: "/path/to/functions.zip"
        - os_type: "linux"
        - runtime_stack: "python"
        - storage_account: my_account
        - app_service_plan: my_plan
        - enable_app_insights: True
        - tags:
            "Owner": "EITR Technologies"