Azure : Function Apps via REST API, Deploy with App Service Plan and Consumption Plan

REST API documentation for Azure Functions is one of the poorest documentation I have ever seen. I thought to share a trick I have found in Azure Function REST API.

Azure Functions do support both App Service Plan and Consumption plan. Both of them are there for different purposes. App Service Plan does support hybrid connectivity while Consumption plan does elastic scaling. But when it comes to the Azure Function App creation via REST API how to handle both these plans.

Consumption Plan

If we want to create an Azure Function App with consumption plan, just call the REST API for the Web apps creation and in the body provide the following as JSON

{
     "kind": "functionapp", 
     "location": "South India", 
     "properties": { }
}

In the kind key, we have to mention functionapp to say this is a Azure Function App. app value for kind key will create a traditional web app. And we should not mention serverFarmId under properties. The serverFarmId property is the place where we define an App Service Plan for the app. If we just leave the properties as an empty object, Azure will create the default things for us with a 0 Small consumption plan.

consumption plan

App Service Plan

If our purpose is to create a Function app with an App Service Plan, we have to mention it as serverFarmId under properties.

{ 
   "kind": "functionapp", 
   "location": "South India", 
   "properties": 
   { 
      "serverFarmId" : "/subscriptions/[subscription id]/resourceGroups/[resource group name]/providers/Microsoft.Web/serverfarms/[app service plan]" 
   }
}

That’s it. Happy Coding.

PS 0 : If you see a “green cloud” in service plans, it is consumption plan (as shown in the above image). A “blue cloud” denotes an App Service plan.

PS 1 : This is the documentation for the Azure REST API for Web apps creation.

PS 2 : You must provide properties even though its empty. (ie, properties should not be null, but can be an empty object.

2 thoughts on “Azure : Function Apps via REST API, Deploy with App Service Plan and Consumption Plan

  1. As per my understanding Azure functions dont provide facility for Java, Python. Azure functions run internally on Microsoft windows machines but AWS lambda provide support for major programming languages and run on amazon linux machine i.e. lambda is faster as compared to azure functions.

    1. Hi Ganesh, Az Functions supported C#, F# and JS from 1.x version and Java, Python, PHP, Tyoescript, Batch, Bash and Powershell were experimental, where as the previously mentioned languages are in preview for Az Functions version 2.x on wards (ref : https://docs.microsoft.com/en-us/azure/azure-functions/supported-languages). Here is a the tutorial for Az Functions in Java – https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-java-maven .

      You can create function that can run on Linux. You have to install Azure CLI with .NET core and run Az Function on a Linux machine (preview) https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-azure-function-azure-cli-linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s