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);
                });
        }
 /// <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.Azure.Management.WebSites.IWebSiteOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='webSiteName'>
 /// Required. The name of the web site.
 /// </param>
 /// <param name='slotName'>
 /// Optional. The name of the slot.
 /// </param>
 /// <param name='parameters'>
 /// Optional. Additional parameters.
 /// </param>
 /// <returns>
 /// The Get Web Site Details operation response.
 /// </returns>
 public static Task<WebSiteGetResponse> GetAsync(this IWebSiteOperations operations, string resourceGroupName, string webSiteName, string slotName, WebSiteGetParameters parameters)
 {
     return operations.GetAsync(resourceGroupName, webSiteName, slotName, parameters, CancellationToken.None);
 }
Пример #3
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;
 }
 /// <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.Azure.Management.WebSites.IWebSiteOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group.
 /// </param>
 /// <param name='webSiteName'>
 /// Required. The name of the web site.
 /// </param>
 /// <param name='slotName'>
 /// Optional. The name of the slot.
 /// </param>
 /// <param name='parameters'>
 /// Optional. Additional parameters.
 /// </param>
 /// <returns>
 /// The Get Web Site Details operation response.
 /// </returns>
 public static WebSiteGetResponse Get(this IWebSiteOperations operations, string resourceGroupName, string webSiteName, string slotName, WebSiteGetParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IWebSiteOperations)s).GetAsync(resourceGroupName, webSiteName, slotName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }