Create Azure website with Standard pricing tier via Powershell
This is possible so easily in the new RM cmdlets. Make sure that you have the latest version of Azure PowerShell first.
First create an App service plan that defines the Standard Price tier, then create a web app with the app service plan.
function Create-AppServicePlan(){ #https://msdn.microsoft.com/en-us/library/mt619306.aspx $resource = Find-AzureRmResource -ResourceNameContains $ServicePlanName -ResourceGroupNameContains $ResourceGroupName -ResourceType "Microsoft.Web/ServerFarms" if(!$resource) { # Specify the Tier type that you would like $servicePlan = New-AzureRmAppServicePlan -ResourceGroupName $ResourceGroupName -Name $ServicePlanName -Location $WebAppLocation -Tier Standard -NumberofWorkers 1 -WorkerSize "Small" }}
Next create the web app with the app service plan as a parameter.
function Create-AzureRmWebApp(){ #https://msdn.microsoft.com/en-us/library/mt619250.aspx $resource = Find-AzureRmResource -ResourceNameContains $WebAppName -ResourceGroupNameContains $ResourceGroupName -ResourceType "Microsoft.Web/sites" if(!$resource) { $webApp = New-AzureRmWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName -Location $WebAppLocation -AppServicePlan $ServicePlanName }}
This is the full working script that is verified working.
$ServicePlanName = "PSScriptAppServicePlann"$WebAppName = "WebAppByPSlooksCool"$ResourceGroupName = "MyResourceGroup"$WebAppLocation = "australiaeast"$ErrorActionPreference = "Stop"# Step 1: Create the application service planCreate-AppServicePlan# Step 2: Create the web app using the service plan name.Create-AzureRmWebAppfunction Create-AzureRmWebApp(){ #https://msdn.microsoft.com/en-us/library/mt619250.aspx $resource = Find-AzureRmResource -ResourceNameContains $WebAppName -ResourceGroupNameContains $ResourceGroupName -ResourceType "Microsoft.Web/sites" if(!$resource) { $webApp = New-AzureRmWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName -Location $WebAppLocation -AppServicePlan $ServicePlanName }}function Create-AppServicePlan(){ #https://msdn.microsoft.com/en-us/library/mt619306.aspx $resource = Find-AzureRmResource -ResourceNameContains $ServicePlanName -ResourceGroupNameContains $ResourceGroupName -ResourceType "Microsoft.Web/ServerFarms" if(!$resource) { # Specify the Tier type that you would like $servicePlan = New-AzureRmAppServicePlan -ResourceGroupName $ResourceGroupName -Name $ServicePlanName -Location $WebAppLocation -Tier Standard -NumberofWorkers 1 -WorkerSize "Small" }}
The problem is that you created your site in a default free App Service Plan (aka Server Farm or Web Hosting Plan - they're all the same thing), called "Default1". Yet the App Service Plan you scaled to the Standard size was a different one called "devHostingPlanWestEU10".
To create a site in a pre-existing App Service Plan use the following command:
(split into multiple lines for readability)
New-AzureResource -Name <YourSiteName> -Location "West US" -ResourceGroupName <YourResourceGroupName> -ApiVersion 2014-11-01 -ResourceType "Microsoft.Web/sites" -PropertyObject @{ "serverFarm" = "<Your service plan name>" }
With the New Azure Resource Manager Cmdlet. You can create a new App Service Plan and Pass it to the New-AzureRmWebApp Cmdlet.
New-AzureRmAppServicePlan -Name StdPlan -Location <"Location"> -ResourceGroupName <"ResourceGroupName"> -Tier Standard
New-AzureRmWebApp -ResourceGroupName <"ResourceGroupName"> -Name <"WebAppname"> -Location <"Location"> -AppServicePlan StdPlan
Reference Article: https://docs.microsoft.com/en-us/azure/app-service-web/app-service-web-app-azure-resource-manager-powershell