/// <summary>
 /// You can clone a web site by using a PUT request that includes the
 /// name of the web site and other information in the request body.
 /// (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/dn166986.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'>
 /// Required. Parameters supplied to the clone Web Site operation.
 /// </param>
 /// <returns>
 /// The website operation response.
 /// </returns>
 public static Task<WebSiteAsyncOperationResponse> CloneAsync(this IWebSiteOperations operations, string resourceGroupName, string webSiteName, string slotName, WebSiteCloneParameters parameters)
 {
     return operations.CloneAsync(resourceGroupName, webSiteName, slotName, parameters, CancellationToken.None);
 }
        public void CloneSite()
        {
            RunWebsiteTestScenario(
                (webSiteName, resourceGroupName, whpName, locationName, webSitesClient, resourcesClient) =>
                {
                    string targetSiteName = TestUtilities.GenerateName("csmws");
                    string location = ResourceGroupHelper.GetResourceLocation(resourcesClient, "Microsoft.Web/sites");
                    WebSiteCloneParameters parameters = new WebSiteCloneParameters()
                    {
                        WebSiteClone = new WebSiteCloneBase()
                        {
                            Location = location,
                            Properties = new WebSiteCloneBaseProperties()
                            {
                                CloningInfo = new CloningInfo()
                                {
                                    Source = new SourceWebSite()
                                    {
                                        Location = location,
                                        Name = webSiteName,
                                        ResourceGroupName = resourceGroupName,
                                        SubscriptionId = resourcesClient.Credentials.SubscriptionId
                                    }
                                }
                            }
                        }
                    };

                    var operationResponse = webSitesClient.WebSites.Clone(resourceGroupName, targetSiteName, null,
                        parameters);
                    Assert.NotNull(operationResponse);
                    Assert.NotNull(operationResponse.Location);

                    Guid operationId = ParseOperationIdFromLocation(operationResponse.Location);

                    WaitForOperationCompletion(360, 1000, "WebSites.GetOperation", () =>
                    {
                        operationResponse = webSitesClient.WebSites.GetOperation(resourceGroupName, targetSiteName, null, operationId);
                        return operationResponse.StatusCode;
                    });
                }, SkuOptions.Standard);
        }
 /// <summary>
 /// You can clone a web site by using a PUT request that includes the
 /// name of the web site and other information in the request body.
 /// (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/dn166986.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'>
 /// Required. Parameters supplied to the clone Web Site operation.
 /// </param>
 /// <returns>
 /// The website operation response.
 /// </returns>
 public static WebSiteAsyncOperationResponse Clone(this IWebSiteOperations operations, string resourceGroupName, string webSiteName, string slotName, WebSiteCloneParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IWebSiteOperations)s).CloneAsync(resourceGroupName, webSiteName, slotName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }