private void CreateTestServerFarmIfNeeded()
        {
            WebHostingPlanCreateParameters parameter = new WebHostingPlanCreateParameters();

            parameter.Name            = WebsiteServerFarmName;
            parameter.NumberOfWorkers = 2;
            parameter.WorkerSize      = WorkerSizeOptions.Medium;

            try
            {
                WebsiteManagementClient.WebHostingPlans.Create(WebSpaceName, parameter);
            }
            catch (CloudException ce)
            {
                if (ce.Response.StatusCode == System.Net.HttpStatusCode.Conflict)
                {
                    Console.WriteLine("A server farm already exists. Continuing.");
                }
                else
                {
                    throw;
                }
            }
        }
 /// <summary>
 /// Creates a new Web Hosting Plan.  (see
 /// http://azure.microsoft.com/en-us/documentation/articles/azure-web-sites-web-hosting-plans-in-depth-overview/
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.WebSites.IWebHostingPlanOperations.
 /// </param>
 /// <param name='webSpaceName'>
 /// Required. The name of the web space.
 /// </param>
 /// <param name='parameters'>
 /// Required. Web Hosting Plan Parameters.
 /// </param>
 /// <returns>
 /// The Create Web Web Hosting Plan operation response.
 /// </returns>
 public static Task <WebHostingPlanCreateResponse> CreateAsync(this IWebHostingPlanOperations operations, string webSpaceName, WebHostingPlanCreateParameters parameters)
 {
     return(operations.CreateAsync(webSpaceName, parameters, CancellationToken.None));
 }
 /// <summary>
 /// Creates a new Web Hosting Plan.  (see
 /// http://azure.microsoft.com/en-us/documentation/articles/azure-web-sites-web-hosting-plans-in-depth-overview/
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.WebSites.IWebHostingPlanOperations.
 /// </param>
 /// <param name='webSpaceName'>
 /// Required. The name of the web space.
 /// </param>
 /// <param name='parameters'>
 /// Required. Web Hosting Plan Parameters.
 /// </param>
 /// <returns>
 /// The Create Web Web Hosting Plan operation response.
 /// </returns>
 public static WebHostingPlanCreateResponse Create(this IWebHostingPlanOperations operations, string webSpaceName, WebHostingPlanCreateParameters parameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IWebHostingPlanOperations)s).CreateAsync(webSpaceName, parameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }