It's possible to create App Service Plans using Azure Powershell? - azure

As the title say, I need to create App Service Plans programmatilly, The scenario:
N azure websites will be created (dynamically, using azure powershell too)
If someday the Premium App Service Plan can't handle the quantity of websites (even with autoscaling by cpu usage), another service plan must be created to hold new sites.
It is possible? Or Am I going to the wrong way to accomplish this?

Unless your design doesn't permit it, when you create a new Premium App Service Plan, create it in a new resource group, as that will give it a greater chance to have enough capacity to scale.
Using Azure PowerShell version 1.1.0 you can use the following command to create new app service plans
New-AzureRmAppServicePlan -Location "South Central US" -ResourceGroupName DestinationAzureResourceGroup -Name NewAppServicePlan -Sku Premium

Related

how to fix 'conflicts with an already existing hostname' while cloning web app using Azure cloudshell

Scenario: You want to clone an app to another region, while configuring an Azure Resource Manager traffic manager profile that includes both apps.
Below are the commands I tried
$srcapp = Get-AzWebApp -ResourceGroupName SourceAzureResourceGroup -Name
source-webapp
$destapp = New-AzWebApp -ResourceGroupName DestinationAzureResourceGroup -Name dest-webapp -Location "South Central US" -AppServicePlan DestinationAppServicePlan -SourceWebApp $srcapp -TrafficManagerProfileName newTrafficManagerProfile
the above commands fail with ""Creating app with backup from 'subscriptiondetailshere' failed: Detail: Hostname \'abc.xyz.companydomain.com\' conflicts with an already existing hostname. ExtendedCode: 04005"
FYI : the apps are hosted in standard app service plan. I did read documentation saying only the premium apps can be cloned but I was able to clone this particular app in standard plan through Azure Portal UI.
I want to be able to automate this using the ps. Any pointers are appreciated
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-app-cloning
Update:
copied web app:
Traffic manager:
First, azure web app clone does support standard app service plan. Here is a screenshot from the doc:
Second, the code you're using is correct, I did a test at my side, it's working fine(The web app is copied from central us to west us, after copied, everything is working fine):
For the conflicting error, you should check in your destination resource group if there is a existing web app with that host name(you mentioned that you can copy from azure portal, maybe you didn't delete it when you were using code to copy it).

Move app service from one app service plan to another (same resource group and region)

I have two app service plans running in the same region, same resource group and in the same subscription. I have a web app in app service plan a, that I want to move to app service plan b. When clicking Change App Service Plan, the Portal tells me that "No App Service Plans Found".
App service plan a is running on Standard: 1 Small. App service plan b is running on Standard: 2 Large. Changing app service plan a to Standard: 1 Large, doesn't make app service plan b show up when trying to move the app service.
What could be the problem here?
I'm pretty sure I found out why I cannot move my app service between plans. Besides resource groups, subscriptions and regions, there is a concept called Webspaces. As I understand it, a webspace is a number of physical servers within the same rack or something similar. In order to move app services between plans, the app services needs to be within the same webspace too.
You have to check the webspace between the 2 App Service Plans. Are there identical?
You might move (multiple times) your App Service Plan to different Ressource Group but the webspace is based on your original Resource Group (when you created this App Service Plan the first time)
You might have also deleted your original Resource Group, so you might have to recreate it? (I have never tried this case, but it should create in the same webspace then)
To check I use PowerShell command:
Login-AzureRMAccount
Get-AzureRmSubscription
Select-AzureRmSubscription -SubscriptionId <Your Subscription Guid>
Get-AzureRmResource -ResourceId "/subscriptions/<SUB-ID>/resourceGroups/<RG-NAME>/resources" | Select Name, ResourceName, #{Name='webSpace'; Expression={$_.Properties.webSpace}} | Format-List
For the name space, you will get something like:
Name : Consoto_AppServicePlan
ResourceName : Consoto_ResourceGroup
webSpace : Consoto-SouthCentralUSwebspace
(Supposed that the location is South Central US)
So if you want to move your App Service to another App Service Plan name, you will have to create a new App Service Plan in the Resource Group named "Consoto" (refer to my example above) in the Location South Central US in the same subscription of course.
Then you will be able to use the Change App Service Plan functionality in the Azure Portal

Change App Service Plan does not working after move to another resource Group

I have a strange issue in azure portal after moving my WebApp and App Service Plan to another resource group. After click to Change App Service Plan I'm getting that info:
Application is worrking but I can't do anything with App Service Plan settings, moreover I can't event do this from powershell with using command:
Set-AzureRmWebApp -Name <webapp name> -ResourceGroupName <resource group name> -AppServicePlan <new app service plan>
Ticket submitted for support!
Does anyone know how to fix it?
#komluk, As Avanish said that you can't move WebApp resources between web spaces and Moving web apps to App Service plans that are in data centers in different geographical locations is not supported.

Move Azure website between App Service Plans

Is it possible to move an Azure Website to a different (or new) App Service Plan?
I have already tried both the old and new portals but cannot find the options for this.
The original accepted answer is more than a year old. In Azure world, that's an eternity. The "Change App Plan" button in the Azure Portal is no longer present it appears (as of 2016-06-17), so I'm throwing in the Powershell command I needed to use in order to move a Webapp to another App Service Plan.
Set-AzureRmWebApp -Name <webapp name> -ResourceGroupName <resource group name> -AppServicePlan <new app service plan>
Set-AzureRmWebAppSlot -Name <webapp name> -Slot <slot name> -ResourceGroupName <resource group name> -AppServicePlan <new app service plan>
The option "Change App Service plan" has been moved to the APP SERVICE PLAN menu.
Yes, you can do this from the Web app blade in the Azure portal. You have to expand the toolbar though to see the option. See below.
I needed to move things between different subscriptions, which is quite possible according to documentation. Much is shamelessly copied from the azure website. This solution is taking advantage of the Azure Powershell 1.0.
First off, if you need to move a Web app and it's connected webfarm there are some limitations:
You can move Azure Web App resources using the ARM Move Resources Api.
Azure Web Apps currently supports the following move scenarios:
Moving the entire contents of a resource group (web apps, app service plans, and certificates) to another resource group.
Note: The destination resource group can not contain any Microsoft.Web resources in this scenario
Moving individual web apps to a different resource group, while still hosting them in their current app service plan (the app service
plan stays in the old resource group)
Basically you need to get the resource id from the resources you want to move and use the Move-AzureRmResource command. You'll naturally need an Azure login which is able to read and write to the subscriptions involved.
$webapp = Get-AzureRmResource -ResourceGroupName OldGroup -ResourceName WebApp -ResourceType Microsoft.Web/sites
$plan = Get-AzureRmResource -ResourceGroupName OldGroup -ResourceName Plan -ResourceType Microsoft.Web/serverFarms
Move-AzureRmResource -DestinationResourceGroupName NewGroup -ResourceId ($webapp.ResourceId, $plan.ResourceId) -DestinationSubscriptionId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
I'd point out that if you're moving the resources to another subscription, there are some caveats. First, that subscription must have rights to provision the website in that region, the API's for that are beyond this scope, but simply creating a website and removing it will give the subscription those rights. In my case i had a second error which is still unresolved, but i suspect that other resources that are connected to the resources being moved are the culprits. Will update with further information if i resolve the issue.
As a final note, there is also the possibility to use the REST API.

Is it possible to rename an Azure App Service plan using the Azure Portal?

Is it possible to rename an App Service Plan?
I have already tried in both the old and new portals and can't find any rename options.
No, you can't.
However, if you create a new App Service Plan in the same region and resource group then you can move all your sites to the new App Service Plan and delete the old one.
No but you can change it like this (if it is in the same region and resource group as mentioned by Zain Rizvi):
Create a new App Service Plan and bind it to the correct Subscription and Resource Group. Example:
Then go to your App Service and choose "Change App Service plan"

Resources