microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.47k stars 2.61k forks source link

Config transform in Release when using AzureRmWebAppDeployment #4776

Closed AmeetAB closed 7 years ago

AmeetAB commented 7 years ago

Hi,

We have a product version specific build that has a release pipeline that goes from QA -> UAT -> PROD all on Azure.

We've somehow got the config transform to execute but will issues. The issue is that it picks up the Web.Release.config even when the environment variable "ReleaseConfiguration" is set to CloudQa, CloudUat & CloudProd in the variables section. Also the task for deployment fails without any logs so I've had to literally wait for it to come to a point when it fails while watching the logs and take a printscreen. That's how we've found out that the transform is happening with Web.Release.config which does not have any transform related entries in it.

How do I force the task to transform using the "ReleaseConfiguration" value?

vincent1173 commented 7 years ago

@AmeetAB , Currently transformation is applied using Release-Environment Name.

You need to change Release Environment Name and not Release Configuration. image

Please change the Environment name to (CloudQa, CloudUat or CloudProd).

Old Editor View: image

AmeetAB commented 7 years ago

That is what I got:

image

vincent1173 commented 7 years ago

@AmeetAB , .Release.config is selected by default when available( in the same folder). Order of Transformation applied is as follows: `.Release.configfollowed by*..config`

image

If Web.Release.config has no significance in your package, can you remove the file or provide the below tag in the same file ?

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
</configuration>
AmeetAB commented 7 years ago

@vincentdass applied

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
</configuration>

to both Web.Debug.config and Web.Release.config and made the CI build configuration to run on "Debug" this resulted in the release picking the environment specific config file for transformation for the web api.

We, however, also have a web job as part of the solution which we'd like deployed. Although I'm getting the webjob deployed as desired, the transformation of App.config isn't happening. Here's the log from the release: image

It seems that the XML Transformation is looking for a Web.config and the transformation file instead of App.config. How do we handle App.config transformation? Here are the tasks in CloudProd environment: image

And this is the config of the web job deploy task:

image

We have a lot of components using webjobs and releases with webjobs are important as part of ALM. Your help is appreciated!

vincent1173 commented 7 years ago

@AmeetAB, To apply transformation in App.config file, your transformation configuration files should be named App.Release.config or App.<EnvironmentName>.config

Can you please ensure that the files are present in same folder as well?

AmeetAB commented 7 years ago

@vincentdass they're in a different project but at the root and in the format App..config etc

In our case, App.CloudDev.config and so on.

vincent1173 commented 7 years ago

@AmeetAB , can you please share the debug logs for the release (by setting variable system.debug = true)?

Need to confirm whether the artifact contains the config and transform file in the same folder.

AmeetAB commented 7 years ago

@vincentdass here's some more information from my research:

I have also found another "gotcha": On the project that contains the transformation files, this <FilesToIncludeForPublish>AllFilesInTheProject</FilesToIncludeForPublish> has to be entered as a sub element of this property group of the csproj file <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> Our CI build runs on debug configuration so that's where I've got that entry, if someone runs CI in release mode then it has to obviously be included in that property group.

Unless the above happens, the config files are not part of the artifact package and transformation at release time cannot find the specific transform file.

With webjob kind projects, in the build, this happens:

2017-07-13T07:22:33.2974267Z _CopyAppConfigFile:
2017-07-13T07:22:33.2974267Z   Copying file from "App.config" to "bin\Debug\Transactions.WebJob.exe.config".

Obviously, at this point the App.config file has been changed into Transactions.WebJob.exe.config in the artifact package. I'm trying to apply the transformation at Release time and it cannot find the App.config or the corresponding App..config file. I can get the files to get copied over by adding but what about the App.config file getting copied into something else?

vincent1173 commented 7 years ago

@AmeetAB , As you mentioned App.config is renamed to ".exe.config". This is done by MSBuild to match the executable application file name [Link].

You need to rename your transform files something like this

App.CloudProd.config => Transactions.WebJob.exe.CloudProd.config
App.CloudQA.config => Transactions.WebJob.exe.CloudQA.config
AmeetAB commented 7 years ago

@vincentdass did what you recommended and although the files are part of the artifact, the transformation task still seems to be looking for Web.config file for transformation.

image

Transform files: image

Actual config file: image

vincent1173 commented 7 years ago

@AmeetAB , please share the debug logs for the same.

AmeetAB commented 7 years ago

@vincentdass what's the best way to send you these logs?

vincent1173 commented 7 years ago

@AmeetAB , you can paste the logs here. You can also send the logs to RM_Customer_Queries@Microsoft.com with subject as "Config transform in Release when using AzureRmWebAppDeployment #4776" for reference.

vincent1173 commented 7 years ago

@AmeetAB , closing the thread as there is no action item on us. (Based on the offline discussion) Feel free to reopen or create a new issue, if required.