azure logo
Azure Classic v5.38.0, Mar 21 23

azure.appservice.FunctionAppFunction

Manages a Function App Function.

Example Usage

Basic HTTP Trigger

using System.Collections.Generic;
using System.Text.Json;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new()
    {
        Location = "West Europe",
    });

    var exampleAccount = new Azure.Storage.Account("exampleAccount", new()
    {
        ResourceGroupName = exampleResourceGroup.Name,
        Location = exampleResourceGroup.Location,
        AccountTier = "Standard",
        AccountReplicationType = "LRS",
    });

    var exampleServicePlan = new Azure.AppService.ServicePlan("exampleServicePlan", new()
    {
        Location = exampleResourceGroup.Location,
        ResourceGroupName = exampleResourceGroup.Name,
        OsType = "Linux",
        SkuName = "S1",
    });

    var exampleLinuxFunctionApp = new Azure.AppService.LinuxFunctionApp("exampleLinuxFunctionApp", new()
    {
        Location = exampleResourceGroup.Location,
        ResourceGroupName = exampleResourceGroup.Name,
        ServicePlanId = exampleServicePlan.Id,
        StorageAccountName = exampleAccount.Name,
        StorageAccountAccessKey = exampleAccount.PrimaryAccessKey,
        SiteConfig = new Azure.AppService.Inputs.LinuxFunctionAppSiteConfigArgs
        {
            ApplicationStack = new Azure.AppService.Inputs.LinuxFunctionAppSiteConfigApplicationStackArgs
            {
                PythonVersion = "3.9",
            },
        },
    });

    var exampleFunctionAppFunction = new Azure.AppService.FunctionAppFunction("exampleFunctionAppFunction", new()
    {
        FunctionAppId = exampleLinuxFunctionApp.Id,
        Language = "Python",
        TestData = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["name"] = "Azure",
        }),
        ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["bindings"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["authLevel"] = "function",
                    ["direction"] = "in",
                    ["methods"] = new[]
                    {
                        "get",
                        "post",
                    },
                    ["name"] = "req",
                    ["type"] = "httpTrigger",
                },
                new Dictionary<string, object?>
                {
                    ["direction"] = "out",
                    ["name"] = "$return",
                    ["type"] = "http",
                },
            },
        }),
    });

});
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/appservice"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/storage"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
			Location: pulumi.String("West Europe"),
		})
		if err != nil {
			return err
		}
		exampleAccount, err := storage.NewAccount(ctx, "exampleAccount", &storage.AccountArgs{
			ResourceGroupName:      exampleResourceGroup.Name,
			Location:               exampleResourceGroup.Location,
			AccountTier:            pulumi.String("Standard"),
			AccountReplicationType: pulumi.String("LRS"),
		})
		if err != nil {
			return err
		}
		exampleServicePlan, err := appservice.NewServicePlan(ctx, "exampleServicePlan", &appservice.ServicePlanArgs{
			Location:          exampleResourceGroup.Location,
			ResourceGroupName: exampleResourceGroup.Name,
			OsType:            pulumi.String("Linux"),
			SkuName:           pulumi.String("S1"),
		})
		if err != nil {
			return err
		}
		exampleLinuxFunctionApp, err := appservice.NewLinuxFunctionApp(ctx, "exampleLinuxFunctionApp", &appservice.LinuxFunctionAppArgs{
			Location:                exampleResourceGroup.Location,
			ResourceGroupName:       exampleResourceGroup.Name,
			ServicePlanId:           exampleServicePlan.ID(),
			StorageAccountName:      exampleAccount.Name,
			StorageAccountAccessKey: exampleAccount.PrimaryAccessKey,
			SiteConfig: &appservice.LinuxFunctionAppSiteConfigArgs{
				ApplicationStack: &appservice.LinuxFunctionAppSiteConfigApplicationStackArgs{
					PythonVersion: pulumi.String("3.9"),
				},
			},
		})
		if err != nil {
			return err
		}
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"name": "Azure",
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		tmpJSON1, err := json.Marshal(map[string]interface{}{
			"bindings": []interface{}{
				map[string]interface{}{
					"authLevel": "function",
					"direction": "in",
					"methods": []string{
						"get",
						"post",
					},
					"name": "req",
					"type": "httpTrigger",
				},
				map[string]interface{}{
					"direction": "out",
					"name":      "$return",
					"type":      "http",
				},
			},
		})
		if err != nil {
			return err
		}
		json1 := string(tmpJSON1)
		_, err = appservice.NewFunctionAppFunction(ctx, "exampleFunctionAppFunction", &appservice.FunctionAppFunctionArgs{
			FunctionAppId: exampleLinuxFunctionApp.ID(),
			Language:      pulumi.String("Python"),
			TestData:      pulumi.String(json0),
			ConfigJson:    pulumi.String(json1),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.storage.Account;
import com.pulumi.azure.storage.AccountArgs;
import com.pulumi.azure.appservice.ServicePlan;
import com.pulumi.azure.appservice.ServicePlanArgs;
import com.pulumi.azure.appservice.LinuxFunctionApp;
import com.pulumi.azure.appservice.LinuxFunctionAppArgs;
import com.pulumi.azure.appservice.inputs.LinuxFunctionAppSiteConfigArgs;
import com.pulumi.azure.appservice.inputs.LinuxFunctionAppSiteConfigApplicationStackArgs;
import com.pulumi.azure.appservice.FunctionAppFunction;
import com.pulumi.azure.appservice.FunctionAppFunctionArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()        
            .location("West Europe")
            .build());

        var exampleAccount = new Account("exampleAccount", AccountArgs.builder()        
            .resourceGroupName(exampleResourceGroup.name())
            .location(exampleResourceGroup.location())
            .accountTier("Standard")
            .accountReplicationType("LRS")
            .build());

        var exampleServicePlan = new ServicePlan("exampleServicePlan", ServicePlanArgs.builder()        
            .location(exampleResourceGroup.location())
            .resourceGroupName(exampleResourceGroup.name())
            .osType("Linux")
            .skuName("S1")
            .build());

        var exampleLinuxFunctionApp = new LinuxFunctionApp("exampleLinuxFunctionApp", LinuxFunctionAppArgs.builder()        
            .location(exampleResourceGroup.location())
            .resourceGroupName(exampleResourceGroup.name())
            .servicePlanId(exampleServicePlan.id())
            .storageAccountName(exampleAccount.name())
            .storageAccountAccessKey(exampleAccount.primaryAccessKey())
            .siteConfig(LinuxFunctionAppSiteConfigArgs.builder()
                .applicationStack(LinuxFunctionAppSiteConfigApplicationStackArgs.builder()
                    .pythonVersion("3.9")
                    .build())
                .build())
            .build());

        var exampleFunctionAppFunction = new FunctionAppFunction("exampleFunctionAppFunction", FunctionAppFunctionArgs.builder()        
            .functionAppId(exampleLinuxFunctionApp.id())
            .language("Python")
            .testData(serializeJson(
                jsonObject(
                    jsonProperty("name", "Azure")
                )))
            .configJson(serializeJson(
                jsonObject(
                    jsonProperty("bindings", jsonArray(
                        jsonObject(
                            jsonProperty("authLevel", "function"),
                            jsonProperty("direction", "in"),
                            jsonProperty("methods", jsonArray(
                                "get", 
                                "post"
                            )),
                            jsonProperty("name", "req"),
                            jsonProperty("type", "httpTrigger")
                        ), 
                        jsonObject(
                            jsonProperty("direction", "out"),
                            jsonProperty("name", "$return"),
                            jsonProperty("type", "http")
                        )
                    ))
                )))
            .build());

    }
}
import pulumi
import json
import pulumi_azure as azure

example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_account = azure.storage.Account("exampleAccount",
    resource_group_name=example_resource_group.name,
    location=example_resource_group.location,
    account_tier="Standard",
    account_replication_type="LRS")
example_service_plan = azure.appservice.ServicePlan("exampleServicePlan",
    location=example_resource_group.location,
    resource_group_name=example_resource_group.name,
    os_type="Linux",
    sku_name="S1")
example_linux_function_app = azure.appservice.LinuxFunctionApp("exampleLinuxFunctionApp",
    location=example_resource_group.location,
    resource_group_name=example_resource_group.name,
    service_plan_id=example_service_plan.id,
    storage_account_name=example_account.name,
    storage_account_access_key=example_account.primary_access_key,
    site_config=azure.appservice.LinuxFunctionAppSiteConfigArgs(
        application_stack=azure.appservice.LinuxFunctionAppSiteConfigApplicationStackArgs(
            python_version="3.9",
        ),
    ))
example_function_app_function = azure.appservice.FunctionAppFunction("exampleFunctionAppFunction",
    function_app_id=example_linux_function_app.id,
    language="Python",
    test_data=json.dumps({
        "name": "Azure",
    }),
    config_json=json.dumps({
        "bindings": [
            {
                "authLevel": "function",
                "direction": "in",
                "methods": [
                    "get",
                    "post",
                ],
                "name": "req",
                "type": "httpTrigger",
            },
            {
                "direction": "out",
                "name": "$return",
                "type": "http",
            },
        ],
    }))
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleAccount = new azure.storage.Account("exampleAccount", {
    resourceGroupName: exampleResourceGroup.name,
    location: exampleResourceGroup.location,
    accountTier: "Standard",
    accountReplicationType: "LRS",
});
const exampleServicePlan = new azure.appservice.ServicePlan("exampleServicePlan", {
    location: exampleResourceGroup.location,
    resourceGroupName: exampleResourceGroup.name,
    osType: "Linux",
    skuName: "S1",
});
const exampleLinuxFunctionApp = new azure.appservice.LinuxFunctionApp("exampleLinuxFunctionApp", {
    location: exampleResourceGroup.location,
    resourceGroupName: exampleResourceGroup.name,
    servicePlanId: exampleServicePlan.id,
    storageAccountName: exampleAccount.name,
    storageAccountAccessKey: exampleAccount.primaryAccessKey,
    siteConfig: {
        applicationStack: {
            pythonVersion: "3.9",
        },
    },
});
const exampleFunctionAppFunction = new azure.appservice.FunctionAppFunction("exampleFunctionAppFunction", {
    functionAppId: exampleLinuxFunctionApp.id,
    language: "Python",
    testData: JSON.stringify({
        name: "Azure",
    }),
    configJson: JSON.stringify({
        bindings: [
            {
                authLevel: "function",
                direction: "in",
                methods: [
                    "get",
                    "post",
                ],
                name: "req",
                type: "httpTrigger",
            },
            {
                direction: "out",
                name: "$return",
                type: "http",
            },
        ],
    }),
});
resources:
  exampleResourceGroup:
    type: azure:core:ResourceGroup
    properties:
      location: West Europe
  exampleAccount:
    type: azure:storage:Account
    properties:
      resourceGroupName: ${exampleResourceGroup.name}
      location: ${exampleResourceGroup.location}
      accountTier: Standard
      accountReplicationType: LRS
  exampleServicePlan:
    type: azure:appservice:ServicePlan
    properties:
      location: ${exampleResourceGroup.location}
      resourceGroupName: ${exampleResourceGroup.name}
      osType: Linux
      skuName: S1
  exampleLinuxFunctionApp:
    type: azure:appservice:LinuxFunctionApp
    properties:
      location: ${exampleResourceGroup.location}
      resourceGroupName: ${exampleResourceGroup.name}
      servicePlanId: ${exampleServicePlan.id}
      storageAccountName: ${exampleAccount.name}
      storageAccountAccessKey: ${exampleAccount.primaryAccessKey}
      siteConfig:
        applicationStack:
          pythonVersion: '3.9'
  exampleFunctionAppFunction:
    type: azure:appservice:FunctionAppFunction
    properties:
      functionAppId: ${exampleLinuxFunctionApp.id}
      language: Python
      testData:
        fn::toJSON:
          name: Azure
      configJson:
        fn::toJSON:
          bindings:
            - authLevel: function
              direction: in
              methods:
                - get
                - post
              name: req
              type: httpTrigger
            - direction: out
              name: $return
              type: http

HTTP Trigger With Code Upload

using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new()
    {
        Location = "West Europe",
    });

    var exampleAccount = new Azure.Storage.Account("exampleAccount", new()
    {
        ResourceGroupName = exampleResourceGroup.Name,
        Location = exampleResourceGroup.Location,
        AccountTier = "Standard",
        AccountReplicationType = "LRS",
    });

    var exampleServicePlan = new Azure.AppService.ServicePlan("exampleServicePlan", new()
    {
        Location = exampleResourceGroup.Location,
        ResourceGroupName = exampleResourceGroup.Name,
        OsType = "Windows",
        SkuName = "S1",
    });

    var test = new Azure.AppService.WindowsFunctionApp("test", new()
    {
        Location = azurerm_resource_group.Test.Location,
        ResourceGroupName = azurerm_resource_group.Test.Name,
        ServicePlanId = azurerm_service_plan.Test.Id,
        StorageAccountName = azurerm_storage_account.Test.Name,
        StorageAccountAccessKey = azurerm_storage_account.Test.Primary_access_key,
        SiteConfig = new Azure.AppService.Inputs.WindowsFunctionAppSiteConfigArgs
        {
            ApplicationStack = new Azure.AppService.Inputs.WindowsFunctionAppSiteConfigApplicationStackArgs
            {
                DotnetVersion = "6",
            },
        },
    });

    var exampleFunctionAppFunction = new Azure.AppService.FunctionAppFunction("exampleFunctionAppFunction", new()
    {
        FunctionAppId = azurerm_linux_function_app.Example.Id,
        Language = "CSharp",
        Files = new[]
        {
            new Azure.AppService.Inputs.FunctionAppFunctionFileArgs
            {
                Name = "run.csx",
                Content = File.ReadAllText("exampledata/run.csx"),
            },
        },
        TestData = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["name"] = "Azure",
        }),
        ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["bindings"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["authLevel"] = "function",
                    ["direction"] = "in",
                    ["methods"] = new[]
                    {
                        "get",
                        "post",
                    },
                    ["name"] = "req",
                    ["type"] = "httpTrigger",
                },
                new Dictionary<string, object?>
                {
                    ["direction"] = "out",
                    ["name"] = "$return",
                    ["type"] = "http",
                },
            },
        }),
    });

});
package main

import (
	"encoding/json"
	"os"

	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/appservice"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/storage"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func readFileOrPanic(path string) pulumi.StringPtrInput {
	data, err := os.ReadFile(path)
	if err != nil {
		panic(err.Error())
	}
	return pulumi.String(string(data))
}

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
			Location: pulumi.String("West Europe"),
		})
		if err != nil {
			return err
		}
		_, err = storage.NewAccount(ctx, "exampleAccount", &storage.AccountArgs{
			ResourceGroupName:      exampleResourceGroup.Name,
			Location:               exampleResourceGroup.Location,
			AccountTier:            pulumi.String("Standard"),
			AccountReplicationType: pulumi.String("LRS"),
		})
		if err != nil {
			return err
		}
		_, err = appservice.NewServicePlan(ctx, "exampleServicePlan", &appservice.ServicePlanArgs{
			Location:          exampleResourceGroup.Location,
			ResourceGroupName: exampleResourceGroup.Name,
			OsType:            pulumi.String("Windows"),
			SkuName:           pulumi.String("S1"),
		})
		if err != nil {
			return err
		}
		_, err = appservice.NewWindowsFunctionApp(ctx, "test", &appservice.WindowsFunctionAppArgs{
			Location:                pulumi.Any(azurerm_resource_group.Test.Location),
			ResourceGroupName:       pulumi.Any(azurerm_resource_group.Test.Name),
			ServicePlanId:           pulumi.Any(azurerm_service_plan.Test.Id),
			StorageAccountName:      pulumi.Any(azurerm_storage_account.Test.Name),
			StorageAccountAccessKey: pulumi.Any(azurerm_storage_account.Test.Primary_access_key),
			SiteConfig: &appservice.WindowsFunctionAppSiteConfigArgs{
				ApplicationStack: &appservice.WindowsFunctionAppSiteConfigApplicationStackArgs{
					DotnetVersion: pulumi.String("6"),
				},
			},
		})
		if err != nil {
			return err
		}
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"name": "Azure",
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		tmpJSON1, err := json.Marshal(map[string]interface{}{
			"bindings": []interface{}{
				map[string]interface{}{
					"authLevel": "function",
					"direction": "in",
					"methods": []string{
						"get",
						"post",
					},
					"name": "req",
					"type": "httpTrigger",
				},
				map[string]interface{}{
					"direction": "out",
					"name":      "$return",
					"type":      "http",
				},
			},
		})
		if err != nil {
			return err
		}
		json1 := string(tmpJSON1)
		_, err = appservice.NewFunctionAppFunction(ctx, "exampleFunctionAppFunction", &appservice.FunctionAppFunctionArgs{
			FunctionAppId: pulumi.Any(azurerm_linux_function_app.Example.Id),
			Language:      pulumi.String("CSharp"),
			Files: appservice.FunctionAppFunctionFileArray{
				&appservice.FunctionAppFunctionFileArgs{
					Name:    pulumi.String("run.csx"),
					Content: readFileOrPanic("exampledata/run.csx"),
				},
			},
			TestData:   pulumi.String(json0),
			ConfigJson: pulumi.String(json1),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.storage.Account;
import com.pulumi.azure.storage.AccountArgs;
import com.pulumi.azure.appservice.ServicePlan;
import com.pulumi.azure.appservice.ServicePlanArgs;
import com.pulumi.azure.appservice.WindowsFunctionApp;
import com.pulumi.azure.appservice.WindowsFunctionAppArgs;
import com.pulumi.azure.appservice.inputs.WindowsFunctionAppSiteConfigArgs;
import com.pulumi.azure.appservice.inputs.WindowsFunctionAppSiteConfigApplicationStackArgs;
import com.pulumi.azure.appservice.FunctionAppFunction;
import com.pulumi.azure.appservice.FunctionAppFunctionArgs;
import com.pulumi.azure.appservice.inputs.FunctionAppFunctionFileArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()        
            .location("West Europe")
            .build());

        var exampleAccount = new Account("exampleAccount", AccountArgs.builder()        
            .resourceGroupName(exampleResourceGroup.name())
            .location(exampleResourceGroup.location())
            .accountTier("Standard")
            .accountReplicationType("LRS")
            .build());

        var exampleServicePlan = new ServicePlan("exampleServicePlan", ServicePlanArgs.builder()        
            .location(exampleResourceGroup.location())
            .resourceGroupName(exampleResourceGroup.name())
            .osType("Windows")
            .skuName("S1")
            .build());

        var test = new WindowsFunctionApp("test", WindowsFunctionAppArgs.builder()        
            .location(azurerm_resource_group.test().location())
            .resourceGroupName(azurerm_resource_group.test().name())
            .servicePlanId(azurerm_service_plan.test().id())
            .storageAccountName(azurerm_storage_account.test().name())
            .storageAccountAccessKey(azurerm_storage_account.test().primary_access_key())
            .siteConfig(WindowsFunctionAppSiteConfigArgs.builder()
                .applicationStack(WindowsFunctionAppSiteConfigApplicationStackArgs.builder()
                    .dotnetVersion("6")
                    .build())
                .build())
            .build());

        var exampleFunctionAppFunction = new FunctionAppFunction("exampleFunctionAppFunction", FunctionAppFunctionArgs.builder()        
            .functionAppId(azurerm_linux_function_app.example().id())
            .language("CSharp")
            .files(FunctionAppFunctionFileArgs.builder()
                .name("run.csx")
                .content(Files.readString(Paths.get("exampledata/run.csx")))
                .build())
            .testData(serializeJson(
                jsonObject(
                    jsonProperty("name", "Azure")
                )))
            .configJson(serializeJson(
                jsonObject(
                    jsonProperty("bindings", jsonArray(
                        jsonObject(
                            jsonProperty("authLevel", "function"),
                            jsonProperty("direction", "in"),
                            jsonProperty("methods", jsonArray(
                                "get", 
                                "post"
                            )),
                            jsonProperty("name", "req"),
                            jsonProperty("type", "httpTrigger")
                        ), 
                        jsonObject(
                            jsonProperty("direction", "out"),
                            jsonProperty("name", "$return"),
                            jsonProperty("type", "http")
                        )
                    ))
                )))
            .build());

    }
}
import pulumi
import json
import pulumi_azure as azure

example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_account = azure.storage.Account("exampleAccount",
    resource_group_name=example_resource_group.name,
    location=example_resource_group.location,
    account_tier="Standard",
    account_replication_type="LRS")
example_service_plan = azure.appservice.ServicePlan("exampleServicePlan",
    location=example_resource_group.location,
    resource_group_name=example_resource_group.name,
    os_type="Windows",
    sku_name="S1")
test = azure.appservice.WindowsFunctionApp("test",
    location=azurerm_resource_group["test"]["location"],
    resource_group_name=azurerm_resource_group["test"]["name"],
    service_plan_id=azurerm_service_plan["test"]["id"],
    storage_account_name=azurerm_storage_account["test"]["name"],
    storage_account_access_key=azurerm_storage_account["test"]["primary_access_key"],
    site_config=azure.appservice.WindowsFunctionAppSiteConfigArgs(
        application_stack=azure.appservice.WindowsFunctionAppSiteConfigApplicationStackArgs(
            dotnet_version="6",
        ),
    ))
example_function_app_function = azure.appservice.FunctionAppFunction("exampleFunctionAppFunction",
    function_app_id=azurerm_linux_function_app["example"]["id"],
    language="CSharp",
    files=[azure.appservice.FunctionAppFunctionFileArgs(
        name="run.csx",
        content=(lambda path: open(path).read())("exampledata/run.csx"),
    )],
    test_data=json.dumps({
        "name": "Azure",
    }),
    config_json=json.dumps({
        "bindings": [
            {
                "authLevel": "function",
                "direction": "in",
                "methods": [
                    "get",
                    "post",
                ],
                "name": "req",
                "type": "httpTrigger",
            },
            {
                "direction": "out",
                "name": "$return",
                "type": "http",
            },
        ],
    }))
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
import * as fs from "fs";

const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleAccount = new azure.storage.Account("exampleAccount", {
    resourceGroupName: exampleResourceGroup.name,
    location: exampleResourceGroup.location,
    accountTier: "Standard",
    accountReplicationType: "LRS",
});
const exampleServicePlan = new azure.appservice.ServicePlan("exampleServicePlan", {
    location: exampleResourceGroup.location,
    resourceGroupName: exampleResourceGroup.name,
    osType: "Windows",
    skuName: "S1",
});
const test = new azure.appservice.WindowsFunctionApp("test", {
    location: azurerm_resource_group.test.location,
    resourceGroupName: azurerm_resource_group.test.name,
    servicePlanId: azurerm_service_plan.test.id,
    storageAccountName: azurerm_storage_account.test.name,
    storageAccountAccessKey: azurerm_storage_account.test.primary_access_key,
    siteConfig: {
        applicationStack: {
            dotnetVersion: "6",
        },
    },
});
const exampleFunctionAppFunction = new azure.appservice.FunctionAppFunction("exampleFunctionAppFunction", {
    functionAppId: azurerm_linux_function_app.example.id,
    language: "CSharp",
    files: [{
        name: "run.csx",
        content: fs.readFileSync("exampledata/run.csx"),
    }],
    testData: JSON.stringify({
        name: "Azure",
    }),
    configJson: JSON.stringify({
        bindings: [
            {
                authLevel: "function",
                direction: "in",
                methods: [
                    "get",
                    "post",
                ],
                name: "req",
                type: "httpTrigger",
            },
            {
                direction: "out",
                name: "$return",
                type: "http",
            },
        ],
    }),
});
resources:
  exampleResourceGroup:
    type: azure:core:ResourceGroup
    properties:
      location: West Europe
  exampleAccount:
    type: azure:storage:Account
    properties:
      resourceGroupName: ${exampleResourceGroup.name}
      location: ${exampleResourceGroup.location}
      accountTier: Standard
      accountReplicationType: LRS
  exampleServicePlan:
    type: azure:appservice:ServicePlan
    properties:
      location: ${exampleResourceGroup.location}
      resourceGroupName: ${exampleResourceGroup.name}
      osType: Windows
      skuName: S1
  test:
    type: azure:appservice:WindowsFunctionApp
    properties:
      location: ${azurerm_resource_group.test.location}
      resourceGroupName: ${azurerm_resource_group.test.name}
      servicePlanId: ${azurerm_service_plan.test.id}
      storageAccountName: ${azurerm_storage_account.test.name}
      storageAccountAccessKey: ${azurerm_storage_account.test.primary_access_key}
      siteConfig:
        applicationStack:
          dotnetVersion: '6'
  exampleFunctionAppFunction:
    type: azure:appservice:FunctionAppFunction
    properties:
      functionAppId: ${azurerm_linux_function_app.example.id}
      language: CSharp
      files:
        - name: run.csx
          content:
            fn::readFile: exampledata/run.csx
      testData:
        fn::toJSON:
          name: Azure
      configJson:
        fn::toJSON:
          bindings:
            - authLevel: function
              direction: in
              methods:
                - get
                - post
              name: req
              type: httpTrigger
            - direction: out
              name: $return
              type: http

Create FunctionAppFunction Resource

new FunctionAppFunction(name: string, args: FunctionAppFunctionArgs, opts?: CustomResourceOptions);
@overload
def FunctionAppFunction(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        config_json: Optional[str] = None,
                        enabled: Optional[bool] = None,
                        files: Optional[Sequence[FunctionAppFunctionFileArgs]] = None,
                        function_app_id: Optional[str] = None,
                        language: Optional[str] = None,
                        name: Optional[str] = None,
                        test_data: Optional[str] = None)
@overload
def FunctionAppFunction(resource_name: str,
                        args: FunctionAppFunctionArgs,
                        opts: Optional[ResourceOptions] = None)
func NewFunctionAppFunction(ctx *Context, name string, args FunctionAppFunctionArgs, opts ...ResourceOption) (*FunctionAppFunction, error)
public FunctionAppFunction(string name, FunctionAppFunctionArgs args, CustomResourceOptions? opts = null)
public FunctionAppFunction(String name, FunctionAppFunctionArgs args)
public FunctionAppFunction(String name, FunctionAppFunctionArgs args, CustomResourceOptions options)
type: azure:appservice:FunctionAppFunction
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args FunctionAppFunctionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args FunctionAppFunctionArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args FunctionAppFunctionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args FunctionAppFunctionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args FunctionAppFunctionArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

FunctionAppFunction Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The FunctionAppFunction resource accepts the following input properties:

ConfigJson string

The config for this Function in JSON format.

FunctionAppId string

The ID of the Function App in which this function should reside. Changing this forces a new resource to be created.

Enabled bool

Should this function be enabled. Defaults to true.

Files List<FunctionAppFunctionFileArgs>

A file block as detailed below. Changing this forces a new resource to be created.

Language string

The language the Function is written in. Possible values are CSharp, Custom, Java, Javascript, Python, PowerShell, and TypeScript.

Name string

The name of the function. Changing this forces a new resource to be created.

TestData string

The test data for the function.

ConfigJson string

The config for this Function in JSON format.

FunctionAppId string

The ID of the Function App in which this function should reside. Changing this forces a new resource to be created.

Enabled bool

Should this function be enabled. Defaults to true.

Files []FunctionAppFunctionFileArgs

A file block as detailed below. Changing this forces a new resource to be created.

Language string

The language the Function is written in. Possible values are CSharp, Custom, Java, Javascript, Python, PowerShell, and TypeScript.

Name string

The name of the function. Changing this forces a new resource to be created.

TestData string

The test data for the function.

configJson String

The config for this Function in JSON format.

functionAppId String

The ID of the Function App in which this function should reside. Changing this forces a new resource to be created.

enabled Boolean

Should this function be enabled. Defaults to true.

files List<FunctionAppFunctionFileArgs>

A file block as detailed below. Changing this forces a new resource to be created.

language String

The language the Function is written in. Possible values are CSharp, Custom, Java, Javascript, Python, PowerShell, and TypeScript.

name String

The name of the function. Changing this forces a new resource to be created.

testData String

The test data for the function.

configJson string

The config for this Function in JSON format.

functionAppId string

The ID of the Function App in which this function should reside. Changing this forces a new resource to be created.

enabled boolean

Should this function be enabled. Defaults to true.

files FunctionAppFunctionFileArgs[]

A file block as detailed below. Changing this forces a new resource to be created.

language string

The language the Function is written in. Possible values are CSharp, Custom, Java, Javascript, Python, PowerShell, and TypeScript.

name string

The name of the function. Changing this forces a new resource to be created.

testData string

The test data for the function.

config_json str

The config for this Function in JSON format.

function_app_id str

The ID of the Function App in which this function should reside. Changing this forces a new resource to be created.

enabled bool

Should this function be enabled. Defaults to true.

files Sequence[FunctionAppFunctionFileArgs]

A file block as detailed below. Changing this forces a new resource to be created.

language str

The language the Function is written in. Possible values are CSharp, Custom, Java, Javascript, Python, PowerShell, and TypeScript.

name str

The name of the function. Changing this forces a new resource to be created.

test_data str

The test data for the function.

configJson String

The config for this Function in JSON format.

functionAppId String

The ID of the Function App in which this function should reside. Changing this forces a new resource to be created.

enabled Boolean

Should this function be enabled. Defaults to true.

files List<Property Map>

A file block as detailed below. Changing this forces a new resource to be created.

language String

The language the Function is written in. Possible values are CSharp, Custom, Java, Javascript, Python, PowerShell, and TypeScript.

name String

The name of the function. Changing this forces a new resource to be created.

testData String

The test data for the function.

Outputs

All input properties are implicitly available as output properties. Additionally, the FunctionAppFunction resource produces the following output properties:

ConfigUrl string

The URL of the configuration JSON.

Id string

The provider-assigned unique ID for this managed resource.

InvocationUrl string

The invocation URL.

ScriptRootPathUrl string

The Script root path URL.

ScriptUrl string

The script URL.

SecretsFileUrl string

The URL for the Secrets File.

TestDataUrl string

The Test data URL.

Url string

The function URL.

ConfigUrl string

The URL of the configuration JSON.

Id string

The provider-assigned unique ID for this managed resource.

InvocationUrl string

The invocation URL.

ScriptRootPathUrl string

The Script root path URL.

ScriptUrl string

The script URL.

SecretsFileUrl string

The URL for the Secrets File.

TestDataUrl string

The Test data URL.

Url string

The function URL.

configUrl String

The URL of the configuration JSON.

id String

The provider-assigned unique ID for this managed resource.

invocationUrl String

The invocation URL.

scriptRootPathUrl String

The Script root path URL.

scriptUrl String

The script URL.

secretsFileUrl String

The URL for the Secrets File.

testDataUrl String

The Test data URL.

url String

The function URL.

configUrl string

The URL of the configuration JSON.

id string

The provider-assigned unique ID for this managed resource.

invocationUrl string

The invocation URL.

scriptRootPathUrl string

The Script root path URL.

scriptUrl string

The script URL.

secretsFileUrl string

The URL for the Secrets File.

testDataUrl string

The Test data URL.

url string

The function URL.

config_url str

The URL of the configuration JSON.

id str

The provider-assigned unique ID for this managed resource.

invocation_url str

The invocation URL.

script_root_path_url str

The Script root path URL.

script_url str

The script URL.

secrets_file_url str

The URL for the Secrets File.

test_data_url str

The Test data URL.

url str

The function URL.

configUrl String

The URL of the configuration JSON.

id String

The provider-assigned unique ID for this managed resource.

invocationUrl String

The invocation URL.

scriptRootPathUrl String

The Script root path URL.

scriptUrl String

The script URL.

secretsFileUrl String

The URL for the Secrets File.

testDataUrl String

The Test data URL.

url String

The function URL.

Look up Existing FunctionAppFunction Resource

Get an existing FunctionAppFunction resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: FunctionAppFunctionState, opts?: CustomResourceOptions): FunctionAppFunction
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        config_json: Optional[str] = None,
        config_url: Optional[str] = None,
        enabled: Optional[bool] = None,
        files: Optional[Sequence[FunctionAppFunctionFileArgs]] = None,
        function_app_id: Optional[str] = None,
        invocation_url: Optional[str] = None,
        language: Optional[str] = None,
        name: Optional[str] = None,
        script_root_path_url: Optional[str] = None,
        script_url: Optional[str] = None,
        secrets_file_url: Optional[str] = None,
        test_data: Optional[str] = None,
        test_data_url: Optional[str] = None,
        url: Optional[str] = None) -> FunctionAppFunction
func GetFunctionAppFunction(ctx *Context, name string, id IDInput, state *FunctionAppFunctionState, opts ...ResourceOption) (*FunctionAppFunction, error)
public static FunctionAppFunction Get(string name, Input<string> id, FunctionAppFunctionState? state, CustomResourceOptions? opts = null)
public static FunctionAppFunction get(String name, Output<String> id, FunctionAppFunctionState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
ConfigJson string

The config for this Function in JSON format.

ConfigUrl string

The URL of the configuration JSON.

Enabled bool

Should this function be enabled. Defaults to true.

Files List<FunctionAppFunctionFileArgs>

A file block as detailed below. Changing this forces a new resource to be created.

FunctionAppId string

The ID of the Function App in which this function should reside. Changing this forces a new resource to be created.

InvocationUrl string

The invocation URL.

Language string

The language the Function is written in. Possible values are CSharp, Custom, Java, Javascript, Python, PowerShell, and TypeScript.

Name string

The name of the function. Changing this forces a new resource to be created.

ScriptRootPathUrl string

The Script root path URL.

ScriptUrl string

The script URL.

SecretsFileUrl string

The URL for the Secrets File.

TestData string

The test data for the function.

TestDataUrl string

The Test data URL.

Url string

The function URL.

ConfigJson string

The config for this Function in JSON format.

ConfigUrl string

The URL of the configuration JSON.

Enabled bool

Should this function be enabled. Defaults to true.

Files []FunctionAppFunctionFileArgs

A file block as detailed below. Changing this forces a new resource to be created.

FunctionAppId string

The ID of the Function App in which this function should reside. Changing this forces a new resource to be created.

InvocationUrl string

The invocation URL.

Language string

The language the Function is written in. Possible values are CSharp, Custom, Java, Javascript, Python, PowerShell, and TypeScript.

Name string

The name of the function. Changing this forces a new resource to be created.

ScriptRootPathUrl string

The Script root path URL.

ScriptUrl string

The script URL.

SecretsFileUrl string

The URL for the Secrets File.

TestData string

The test data for the function.

TestDataUrl string

The Test data URL.

Url string

The function URL.

configJson String

The config for this Function in JSON format.

configUrl String

The URL of the configuration JSON.

enabled Boolean

Should this function be enabled. Defaults to true.

files List<FunctionAppFunctionFileArgs>

A file block as detailed below. Changing this forces a new resource to be created.

functionAppId String

The ID of the Function App in which this function should reside. Changing this forces a new resource to be created.

invocationUrl String

The invocation URL.

language String

The language the Function is written in. Possible values are CSharp, Custom, Java, Javascript, Python, PowerShell, and TypeScript.

name String

The name of the function. Changing this forces a new resource to be created.

scriptRootPathUrl String

The Script root path URL.

scriptUrl String

The script URL.

secretsFileUrl String

The URL for the Secrets File.

testData String

The test data for the function.

testDataUrl String

The Test data URL.

url String

The function URL.

configJson string

The config for this Function in JSON format.

configUrl string

The URL of the configuration JSON.

enabled boolean

Should this function be enabled. Defaults to true.

files FunctionAppFunctionFileArgs[]

A file block as detailed below. Changing this forces a new resource to be created.

functionAppId string

The ID of the Function App in which this function should reside. Changing this forces a new resource to be created.

invocationUrl string

The invocation URL.

language string

The language the Function is written in. Possible values are CSharp, Custom, Java, Javascript, Python, PowerShell, and TypeScript.

name string

The name of the function. Changing this forces a new resource to be created.

scriptRootPathUrl string

The Script root path URL.

scriptUrl string

The script URL.

secretsFileUrl string

The URL for the Secrets File.

testData string

The test data for the function.

testDataUrl string

The Test data URL.

url string

The function URL.

config_json str

The config for this Function in JSON format.

config_url str

The URL of the configuration JSON.

enabled bool

Should this function be enabled. Defaults to true.

files Sequence[FunctionAppFunctionFileArgs]

A file block as detailed below. Changing this forces a new resource to be created.

function_app_id str

The ID of the Function App in which this function should reside. Changing this forces a new resource to be created.

invocation_url str

The invocation URL.

language str

The language the Function is written in. Possible values are CSharp, Custom, Java, Javascript, Python, PowerShell, and TypeScript.

name str

The name of the function. Changing this forces a new resource to be created.

script_root_path_url str

The Script root path URL.

script_url str

The script URL.

secrets_file_url str

The URL for the Secrets File.

test_data str

The test data for the function.

test_data_url str

The Test data URL.

url str

The function URL.

configJson String

The config for this Function in JSON format.

configUrl String

The URL of the configuration JSON.

enabled Boolean

Should this function be enabled. Defaults to true.

files List<Property Map>

A file block as detailed below. Changing this forces a new resource to be created.

functionAppId String

The ID of the Function App in which this function should reside. Changing this forces a new resource to be created.

invocationUrl String

The invocation URL.

language String

The language the Function is written in. Possible values are CSharp, Custom, Java, Javascript, Python, PowerShell, and TypeScript.

name String

The name of the function. Changing this forces a new resource to be created.

scriptRootPathUrl String

The Script root path URL.

scriptUrl String

The script URL.

secretsFileUrl String

The URL for the Secrets File.

testData String

The test data for the function.

testDataUrl String

The Test data URL.

url String

The function URL.

Supporting Types

FunctionAppFunctionFile

Content string

The content of the file. Changing this forces a new resource to be created.

Name string

The filename of the file to be uploaded. Changing this forces a new resource to be created.

Content string

The content of the file. Changing this forces a new resource to be created.

Name string

The filename of the file to be uploaded. Changing this forces a new resource to be created.

content String

The content of the file. Changing this forces a new resource to be created.

name String

The filename of the file to be uploaded. Changing this forces a new resource to be created.

content string

The content of the file. Changing this forces a new resource to be created.

name string

The filename of the file to be uploaded. Changing this forces a new resource to be created.

content str

The content of the file. Changing this forces a new resource to be created.

name str

The filename of the file to be uploaded. Changing this forces a new resource to be created.

content String

The content of the file. Changing this forces a new resource to be created.

name String

The filename of the file to be uploaded. Changing this forces a new resource to be created.

Import

a Function App Function can be imported using the resource id, e.g.

 $ pulumi import azure:appservice/functionAppFunction:FunctionAppFunction example "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1/functions/function1"

Package Details

Repository
Azure Classic pulumi/pulumi-azure
License
Apache-2.0
Notes

This Pulumi package is based on the azurerm Terraform Provider.