2
votes

We have a few standard websites in our azure subscription. We are trying to automate some tasks, one being creating a site in Azure. We are using the 'Microsoft Azure Web Sites Management Library' from Nuget. We are using the below code, but in spite of telling it dedicated, it always gets created as a Free site and not Standard.

domain is a string containing the domain for the site. hostName is a string containing the domain + 'azurewebsites.net', domain has periods stripped for hostName. ws is a WebSpace object that we retrieved from calling previous Azure methods for our subscription.

var newSite = new WebSiteCreateParameters();
newSite.Name = domain;
newSite.HostNames.Add(hostName);
newSite.ComputeMode = WebSiteComputeMode.Dedicated;
newSite.ServerFarm = "DefaultServerFarm";
newSite.WebSpaceName = ws.Name;
newSite.WebSpace = new WebSiteCreateParameters.WebSpaceDetails()
{
      GeoRegion = ws.GeoRegion,
      Name = ws.Name,
      Plan = ws.Plan
};
var r = await AzureClient.WebSites.CreateAsync(
    ws.Name, 
    newSite, 
    new System.Threading.CancellationToken()
);
1
Thanks, will share with the team.Jeff Wilcox
From the sample code, I am making the call correctly, it should be creating a 'Standard' class website?John C
So it sounds like today creating a site will always happen initially in the free tier, so you'll just need to configure it after the fact to be Standard. Not sure about the design on it now but I'd suggest trying the 2-step approach for now.Jeff Wilcox
Will do, thanks for the update!John C
@JeffWilcox Unfortunately this is still happening even with the latest 2.4 Azure SDK.Oliver Weichhold

1 Answers

0
votes

Can you take a look at this sample in github:

https://github.com/btardif/AzureWebsitesAPISamples

To create a site in standard mode you will first need to create the Web Hosting Plan (WHP) and then assign the website to this WHP.

Web Hosting Plans AKA ServerFarm have a SKU property Size and Instance count.