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.
Related
I am trying to move resources from a resource group in one subscription to another in Azure.
Im using Powershell as follows:
Validate
Invoke-AzResourceAction -Action validateMoveResources `
-ResourceId "/subscriptions/{subscription-id}/resourceGroups/{source-rg}" `
-Parameters #{ resources= #("/subscriptions/{subscription-id}/resourceGroups/{source-
rg}/providers/{resource-provider}/{resource-type}/{resource-name}",
"/subscriptions/{subscription-id}/resourceGroups/{source-rg}/providers/{resource-
provider}/{resource-type}/{resource-name}", "/subscriptions/{subscription-
id}/resourceGroups/{source-rg}/providers/{resource-provider}/{resource-type}/{resource-
name}");targetResourceGroup = '/subscriptions/{subscription-
id}/resourceGroups/{destination-rg}' }
Move
$webapp = Get-AzResource -ResourceGroupName OldRG -ResourceName ExampleSite
$plan = Get-AzResource -ResourceGroupName OldRG -ResourceName ExamplePlan
Move-AzResource -DestinationResourceGroupName NewRG -ResourceId $webapp.ResourceId,
$plan.ResourceId
The App service that I have connects to a database so Im assuming that the database needs to be in that same RG for it to be moved ?
Also each resource for example the App Service sits under an App Service Plan, does the App Service Plan get created and moved over into the new Subscripton ?
Are database firewall rules moved across as well ?
If you move the resources across the Subscriptions/ Resource group, you have to move the entire resources which you want to move.
If your move requires setting up new dependent resources, you'll experience an interruption in those services until they've been re-configured.
The App service that I have connects to a database so I'm assuming that the database needs to be in that same RG for it to be moved?
Yes, it should be in the same resource group. or you have to re-configure the database connections according to yours.
Also, each resource for example the App Service sits under an App Service Plan, does the App Service Plan get created and moved over into the new Subscription?
Yes, App Service plan can be move to new subscription. But we have some limitations to move App Service from one Resource Group/Subscription to another.
Moving a resource to a new resource group or subscription is merely a metadata modification that should have no impact on how the resource works. The inbound IP address for an app service, for example, does not change when the app service is moved.
There must be no existing App Service resources in the target resource group. Among the App Service's resources are:
Web Apps
App Service plans Uploaded or imported
TLS/SSL certificates
App Service Environments
All App Service resources in the resource group must be moved together.
References
Move resources to a new resource group / subscription
App Service Limitations
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).
Hi is there a powershell script for moving a web app to an another app service plan who is not in the same resourcegroup. Or can we create a web app where the app service plan is not in the same resource group.
New-AzWebApp -ResourceGroupName $WebAppResourceGroup -Name $testWebAppName -location $location `
-AppServicePlan $appServicePlan01
This script create a new webapp and a new app service plan even there is one exist with the same name. so in case when a want to move the problem resiste the same i cant move it to an existing app service plan.
Set-AzWebApp -Name $WebAppName -ResourceGroupName $WebAppResourceGroup `
-AppServicePlan $appServicePlan02
is there a powershell cmdlet for doing this or do I move the webapp trough the portal.
Thanks
The region in which your app runs is the region of the App Service plan it's in. However, you cannot change an App Service plan's region. If you want to run your app in a different region, one alternative is app cloning. Cloning makes a copy of your app in a new or existing App Service plan in any region.
It can be accomplished by using the Azure Resource Manager version of the PowerShell cmdlet to create a new app with the -SourceWebApp option.
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-app-cloning#cloning-an-existing-app
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.
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