How to set/change app service plan on an app service through azure cli (using az webapp update --set)

Zhanelya Subebayeva 0 Reputation points
2023-10-13T13:36:19.35+00:00

Hi, I've been trying to set app service plan on an app service, but with no luck, is there a way to do wo using az webapp update --set? I've tried the following with no luck:

   #az webapp update -g $SRA_RESOURCE_GROUP --n $APP --set plan=$PRELIVE_ASP
   #az webapp update -g $SRA_RESOURCE_GROUP --n $APP --set appServicePlanId=$PRELIVE_ASP_ID
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,961 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Luke Murray 11,436 Reputation points MVP Volunteer Moderator
    2023-10-14T23:43:14.0933333+00:00

    Hi, just for some additional clarification:

    • Are you looking at MOVING your existing app service to a different app service plan?

    If this is the case, it doesn't sound like it is possible using the CLI to do this, and I recommend raising an Issue directly on the Azure CLI issue.

    0 comments No comments

  2. VenkateshDodda-MSFT 25,111 Reputation points Microsoft Employee Moderator
    2023-10-19T14:16:46.5633333+00:00

    @Zhanelya Subebayeva Thanks for reaching out to Microsoft Q&A, apologize for any inconvenience caused on this.

    Based on the shared information, I understand that you are trying to change the app service plan of a particular app service using cmdlets.

    Adding to lukemurraynz response. To achieve your requirement, alternatively you can use the below PowerShell cmdlets.

    $currentappserviceplan=(Get-AzWebApp -ResourceGroupName <RGName> -Name <AppServiceName>).ServerFarmId.Split("/")[-1]
    $newappserviceplan=<NewAppServiceplan>
    Set-AzWebApp -ResourceGroupName <RGName> -Name <AppServiceName> -AppServicePlan $newappserviceplan
    

    Note: You can move an app to another App Service plan, as long as the source plan and the target plan are in the same resource group, geographical region, and of the same OS type. Any change in type such as Windows to Linux or any type that is different from the originating type is not supported.

    Here is the Sample output for your reference:

    User's image

    I have tested this in my environment it is working fine, and I would suggest you validate from your end as well.

    Feel free to reach back to me if you have any further questions on this.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.