Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Migrate from Consumption Plan to App Service Plan (and vice versa) #155

Open
lindydonna opened this issue Jan 19, 2017 · 91 comments
Open
Milestone

Comments

@lindydonna
Copy link
Contributor

From @stephlocke on November 30, 2016 12:4

Is the migration path:

  1. Make sure you have all your keys
  2. Delete existing Function App
  3. Delete Service Plan
  4. Wait for DNS to flush
  5. Create new Function App on Consumption Plan with same name and same storage account
  6. Configure CI, app settings etc

Will this work with all the history so blob's don't get reprocessed etc?

Copied from original issue: Azure/azure-functions-host#1010

@lindydonna
Copy link
Contributor Author

@stephlocke This is better asked on the MSDN forums or StackOverflow (you'll have more folks seeing and answering questions there, as opposed to GitHub isuses).

Are you using blob or queue triggers? Those behave differently in terms of how multiple hosts will process.

@christopheranderson Do you know the answer to this question?

@lindydonna
Copy link
Contributor Author

From @stephlocke on December 2, 2016 20:51

IMO, this should be a docs thing as people will need to do this for maybe
the next year?

@lindydonna
Copy link
Contributor Author

From @stephlocke on December 5, 2016 11:44

I'm using blob triggers, and also eventhub triggers elsewhere that would need migrating also

@lindydonna lindydonna changed the title Q: Migration from Service Plans to Consumption Plans How to Migrate from Consumption Plan to App Service Plan (and vice versa) Jan 19, 2017
@lindydonna
Copy link
Contributor Author

This will become a real feature soon, so don't need to document.

@stoicskyline
Copy link

@lindydonna Any updates on this feature to automatically migrate from Consumption to App Service Plan?

@aherrick
Copy link

aherrick commented Oct 6, 2017

Would also like an update on this! Is there at least a manual process?

@jmarbutt
Copy link

I need an update on this also

@JensMadsen
Copy link

me too

@leftler
Copy link

leftler commented Oct 30, 2017

@lindydonna I would also like a update, it has been several months since we heard anything about this.

@valdisiljuconoks
Copy link

she is not working in MS anymore..

@stephlocke
Copy link

@christopheranderson are you able to pick this up? Still a big gaps in the docs / functionality that is still giving people trouble

@lindydonna
Copy link
Contributor Author

CC @jeffhollan

@lindydonna lindydonna reopened this Oct 30, 2017
@syedhassaanahmed
Copy link

+1

5 similar comments
@neilhosey
Copy link

+1

@mjirhage
Copy link

+1

@mharr
Copy link

mharr commented Dec 23, 2017

+1

@talkwaqar
Copy link

+1

@patmci
Copy link

patmci commented Jan 2, 2018

+1

@leftler
Copy link

leftler commented Jan 2, 2018

@jeffhollan can we get any kind of update on this, it has been two months without any kind of word from microsoft about this. Is it at least on the backlog?

@gpazo
Copy link

gpazo commented Mar 20, 2019

@adetayorabiu +1 modifying the serverFarmId using resource explorer caused the page to refresh with the serverFarmId property unchanged

@jeffhollan
Copy link
Contributor

The only officially supported way today to move from consumption to a dedicated app service plan would be to re-deploy. The differences in file and app data storage are technically navigable, but if anyone is stuck I'd recommend redeploying.

Note that there are some limitations if trying to change your app service plan regardless if functions. Things like trying to change the region aren't supported. It's also important to note the note here on webspaces, where even two plans in the same region may not be compatible to move without re-deploy. The way I tested was with two plans in the same resource group so I knew they were in the same webspace.

We are working on easier ways to move from a consumption to more dedicated plan shortly, and do have some UX planned to support that, but it will be limited in scope as well.

@pdemro
Copy link

pdemro commented Dec 26, 2019

We do have some UX and some features coming out in the next month that will allow migration between plan types in the portal

@jeffhollan Have these updates been deployed? I am attempting to "scale up" a function app this morning and do not see the option to change or modify the subscription

@leonheess
Copy link

When will this feature arrive?

@jeffhollan
Copy link
Contributor

See this related issue: #1194 (comment)

@stephlocke
Copy link

Still for me the main point of concern is avoiding a retriggering for already processed stuff. If we had a way of importing some history or state, for me things would be fine 👍

@IanKemp
Copy link

IanKemp commented Mar 5, 2020

Come on Microsoft...

When will this basic functionality be added...

Will it be sometime this millennium?

@IanKemp
Copy link

IanKemp commented Mar 5, 2020

When you create a support ticket in Azure about moving a function app, it actually links to this GitHub issue.

I created a ticket anyway because if Microsoft is happy to waste our time by not fixing this issue for THREE WHOLE YEARS, I'm happy to waste their time. And I will keep submitting a new ticket every time I have this issue and it's not fixed.

Pull your finger out, Microsoft.

@jeffhollan
Copy link
Contributor

Details on progress in this comment #1194 (comment)

@stephlocke
Copy link

stephlocke commented Mar 6, 2020

On that issue, it's unclear whether that supports state/history migration when you change plans. I had the situation where my function had already processed millions of blobs and I wouldn't want the change in plan to cause all those blobs to get re-processed.

(This was a blob trigger and back in the day there wasn't an event grid trigger 😂 which could avoid the issue now, but of course, there's still gonna be folks using blob triggers so it's still relevant)

@jeffhollan
Copy link
Contributor

The state for functions is stored in AzureWebJobsStorage - so assuming you keep the same AzureWebJobsStorage azure storage account (which I would recommend), it should preserve things like checkpoints.

@stephlocke
Copy link

So my point 5 on the original issue was right? Just point at the same storage and easy peasy? 😱

@chetanmotamarri
Copy link

Also regarding the PowerShell that was shared by @DeV1L earlier (thanks for sharing that), there are a few important details that are worth noting:

  1. When invoking Set-AzureRmWebApp, the -AppServicePlan parameter can only be the app service plan name if everything is in the same region/resource group.
  2. If the app service plan is in a different resource group than the Azure function, you can only switch to it using Set-AzureRmWebApp if you pass in the app service plan id (which can be found by looking up the app service plan with Get-AzureRmAppServicePlan, and then passing in the Id property of the object you get back).
  3. If the app service plan is in a different region than the Azure function, then you cannot switch to it using Set-AzureRmWebApp -- it returns an error indicating "Cannot change the site _________ to the App Service Plan _________ due to hosting constraints."

This solution is not working. I tried to change from Consumption plan to App service Premium plan. It worked for a day or two, after that my azure function got reverted back to original consumption plan.

@span
Copy link

span commented Apr 27, 2020

It can be done easy:

1. Create new AppService plan

2. Open CloudShell (PoS)

3. Run commands
   `Select-AzureRmSubscription -SubscriptionId "[id]" `
   `Set-AzureRmWebApp -Name "[function name]" -ResourceGroupName "[resource group]" -AppServicePlan "[new app service plan name]" `

Here is how to do it with az cli:

  1. Create new plan

  2. Login to your subscription with az login

  3. Run update command

az resource update \
    --resource-type "Microsoft.Web/sites" \
    --name "[function name]" \
    --resource-group "[resource group]" \
    --set serverFarmId="[new app service plan name]"

@jeffhollan
Copy link
Contributor

Just updating this comment - the work so that virtually all consumption functions should be able to move to a premium plan in the same resource group has finished rolling out.

@justinimel
Copy link

I am unable to run these commands in PowerShell or Bash.

Powershell gives this error:
Set-AzWebApp: Operation returned an invalid status code 'BadRequest'

Bash gives this error:
Property 'serverFarmId' not found on root. Send it as an additional property .
The request content was invalid and could not be deserialized: 'Could not find member 'serverFarmId' on object of type 'ResourceDefinition'. Path 'serverFarmId'.'.

Have the commands changed? Everything is in the same resource groups and regions.

@nexxai
Copy link

nexxai commented Aug 19, 2020

I'm getting the same issue.

In Bash:

➜  ~ az resource update --resource-type "Microsoft.Web/sites" --name "testing-move" --resource-group "testing-asp" --set serverFarmId="testing-destination"
Property 'serverFarmId' not found on root. Send it as an additional property .
The request content was invalid and could not be deserialized: 'Could not find member 'serverFarmId' on object of type 'ResourceDefinition'. Path 'serverFarmId'.'.

In PowerShell:

PS /home/me> Set-AzureRmWebApp -Name "testing-move" -ResourceGroupName "testing-asp" -AppServicePlan "testing-destination"
Set-AzWebApp: Operation returned an invalid status code 'BadRequest'

@jeffhollan Any ideas?

@DanielHolth
Copy link

Bash did not work, but PowerShell worked. Provided all 3 components exists in the same region (West-Europe in my case)

@IanKemp
Copy link

IanKemp commented Sep 3, 2020

Bash did not work, but PowerShell worked.

Did you use az.exe or the Set-AzWebApp cmdlet?

@DanielHolth
Copy link

DanielHolth commented Sep 3, 2020

Set-AzureRmWebApp -Name "..." -ResourceGroupName "..." -AppServicePlan "..."

Directly in the Browser azure portal (Cloud shell)

prereq:

  1. I've created the app service plan (premium) and resource group first.
  2. Published my function app using consumption plan.
  3. Ran the powershell command cmdlet above.

@rhythmnewt
Copy link

Neither of the commands worked for me with the same typical messages. Tried consumption plan to existing app service plan.
The request content was invalid and could not be deserialized: 'Could not find member 'serverFarmId' on object of type 'ResourceDefinition'. Path 'serverFarmId'.'.

and
Set-AzWebApp: Operation returned an invalid status code 'BadRequest'

@tdwright
Copy link

tdwright commented Oct 8, 2020

Hi @jeffhollan. Hope you're well?

Pleased to hear that

the work so that virtually all consumption functions should be able to move to a premium plan in the same resource group has finished rolling out

Apologies if I've missed it (in this now rather long issue), but are there any plans afoot to support the other direction? I.e. to move from a functions app backed by an app service plan to a consumption based plan?

@dominikfoldi
Copy link

I was able to move back my Function from App Service Plan to Consumption plan by using the https://resources.azure.com/ website.

Enter edit mode, find your Function App and change the following:

{
  serverFarmId: "..../<your-consumption-app-service-name>"
  ...
  // Scroll a bit down
  sku: "Dynamic"
}

Update the resource and you are done.

Make sure that you turn Always On off in the App Service Plan settings before the resource update to make this work.

@Gamecock
Copy link

This is still broken from the command line:
PowerShell Set-AzureRmWebApp returns a 'NotFound" for my function app. I retyped many times, tied both quotes and unquoted.
Bash: az resource update returns: Property 'serverFarmId' not found on root. Send it as an additional property .
@dominikfoldi answer for ResourceExplorer worked,I did not update "sku:" and it updated itself to PremiumV2.

@ghost
Copy link

ghost commented Nov 1, 2021

The az CLI is not correct. Use the following command to do the move.

az resource update \
    --resource-type "Microsoft.Web/sites" \
    --name "[function app name]" \
    --resource-group "[resource group]" \
    --set properties.serverFarmId="[new app service plan name]"

You can confirm the property in the REST API and it is under properties.serverFarmId.

Web Apps - Create Or Update

@dh3umil
Copy link

dh3umil commented May 18, 2022

Thanks @dominikfoldi and @jobullen.

That should work in most cases. However, if you still get a 'Bad Request' error: you will have to change numberOfWorkers from -1 to any value greater than 0.

First change the numberOfWorkers using:

az resource update --resource-type "Microsoft.Web/sites" --name <your-app> --resource-group <your-resource-group> --set properties.numOfWorkers=1

and then change the serverFarmID using:

az resource update --resource-type "Microsoft.Web/sites" --name <your-app> --resource-group <your-resource-group> --set properties.serverFarmId=<premium-plan-resource-id>

Alternatively you can use https://resources.azure.com/ to do the same.

@fzoccara
Copy link

fzoccara commented May 5, 2023

I hope we solved re-creating all azure function with windows instead of linux, not happy about this, but it seems working now.

take care
fra

@prenaissance
Copy link

Did anyone have their consumption based function app automatically changed to B1 plan? :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests