I am trying to fix my continuous deployment scenario, and for this to work, the Azure site must exist and be able to exchange between Staging and Production. We want this website to operate at Standard pricing.
script I am currently creating a new ResourceGroup, Hosting Plan, and after they are created, the site itself. The problem that I encountered is that the site is always in Free mode. I should be able to fix this using the Set-AzureResource , but it throws a message telling me that I should specify Location . The problem with this in this particular cmdlet does not have the Location parameter.
Set-AzureResource : { "Error": { "Code": "LocationRequired", "Message": "The location property is required for this definition.", "Target": null, "Details": null } }
This (simplified) script I use to create all resources:
#Create the resource group New-AzureResourceGroup -Location $location -Name $resourceGroupName -Force #Create the hosting plan $hostingPlanParameters = @{"name" = $hostingPlanName; "sku" = "Standard"; "computeMode" = "Standard"; "workerSize" = "0"; "numberOfWorkers" = "1"} New-AzureResource -ApiVersion 2014-04-01 -Name $hostingPlanName -ResourceGroupName $resourceGroupName ` -ResourceType Microsoft.Web/serverFarms -Location $location ` -PropertyObject $hostingPlanParameters -Verbose -Force #Create the website $analyticsSite = @{"sku" = "Standard"; "webHostingPlan" = $hostingplan; "computeMode" = "Standard"; } New-AzureResource -Name $label -ResourceType Microsoft.Web/sites ` -ResourceGroupName $resourceGroupName -Location $location ` -ApiVersion $apiVersion -PropertyObject $analyticsSite -Force Set-AzureResource -Name $label -ResourceType Microsoft.Web/sites ` -ResourceGroupName $resourceGroupName -ApiVersion $apiVersion ` -PropertyObject $analyticsSite -Force
I read that the site should inherit sku specified hosting plan, so I do not need to update it. This does not seem to work for my above script. The hosting plan is specified, but the settings are not inherited.
The created hosting plan properties are as follows:
PropertiesText : { "name": "devHostingPlanWestEU10", "sku": "Standard", "workerSize": 0, "workerSizeId": 0, "numberOfWorkers": 1, "currentWorkerSize": 0, "currentWorkerSizeId": 0, "currentNumberOfWorkers": 1, "status": 0, "webSpace": "ResourceGroupWestEU10-WestEuropewebspace", "subscription": "ad7add9b-8b7a-45df-8e95-0e7fccbr78a5", "adminSiteName": null, "hostingEnvironment": null, "maximumNumberOfWorkers": 0, "planName": null, "perSiteScaling": null, "hostingEnvironmentId": null }
It looks good to me. After creating the website, these properties are printed:
PropertiesText : { "name": "Testert10", "state": "Running", "hostNames": [ "testert10.azurewebsites.net" ], "webSpace": "ResourceGroupWestEU10-WestEuropewebspace", ... "repositorySiteName": "Testert10", "owner": null, "usageState": 0, "enabled": true, ... "computeMode": null, "serverFarm": "Default1", "serverFarmId": null, "lastModifiedTimeUtc": "2015-05-21T11:52:30.773", "storageRecoveryDefaultState": "Running", "contentAvailabilityState": 0, "runtimeAvailabilityState": 0, "siteConfig": null, "deploymentId": "Testert10", "trafficManagerHostNames": null, "sku": "Free", "premiumAppDeployed": null, "scmSiteAlsoStopped": false, "targetSwapSlot": null, "hostingEnvironment": null, "microService": "WebSites", "gatewaySiteName": null, "kind": null, "cloningInfo": null, "hostingEnvironmentId": null }
As you can see, computeMode, serverFarm, hostingEnvironment and sku are not set with the properties that I set in the $analyticsSite object.
Therefore, I probably need to update the resource, but this causes the error mentioned above.
I also tried using New-AzureWebsite using the Troy Hunt blog as an example. However, this post also depends on using Set-AzureResource , so I will get into the same issue. Another problem with this example is that you cannot control in which resource group and hosting plan the site is created, which can cause problems when searching for the site.