예제 #1
0
 /// <summary>
 /// Get the sites in the given webspace
 /// </summary>
 /// <param name="spaceName">Name of webspace</param>
 /// <returns>The sites</returns>
 public IList<Utilities.Site> ListSitesInWebSpace(string spaceName)
 {
     WebSiteListParameters input = new WebSiteListParameters();
     input.PropertiesToInclude.Add("repositoryuri");
     input.PropertiesToInclude.Add("publishingpassword");
     input.PropertiesToInclude.Add("publishingusername");
     return WebsiteManagementClient.WebSpaces.ListWebSites(spaceName, input).WebSites.Select(s => s.ToSite()).ToList();
 }
 /// <summary>
 /// You can retrieve a list of all web sites in a web space by issuing
 /// an HTTP GET request.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/dn236429.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.WebSites.IWebSpaceOperations.
 /// </param>
 /// <param name='webSpaceName'>
 /// Required. The name of the web space.
 /// </param>
 /// <param name='parameters'>
 /// Optional. Additional parameters.
 /// </param>
 /// <returns>
 /// The List Web Sites operation response.
 /// </returns>
 public static Task<WebSpacesListWebSitesResponse> ListWebSitesAsync(this IWebSpaceOperations operations, string webSpaceName, WebSiteListParameters parameters)
 {
     return operations.ListWebSitesAsync(webSpaceName, parameters, CancellationToken.None);
 }
        private static Utilities.Site GetFromAzure(IWebSiteManagementClient client,
            string website)
        {
            // Get all available webspace using REST API
            var spaces = client.WebSpaces.List();
            foreach (var space in spaces.WebSpaces)
            {
                WebSiteListParameters input = new WebSiteListParameters();
                input.PropertiesToInclude.Add("repositoryuri");
                input.PropertiesToInclude.Add("publishingpassword");
                input.PropertiesToInclude.Add("publishingusername");
                var sites = client.WebSpaces.ListWebSites(space.Name, input);
                var site = sites.WebSites.FirstOrDefault(
                    ws => ws.Name.Equals(website, StringComparison.InvariantCultureIgnoreCase));
                if (site != null)
                {
                    return site.ToSite();
                }
            }

            // The website does not exist.
            return null;
        }
 /// <summary>
 /// You can retrieve a list of all web sites in a web space by issuing
 /// an HTTP GET request.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/dn236429.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.WebSites.IWebSpaceOperations.
 /// </param>
 /// <param name='webSpaceName'>
 /// Required. The name of the web space.
 /// </param>
 /// <param name='parameters'>
 /// Optional. Additional parameters.
 /// </param>
 /// <returns>
 /// The List Web Sites operation response.
 /// </returns>
 public static WebSpacesListWebSitesResponse ListWebSites(this IWebSpaceOperations operations, string webSpaceName, WebSiteListParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IWebSpaceOperations)s).ListWebSitesAsync(webSpaceName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// You can retrieve a list of all web sites in a web space by issuing
 /// an HTTP GET request.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/dn236429.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.WebSites.IWebSpaceOperations.
 /// </param>
 /// <param name='webSpaceName'>
 /// The name of the web space.
 /// </param>
 /// <param name='parameters'>
 /// Additional parameters.
 /// </param>
 /// <returns>
 /// The List Web Sites operation response.
 /// </returns>
 public static WebSpacesListWebSitesResponse ListWebSites(this IWebSpaceOperations operations, string webSpaceName, WebSiteListParameters parameters)
 {
     try
     {
         return operations.ListWebSitesAsync(webSpaceName, parameters).Result;
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }