« Back
read.

New Azure Website in App Service Environment using Resource Manager.

The scenario is the following. We want to create a new Azure Website using an App Service Environment. But we dont want to use the same Resource Group as the App Service Environment and its App Service Plan is in.
If you try to use New-AzureWebsite this operation fails, it cannot find the serverFarm (App Service Plan).
What you need to do instead is us the low level command in the powershell resource manager:

  • Switch-AzureMode AzureResourceManager
  • Select-AzureSubscription -SubscriptionName $subscriptionName
  • New-AzureResourceGroup -Name $resourceGroupName -Location $defaultLocation

  • $propertyObject = @{"serverFarmId" = "/subscriptions/xxx/resourceGroups/Group-ASE-TEST/providers/Microsoft.Web/serverfarms/ASE-AppPlan-TEST"; "hostingEnvironmentId" = "/subscriptions/xxx/resourceGroups/Group-ASE-TEST/providers/Microsoft.Web/hostingEnvironments/YYY-ASE-TEST"; "hostingEnvironment" = "YYY-ASE-TEST"}

  • New-AzureResource -Name $websiteName -Location $defaultLocation -ResourceGroupName $resourceGroupName -ResourceType 'Microsoft.Web/sites' -PropertyObject $propertyObject

Dont forget the hosting environment name and id. It doesnt work without them.

comments powered by Disqus