Azure-cli: Unable to create function app against existing consumption plan

Created on 30 Jan 2019  路  22Comments  路  Source: Azure/azure-cli

Describe the bug
It is not possible to create a function app against a specified consumption app service plan. The following error occurs:

There was a conflict. AlwaysOn cannot be set for this site as the plan does not allow it.

I think that setting --consumption-plan-location disables AlwaysOn, but --plan doesn't.

To Reproduce

  1. Create a consumption plan (see "Additional context" section)
  2. Try to create a function app against the plan created in step 1:
    az functionapp create --resource-group myresourcegroup --storage-account mystorageaccount --name myfunction --plan PlanFromStepOne
  3. Get the error:

There was a conflict. AlwaysOn cannot be set for this site as the plan does not allow it.

Expected behavior
It should create the function app against the specified plan, and not set "AlwaysOn" if the plan does not support it.

Environment summary
Install method: MSI
CLI version: 2.0.52
OS version: Windows 10, Version 1803, OS Build 17134.523
Shell type: cmd

Additional context
You can create a consumption app service plan in two ways.

The first way will create a plan called "NorthEuropePlan" with no option to specify the name (it's also part of creating a function app, rather than a discrete step):

az functionapp create
    --resource-group myresourcegroup 
    --storage-account mystorageaccount 
    --name myfunctionapp
    --runtime node
    --consumption-plan-location northeurope

The second is to use the az resource command. I consider this a much better approach as it is a discrete step, and also lets you specify the name:

az resource create
    --resource-group myresourcegroup
    --name myconsumptionplan
    --resource-type Microsoft.web/serverfarms
    --is-full-object
    --properties "{\"location\":\"northeurope\",\"sku\":{\"name\":\"Y1\",\"tier\":\"Dynamic\"}}"
Functions Functions-cli Service Attention customer-reported

Most helpful comment

I've also ran into this issue. Creating a functionapp with Consumption Plan with a name that conforms to our naming convention is a breeze in ARM, but to create it with Azure CLI, I had to do a horrible workaround:

  1. Create a consumption plan like @Jameskmonger described

az resource create --resource-group myresourcegroup --name myconsumptionplan --resource-type Microsoft.web/serverfarms --is-full-object --properties "{\"location\":\"westeurope\",\"sku\":{\"name\":\"Y1\",\"tier\":\"Dynamic\"}}"

  1. Create a function app with the --consumption-plan-location i.e.

az functionapp create --resource-group myresourcegroup --name myfunctionapp --consumption-plan-location westeurope

  1. Update the functionapp to use the plan created in step 1 i.e.

az functionapp update --resource-group myresourcegroup --name myfunctionapp --plan myconsumptionplan

  1. Delete the consumption plan auto generated in step 2 i.e. (I prefer az resource delete for this)

az resource delete --name WestEurope --resource-group myresourcegroup

I've also found that ver 2.0.8 Azure CLI does not give the "Always On" issue that @Jameskmonger described, but 2.3.1 and 2.4.0 do. But regardless, it just makes sense to be able to specify a newly created consumption plan name for a functionapp in the Azure-CLI and in my opinion should be implemented a.s.a.p.

All 22 comments

Hi, if you are using an Consumption Plan (Dynamic) you only need to set --consumption-plan-location, not --plan.
Consumption plans does not allow Always-On. If you create an App Service plan, then you can use Always On.

@pfranco22 What if I already have a consumption plan and I want to create a new app against that plan? --consumption-plan-location does not meet that requirement

@Jameskmonger it seems like if you specify --consumption-plan-location, the function app will use the consumption plan in that region.

However, the documentation and error message does not imply this, and both should be updated to clarify.

I just ran into this. @uberchris2 is right, if you don't specify a plan, but instead give the consumption-plan-location of your current plan, it creates the functionapp in the existing plan. not what I expected...

Had the same issue but using --consumption-plan-location didn't work and I'd just end up with WestEuropePlan and WestEuropePlan2.

In order to get around this, I've changed the tier from F1 to B1 (the free tier does not allow the AlwaysOn setting).

I have the same issue with an App Service, when I try to create a Service Plan and then assign to a shared SKU App Service I got this message

az appservice plan create --name "MyAwesomePlan" --resource-group "Super" --location "canadacentral" --sku SHARED
az webapp create -g "Super" -p "MyAwesomePlan" -n "MySuperWebApp" --verbose

Is possible to still doing so or cancel the property of Always On from Az CLI?

I have the same issue and I'm using the latest version of the CLI (as of this writing it's v2.0.69).

Is there a way to create a functionapp without setting "AlwaysOn"?

Hi, if you are using an Consumption Plan (Dynamic) you only need to set --consumption-plan-location, not --plan.
Consumption plans does not allow Always-On. If you create an App Service plan, then you can use Always On.

Sorry, but this method creates a very bad name for the consumption plan. If you have 5 azure functions in north europe, they will all be named NorthEuropePlan.

This is extremely bad, I should be able to use an F1 free tier plan, which I can through the portal, but via the az cli it assumes for some reason that always on is true even though I don't need always on. Also using consumption based ruins our naming standards as we can't control the name of the auto generated plan, so that is not an option either. Please default to always on false, or give us the option to set that flag via the cli (az functionapp create).

Come ON, Microsoft. How difficult is it to fix this?

I've also ran into this issue. Creating a functionapp with Consumption Plan with a name that conforms to our naming convention is a breeze in ARM, but to create it with Azure CLI, I had to do a horrible workaround:

  1. Create a consumption plan like @Jameskmonger described

az resource create --resource-group myresourcegroup --name myconsumptionplan --resource-type Microsoft.web/serverfarms --is-full-object --properties "{\"location\":\"westeurope\",\"sku\":{\"name\":\"Y1\",\"tier\":\"Dynamic\"}}"

  1. Create a function app with the --consumption-plan-location i.e.

az functionapp create --resource-group myresourcegroup --name myfunctionapp --consumption-plan-location westeurope

  1. Update the functionapp to use the plan created in step 1 i.e.

az functionapp update --resource-group myresourcegroup --name myfunctionapp --plan myconsumptionplan

  1. Delete the consumption plan auto generated in step 2 i.e. (I prefer az resource delete for this)

az resource delete --name WestEurope --resource-group myresourcegroup

I've also found that ver 2.0.8 Azure CLI does not give the "Always On" issue that @Jameskmonger described, but 2.3.1 and 2.4.0 do. But regardless, it just makes sense to be able to specify a newly created consumption plan name for a functionapp in the Azure-CLI and in my opinion should be implemented a.s.a.p.

I also ran into this issue. and followed the steps mentioned by @hentie .. But what I noticed is that,
after step 2 If I look at the function app, it has automatically linked to the existing consumption app service plan..

Hi, any update ?

@ahmedelnably, @fabiocav please take a look at the issue.

I also ran into this issue. and followed the steps mentioned by @hentie .. But what I noticed is that,
after step 2 If I look at the function app, it has automatically linked to the existing consumption app service plan..

@vikaskk13 That is exactly why I call it a horrible work-around. You have to temporarily create a resource just to delete it again :(

Having the same issue. Why is this still not assigned for fixing?

functions service team should look into this.

Wonder if you tried your workaround recently @hentie - it looks like it's causing the Azure management API to throw 500's when trying to create a new function app. Or maybe Azure is just having a bad day - can never really tell. 馃し

Wonder if you tried your workaround recently @hentie - it looks like it's causing the Azure management API to throw 500's when trying to create a new function app. Or maybe Azure is just having a bad day - can never really tell. 馃し

Hi @Silvenga , I just tested it this morning and the '_terrible workaround_' is still working on my side. I was using Azure CLI version 2.4.0 and deploying the resources to West Europe region for the test.

Perfect, thanks for checking @hentie!

Spoke with Azure Support - trying to create a Linux consumption plan with a custom name will return a 500 error, which seems to be a "works as designed". I may be in the minority, but that seems a little, uhm, wrong.

So it looks like something is fundamentally broken in Azure that needs to be fixed before this feature can be supported.

Still broken...

Was this page helpful?
0 / 5 - 0 ratings