我们做了一个非常类似的过程,对于大约50多个网站使用相同的代码库。我们使用Azure REST Management API来完成部署。我建议将网站特定的设置从web.config移动到单独的ServiceConfiguration..cscfg文件,然后使用CloudConfigurationManager.GetSetting("settingsKey")
获取配置值。创建一个简单的密钥列表,可能是基于域的访问您的设置。
Azure团队使用Management API here有一个很好的代码示例。我们对此进行了调整,以便在我们的代码库中创建控制台应用程序并在TFS构建过程中调用该控制台应用程序下面是我们用得到的托管服务列表中订阅,然后更新每个托管服务部署的相关代码:
var packageUrl = UploadFileToBlob(package);
var services = new ListHostedServicesCommand();
services.Run();
hostedServices = services.HostedServices;
var date = DateTime.UtcNow.ToString("yyyyMMdd-hhmmss-");
var label = date + "some-deployment-name";
var fileinfo = new FileInfo(config);
if (!string.IsNullOrEmpty(packageUrl) && fileinfo.Exists)
{
// get the url of the package uploaded to blob
AzureCommand.PackageLocation = packageUrl;
AzureCommand.ConfigFileLocation = fileinfo.FullName;
AzureCommand.DeploymentSlot = "production";
AzureCommand.Mode = "auto";
AzureCommand.Label = label;
foreach (var hostedService in hostedServices)
{
Console.WriteLine("updating: " + hostedService.ServiceName);
// get the deployment unique name - required for upgrade
AzureCommand.HostedServiceName = hostedService.ServiceName;
AzureCommand.DeploymentName = null;
var getDeployment = new GetDeploymentCommand();
getDeployment.Run();
AzureCommand.DeploymentName = getDeployment.Deployment.Name;
// upgrade the existing deployment
var upgradeDeployment = new UpgradeDeploymentCommand();
upgradeDeployment.Run();
servicesOperations.Add(upgradeDeployment.TrackingId, upgradeDeployment.ServiceManagement);
}
// check status of all operations submitted
foreach (var servicesOperation in servicesOperations)
{
// check status of operations
AzureCommand.WaitForAsyncOperation(servicesOperation.Value, servicesOperation.Key);
}
}
我们使用[八达通](https://octopusdeploy.com/)项目等任务。 – VMAtm 2014-08-11 08:37:30
另请参阅此[问题](http://programmers.stackexchange.com/questions/122729/alternatives-to-octopus-for-deploying-net-applications#) – VMAtm 2014-08-11 08:43:36