Windows Azure的多种部署 [英] Windows Azure multiple deployment

查看:191
本文介绍了Windows Azure的多种部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是该方案: - 太多的网站具有相同源$ C ​​$ c和自己的数据库(每个客户都有自己的系统用自己的数据库,但所有的客户使用相同的源$ C ​​$ C)

Here is the scenario: - Too many web sites with the same source code and own database (Each customer has its own system with his own database, but all customers utilizes the same source code)

  • 我只有一个TFS项目,因为所有的客户使用相同的code(不是身体,因为我已经部署到每个客户在每个网站)

这个问题:我如何才能部署到一个网站(从VS 2012 - 网络部署),它会自动更新所有的其他网站,改变正确的web.config文件(目前,每个部署设置都有其配置以更改网页。配置的connectionString)。

The Question: How can I deploy to one website (from VS 2012 - Web Deploy) and it automatically updates all the other websites, changing correctly the web.config (currently, each deployment setting has its configuration to change the web.config connectionString).

要简化,目前,我把所有的部署设置(的customer1 - 网络部署的customer2 - 网络部署....) 它的工作原理,但我必须部署到每个单一客户... 我想要做的是,让一个循环通过点击只有一次)部署到所有的客户。

TO Simplify, currently, I have all the deployment settings (Customer1 - WEb Deploy, Customer2 - Web Deploy....) It works, but I have to deploy to each single customer... What I want to do is, make a loop to deploy to all Customers by clicking just once)..

推荐答案

我们做了非常类似的过程,使用一段50+网站同code基地。我们使用 Azure的REST API管理来完成部署。我建议你​​从web.config中各个ServiceConfiguration..cscfg文件移动站点特定的设置,然后用 CloudConfigurationManager.GetSetting(settingsKey)来获得配置值。创建密钥的简单列表,可能基于域的访问ATT的设置。

We do a very similar process, using the same code base for some 50+ sites. We use the Azure REST Management API to accomplish the deployments. I'd recommend moving the site specific settings from web.config to individual ServiceConfiguration..cscfg files and then using CloudConfigurationManager.GetSetting("settingsKey") to get the config value. Create a simple list of keys, probably domain based to access att your settings.

有一个伟大的code从Azure团队上使用的此处管理API。我们在一个TFS生成过程中适应了这个对我们的code基地,创建一个控制台应用程序,并调用控制台应用程序。以下是有关code,我们用它来获得在预订托管服务的列表,然后更新每个托管服务部署:

There is a great code sample from the Azure team on using the Management API here. We adapted this for our code base to create a console app and call that console app during a TFS build process. Here's the relevant code we use to get a list of hosted services in a subscription and then updated each hosted service deployment:

            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);
                }
            }

这篇关于Windows Azure的多种部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆