Practical thoughts about software

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:

Switch-AzureMode AzureResourceManager

Add-AzureAccount

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

We can see the values of $r by calling

$r

Then we set only the properties of $r to a new variable $p

$p=$r.Properties

Of Course – we could see the newly set properties with the command

$p

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.