Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: AzureRmWebAppDeployment@4 and XmlTransform - should it work when using stages? #20026

Open
1 of 4 tasks
boltonto opened this issue Jun 18, 2024 · 0 comments
Open
1 of 4 tasks

Comments

@boltonto
Copy link
Contributor

boltonto commented Jun 18, 2024

Task name

AzureRmWebAppDeployment

Task version

4.240.2

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows-2019

Question

We're in the process of switching to full yaml pipelines rather than the old classic pipelines for releases.

All going well so far - but had a real head-scratcher yesterday whereby a web app refused to transform the config file, even though:

  • The Web.Dev.config file was present, alongside the Web.config file in the package.
  • Both were present to use, as the xml variable substitution pass could see it.
  • Solution was built with the appropriate flags to ensure that it wasn't transformed prior.

The error coming back was "Unable to apply transformation for the given package".

I did a bit of delving into the task logic - and it appeared that it was dependent upon an environment variable, Release.EnvironmentName.

Now, in the existing classic pipeline - which was exported to yaml - there's no mention of this anywhere, so I figured classic must be injecting it somewhere - and I could see that in the initialisation step.

I adjusted our new pipeline to dump the environment - and as expected that variable wasn't present. So I ended up setting it in a variable declaration e.g.

 variables:
 solution: '**/*.sln'
 buildPlatform: 'Any CPU'
 buildConfiguration: 'Release'
 RELEASE_ENVIRONMENTNAME: '$(environment.name)'

This fixed the issue - and it transformed the config file as you'd expect.

Here's the yaml for the stages:

  *** SNIP ****
  - stage: Provision_Iac
    displayName: 'Provision Infrastructure'
    dependsOn: BuildAndTest
    condition: |
      succeeded()
    jobs:
      - deployment: ExecuteBicep
        displayName: 'Execute Bicep'
        environment: ${{parameters.environment}}
        strategy:
          runOnce:
            deploy:
              steps:
                - checkout: self
                - task: DownloadPipelineArtifact@2
                  inputs:
                    artifact: 'webapp'
                    targetPath: '$(Pipeline.Workspace)'
                - task: AzureCLI@2
                  ***SNIP****

                - task: AzureRmWebAppDeployment@4
                  displayName: 'xxxx'
                  inputs:
                    azureSubscription: 'xxxx'
                    WebAppName: '$(ExecuteBicepScripts.webAppNameOut)'
                    deployToSlotOrASE: true                    
                    ResourceGroupName: '$(ExecuteBicepScripts.rgNameOut)'
                    packageForLinux: '$(System.DefaultWorkingDirectory)\decompressed\webapp'                    
                    enableXmlTransform: true              
                    enableXmlVariableSubstitution: true

So my question is - am I doing this right, and is this a known issue when running the task through stages as shown above? As we do not see the same behaviour in the classic pipelines? If it is an issue happy to outline the above in an issue separately.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants