持续部署和交付

我们有一个包含+10个项目的解决方案,其中2个是网站。 现在我需要设置链接到我们的TFS服务器的构建定义,构建解决方案并将2个站点部署到正确的Azure网站。 我尝试过几种不同的方法,但每次交付似乎都失败了。 在TFS服务器上构建项目是没有问题的,但是当azure需要提供正确的asp项目时,它正确的Azure网站失败了…任何人都可以指出我如何创建这样的构建定义的正确方向,以及指定交付选项的位置?

编辑:

用我们构建的图像来说明。

docl builddefinition

所以我们在这个文件夹中有2个网站: 在此处输入图像描述

我想将此文件夹中的这两个网站发布到正确的azure色位置。 有没有人知道一个很好的方法来实现2个网站的成功持续交付?

我们在TFS构建期间使用Azure Service Managetment API。 我们将此示例代码( Windows Azure ServiceManagement Sample )作为命令行工具进行了调整,以便在构建任务中运行。

HostedServiceList hostedServices = new HostedServiceList(); Dictionary servicesOperations = new Dictionary(); ParseArguments(args); ProcessCheckServerCertificate(); // upload the package created during the build to Azure BLOB var packageUrl = UploadFileToBlob(package); var services = new ListHostedServicesCommand(); services.Run(); hostedServices = services.HostedServices; . . . 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); } 

这是UploadFileToBlob代码……

 private string UploadFileToBlob(string file) { // Retrieve storage account from connection string CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString")); // Create the blob client CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve reference to a previously created container CloudBlobContainer container = blobClient.GetContainerReference("mydeployments"); // Retrieve reference to a blob var date = DateTime.UtcNow.ToString("yyyyMMdd-hhmmss-"); var fileinfo = new FileInfo(file); if (fileinfo.Exists) { var fileToUpload = new FileInfo(file).Name; var filename = date + fileToUpload; try { CloudBlob blob = container.GetBlobReference(filename); // Create or overwrite the blob with contents from a local file using (var fileStream = System.IO.File.OpenRead(file)) { blob.UploadFromStream(fileStream); } return blob.Uri.AbsoluteUri; } catch (Exception ex) { LogError("Error uploading file to blog: ", ex.Message); return ""; } } LogError("Error - specified file does not exist: ", file); return ""; } 

并在.proj文件中为云服务添加构建任务,指向“YourCommandLineTool.exe”: