2017-02-14 22 views
0

我對Microsoft.Web.Deployment軟件包有問題。有人在這裏可以告訴我,在更新新版本之前,我必須寫入/配置同步過程,目標是否會關閉?Microsoft.Web.Deployment:如何在同步新版本之前使目標脫機?

這裏是我的代碼片段:

var publishSettings = GetPublishSettings(subscriptionId, resourcegroupName, websiteName); 
var sourceBaseOptions = new DeploymentBaseOptions(); 

var targetBaseOptions = new DeploymentBaseOptions 
{ 
    ComputerName = publishSettings.ComputerName, 
    UserName = publishSettings.Username, 
    Password = publishSettings.Password, 
    AuthenticationType = "basic", 
    TraceLevel = Verbose 
}; 
targetBaseOptions.Trace += TargetBaseOptions_Trace; 
var syncOptions = new DeploymentSyncOptions 
{ 
    DoNotDelete = false, 
    WhatIf = false, 
    UseChecksum = true 
}; 

using (var deploymentObject = DeploymentManager.CreateObject(DeploymentWellKnownProvider.ContentPath, Path.GetFullPath(websitePath), sourceBaseOptions)) 
{ 
     var summary = deploymentObject.SyncTo(DeploymentWellKnownProvider.ContentPath, publishSettings.SiteName, targetBaseOptions, syncOptions); 
     if (summary.Errors > 0) throw new Exception("Website Deployment failed"); 
     if (summary.Errors == 0) 
     { 
      Console.WriteLine($"{publishSettings.SiteName}: erfolgreich"); 
     } 
} 

我能想象它是什麼東西在DeploymentSyncOptions

感謝你們

回答

1

Microsoft.Web.Deployment,我無法找到它提供的方法或選項管理(停止,重啓等)Azure網站。如果您希望在部署之前停止Azure網站,則可以嘗試使用爲Microsoft Azure提供網站管理功能的Microsoft.Azure.Management.WebSites

WebSiteManagementClient websiteManagementClient = new WebSiteManagementClient(cred); 

websiteManagementClient.SubscriptionId = "your subscription id here"; 
websiteManagementClient.Sites.StopSite(AzureResourceGroup, siteName); 

您可以使用websiteManagementClient.Sites.GetSite(AzureResourceGroup, siteName).State來檢查網站狀態。

enter image description here

相關問題