Esempio n. 1
0
        private static Site GetFromCache(IWebSiteManagementClient client,
                                         string website)
        {
            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);
        }
Esempio n. 2
0
        public WebSite GetWebsite(string resourceGroupName, string webSiteName, string slotName)
        {
            WebSiteGetParameters webSiteGetParams = new WebSiteGetParameters();
            var getWebsite = WrappedWebsitesClient.WebSites.Get(resourceGroupName, webSiteName, slotName, webSiteGetParams);

            getWebsite.WebSite.Properties.SiteConfig = new WebSiteConfiguration()
            {
                AppSettings       = new Dictionary <string, string>(),
                ConnectionStrings = new List <ConnectionStringInfo>(),
                Metadata          = new Dictionary <string, string>()
            };
            getWebsite.WebSite.Properties.SiteConfig = GetWebSiteConfiguration(resourceGroupName, webSiteName, slotName);
            return(getWebsite.WebSite);
        }
        public void CreateAndDeleteWebsite()
        {
            RunWebsiteTestScenario(
                (webSiteName, resourceGroupName, whpName, locationName, webSitesClient, resourcesClient) =>
            {
                #region Start/Stop website

                AzureOperationResponse stopResponse = webSitesClient.WebSites.Stop(resourceGroupName, webSiteName, null);
                Assert.Equal(HttpStatusCode.OK, stopResponse.StatusCode);

                WebSiteGetParameters parameters = new WebSiteGetParameters()
                {
                    PropertiesToInclude = null
                };

                WebSiteGetResponse getWebSiteResponse = webSitesClient.WebSites.Get(resourceGroupName, webSiteName, null, parameters);
                Assert.NotNull(getWebSiteResponse);
                Assert.NotNull(getWebSiteResponse.WebSite);
                Assert.NotNull(getWebSiteResponse.WebSite.Properties);
                Assert.Equal(getWebSiteResponse.WebSite.Properties.State, WebSiteState.Stopped);

                AzureOperationResponse startResponse = webSitesClient.WebSites.Start(resourceGroupName, webSiteName, null);
                Assert.Equal(HttpStatusCode.OK, startResponse.StatusCode);
                getWebSiteResponse = webSitesClient.WebSites.Get(resourceGroupName, webSiteName, null, null);
                Assert.NotNull(getWebSiteResponse);
                Assert.NotNull(getWebSiteResponse.WebSite);
                Assert.NotNull(getWebSiteResponse.WebSite.Properties);
                Assert.Equal(getWebSiteResponse.WebSite.Properties.State, WebSiteState.Running);

                #endregion Start/Stop website

                webSitesClient.WebSites.Delete(resourceGroupName, webSiteName, null, new WebSiteDeleteParameters
                {
                    DeleteAllSlots = true
                });

                var webSites = webSitesClient.WebSites.List(resourceGroupName, null, null);

                Assert.Equal(0, webSites.WebSites.Count);
            });
        }
        private static Site GetFromCache(IWebSiteManagementClient client,
            string website)
        {
            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;
        }
Esempio n. 5
0
 /// <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 Task <WebSiteGetResponse> GetAsync(this IWebSiteOperations operations, string webSpaceName, string webSiteName, WebSiteGetParameters parameters)
 {
     return(operations.GetAsync(webSpaceName, webSiteName, parameters, CancellationToken.None));
 }
Esempio n. 6
0
 /// <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;
         }
     }
 }
Esempio n. 7
0
 /// <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());
 }