下面是这样的场景:-拥有相同源代码和数据库的网站太多(每个客户都有自己的系统和自己的数据库,但所有客户都使用相同的源代码)
问题:如何部署到一个网站(从VS 2012 -网络部署),它会自动更新所有其他网站,正确地更改web.config (目前,每个部署设置都有其配置以更改web.config connectionString)。
为了简化,目前我有所有的部署设置(Customer1 - WEb部署,Customer2 - Web .)很有效,但我必须把它部署到每个客户.我想做的是,做一个循环,只点击一次就可以部署到所有客户。
发布于 2013-03-11 04:50:17
我们使用相同的代码库对一些50+站点进行非常类似的处理。我们使用Azure REST管理API来完成部署。我建议将站点特定的设置从web.config移动到单独的ServiceConfiguration..cscfg文件,然后使用CloudConfigurationManager.GetSetting("settingsKey")
获取配置值。创建一个简单的键列表,可能是基于域访问att设置。
在使用这里的管理API时,Azure团队提供了一个很好的代码示例。我们在代码库中对此进行了调整,以创建控制台应用程序,并在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://stackoverflow.com/questions/15324656
复制相似问题