Create a Azure webapp in a Resource Group different than the one containing the App Service Plan in Powershell

In Powershell when we would like to create a WebApp, you must specify a Service plan :

 

New-AzureRmWebApp -ResourceGroupName $RG -Name $WEB_Frontend -Location $location_west -AppServicePlan $APP_Service_front

But, if the service plan is in another RG, Azure will create a NEW Service plan in the same RG of the WebApp, this is problematic …

The solution is to specify the service plan ID with :

$APP_Service_front = (Get-AzureRmAppServicePlan -Name $APP_Service_front).Id

And now, the WebApp will be using the new RG and the service plan will stay on the another RG.

Leave a Reply

Your email address will not be published. Required fields are marked *