Freigeben über


Azure Function Apps: Organizing the Azure Function Apps under same Consumption Plan

When we create an Azure Function App from Azure Portal on a Consumption plan we don't have the control over which Consumption plan to use.
In other words, if we want to put all of the azure functions under the same Consumption plan it doesn't seem to be possible.

However, it is possible but only at the time when creating the Azure Function App.

There are two ways (at least what I am aware of) of doing this.
1. Using the ARM template deployment
2. Using the Visual Studio.

Function App Deployment Using ARM template

Here is the link to the template for Azure Function App deployment on Consumption plan.
https://github.com/Azure/azure-quickstart-templates/tree/master/101-function-app-create-dynamic

While defining the resources to create/deploy we can mention existing Consumption plan name/id value for "serverFarmId".
"resources":

 "resources":
[
  {
    "apiVersion": "2015-08-01",
    "type": "Microsoft.Web/sites",
    "name": "[variables('functionAppName')]",
    "location": "[resourceGroup().location]",
    "kind": "functionapp",
    "properties": {
      "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]"
    }
  }
]

We can also create just the consumption plan without the Function App running on it and again by using the ARM template.

 "resources": [
  {
    "type": "Microsoft.Web/serverfarms",
    "apiVersion": "2015-04-01",
    "name": "[variables('hostingPlanName')]",
    "location": "[resourceGroup().location]",
    "properties": {
      "name": "[variables('hostingPlanName')]",
      "computeMode": "Dynamic",
      "sku": "Dynamic"
    }
  }
]

This means the creation of Consumption plan and the Azure Function app can be decoupled and not necessarily be clubbed together. However while creation of a Function app we need to make sure the Consumption plan exists and there is a dependency mentioned on the Function App for the Consumption plan.

Using Visual Studio

After creating the Azure Function App in Visual Studio 2017 when we click on publish, a dialogue pops up asking for the Publish target as shown below.

1

If we chose Azure Function App >> Create New we will further get the option to write the App Name, Chose the Subscription, Resource Group, and the App Service Plan.

2

If we expand the App Service Plan drop-down list we will get to see all the plans listed out to chose.

For Eg. :

myplan1 (S1, South Central US)
myplan2 (B1, East US)
myplan3 (D1, East US)
myconsumptionplan1 (Y1, Central Canada)

These are just the examples but if we have any plan for the subscription it will list out the similar way.

First three plans are quite clear as they belong to Standard(S1), Basic(B1), Shared(D1) pricing tiers respectively.
The last app service plan "myconsumptionplan1 (Y1, Central Canada)" is a Consumption plan and it is denoted by letter "Y" .

So an existing Consumption plan can be chosen from this option. Also, there is a button "new" in front of the App Service Plan field on this screen from where we can create a Consumption plan and then can use it.

3

This way we can organize our Azure Function Apps to run on a particular Consumption plan which can make the tracking easier