I recently needed to change the Web Hosting Plan of one of my Azure Websites. I keep all my Websites in a single hosting plan so I can manage and scale them more easily. However I accidently created a new website under a new Hosting Plan and because of that the website’s scaling was managed separately from the other sites.
To be able to manage them together I needed to put them in the same hosting plan. Unfortunately Azure websites does not provide this via the management portals at the moment. The only way for now is via Azure PowerShell.
There is actually a tutorial that describes the process of changing the Web Hosting Plan but the last part of it(the one with the hash table) didn’t work so I am posting the commands that worked for me. Substitute all the parameters that are in <angle brackets> with the corresponding values.
First install Azure PowerShell. Then use the following commands to initalize:
Then select the proper subscription(optional – if we have multiple Azure subscriptions)
Select-AzureSubscription '<name of the subscription>'
Then if we want we could look at the resource group of your websites(you can find the resource group name in the new Azure Portal under Browse>Resource Groups):
Get-AzureResourceGroup <name of resource group>
Then we get the information about the website(the one that we need to move) and set it to a variable(in our case $r) $r=Get-AzureResource -Name <name of the website> -ResourceGroupName <resource group of the website> -ResourceType Microsoft.Web/sites -ApiVersion 2014-06-08
$r=Get-AzureResource -Name <name of the website> -ResourceGroupName <resource group of the website> -ResourceType Microsoft.Web/sites -ApiVersion 2014-06-08
We can see the values of $r by calling
Then we set only the properties of $r to a new variable $p
Of Course – we could see the newly set properties with the command
Then we set the properties ‘serverFarm’ and ‘webHostingPlan’ to the corresponding values that we want – the Web Hosting Plan that we need to move to. If you’re not sure what is the name of the plan that you need to move to – we could check it out with the Get-AzureResource cmlet that we wrote above, executed against a website that is inside the desired Web Hosting Plan.
$p.serverFarm="<name of web hosting plan>";$p.webHostingPlan="<name of web hosting plan>";
And finally it’s time to overwrite the values in our website by passing $p as PropertyObject of the command
$r2=Set-AzureResource -Name <name of the website> -ResourceGroupName <resource group of the website> -ResourceType Microsoft.Web/sites -ApiVersion 2014-06-08 -PropertyObject $p
If there are no errors we could check if the state of the website’s configuration is the desired one by calling
And that’s all. Now our website is in the same Web Hosting Plan as the rest of the websites and we could manage it more easily!