/// <summary>
 /// You can retrieve details for a web site by issuing an HTTP GET
 /// request.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/dn167007.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.WebSites.IWebSiteOperations.
 /// </param>
 /// <param name='webSpaceName'>
 /// Required. The name of the web space.
 /// </param>
 /// <param name='webSiteName'>
 /// Required. The name of the web site.
 /// </param>
 /// <param name='parameters'>
 /// Optional. Parameters supplied to the Get Web Site Operation.
 /// </param>
 /// <returns>
 /// The Get Web Site operation response.
 /// </returns>
 public static Task<WebSiteGetResponse> GetAsync(this IWebSiteOperations operations, string webSpaceName, string webSiteName, WebSiteGetParameters parameters)
 {
     return operations.GetAsync(webSpaceName, webSiteName, parameters, CancellationToken.None);
 }
        private static Utilities.Site GetFromCache(IWebSiteManagementClient client,
            string website)
        {
            Utilities.Site site = Cache.GetSite(client.Credentials.SubscriptionId, website);
            if (site != null)
            {
                // Verify site still exists
                try
                {
                    WebSiteGetParameters input = new WebSiteGetParameters();
                    input.PropertiesToInclude.Add("repositoryuri");
                    input.PropertiesToInclude.Add("publishingpassword");
                    input.PropertiesToInclude.Add("publishingusername");

                    return client.WebSites.Get(site.WebSpace, site.Name, input).ToSite();
                }
                catch
                {
                    // Website is removed or webspace changed, remove from cache
                    Cache.RemoveSite(client.Credentials.SubscriptionId, site);
                    throw;
                }
            }
            return null;
        }
 /// <summary>
 /// You can retrieve details for a web site by issuing an HTTP GET
 /// request.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/dn167007.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.WebSites.IWebSiteOperations.
 /// </param>
 /// <param name='webSpaceName'>
 /// Required. The name of the web space.
 /// </param>
 /// <param name='webSiteName'>
 /// Required. The name of the web site.
 /// </param>
 /// <param name='parameters'>
 /// Optional. Parameters supplied to the Get Web Site Operation.
 /// </param>
 /// <returns>
 /// The Get Web Site operation response.
 /// </returns>
 public static WebSiteGetResponse Get(this IWebSiteOperations operations, string webSpaceName, string webSiteName, WebSiteGetParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IWebSiteOperations)s).GetAsync(webSpaceName, webSiteName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// You can retrieve details for a web site by issuing an HTTP GET
 /// request.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/dn167007.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.WebSites.IWebSiteOperations.
 /// </param>
 /// <param name='webSpaceName'>
 /// The name of the web space.
 /// </param>
 /// <param name='webSiteName'>
 /// The name of the web site.
 /// </param>
 /// <param name='parameters'>
 /// Additional parameters.
 /// </param>
 /// <returns>
 /// The Get Web Site Details operation response.
 /// </returns>
 public static WebSiteGetResponse Get(this IWebSiteOperations operations, string webSpaceName, string webSiteName, WebSiteGetParameters parameters)
 {
     try
     {
         return operations.GetAsync(webSpaceName, webSiteName, parameters).Result;
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }