IvanAK
IvanAK

Reputation: 213

Azure Release Pipeline IISVirtualDirectory YAML

I'm having this Release created via Azure and its working perfectly. I have create the pipeline using YAML and i want to put the release in the same file. I'm using the "View YAML" approach for this to copy the YAML template and use it. But somehow its failing with this message:

ERROR ( message:Cannot find APP object with identifier "TEST01/". )
##[error]Process 'appcmd.exe' exited with code '1168'.

I guess im missing some other parameters or i really can't figure out how to use the same approach using YAML.

This is the code:

trigger:
- develop

stages:
- stage:
  jobs:
  - job: Build
    displayName: Agent job 1
    pool:
      vmImage: ubuntu-latest
    steps:
    - checkout: self
    - task: ArchiveFiles@2
      displayName: Archive $(System.DefaultWorkingDirectory)
      inputs:
        rootFolderOrFile: "$(System.DefaultWorkingDirectory)"
        includeRootFolder: false
    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact: drop'
  
- stage:
  jobs:
  - job: Deploy
    displayName: Deploy to IIS Dev
    pool:
      vmImage: windows-2019
    steps:
    - task: IISWebAppManagementOnMachineGroup@0
      displayName: 'IIS Web App Manage'
      inputs:
        IISDeploymentType: iISVirtualDirectory
        ParentWebsiteNameForVD: TEST01
        VirtualPathForVD: /admin/test
        PhysicalPathForVD: '%SystemDrive%\inetpub\_phpapps\test-center'

    - task: IISWebAppDeploymentOnMachineGroup@0
      displayName: 'IIS Web App Deploy'
      inputs:
        WebSiteName: "TEST01"
        VirtualApplication: "/admin/test"
        TakeAppOfflineFlag: True
        XmlVariableSubstitution: True

Upvotes: 0

Views: 631

Answers (1)

IvanAK
IvanAK

Reputation: 213

After some research and testing seams like there is a new approach regarding deployment/releases.

Instead of using "Pipelines > Release" and create a release, if you are using the Yaml approach (defining stages etc.) you need to use it with "Environments". Create the group or environment and use it.

Two steps here are missing, one is the package and the other is env, where should be deployed.

So the solution for the above code is the following:

- stage: 'DeployTest'
  displayName: 'DeployTest'
  dependsOn: 'Build'
  condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'develop'))
  jobs:
    - deployment: Test
      displayName: Test
      environment: 
        name: 'ENV-TEST-GROUP'    
        resourceType: VirtualMachine
      strategy:
        runOnce:
          deploy:
            steps:
            - task: IISWebAppManagementOnMachineGroup@0
              displayName: 'IIS Web App Manage'
              inputs:
                IISDeploymentType: iISVirtualDirectory
                ParentWebsiteNameForVD: TEST01
                VirtualPathForVD: /admin/test
                PhysicalPathForVD: '%SystemDrive%\inetpub\_phpapps\test-center'

            - task: IISWebAppDeploymentOnMachineGroup@0
              displayName: 'IIS Web App Deploy'
              inputs:
                WebSiteName: "TEST01"
                VirtualApplication: "/admin/test"
                Package: $(Pipeline.Workspace)\drop\build_test.zip
                TakeAppOfflineFlag: True
                XmlVariableSubstitution: True


Upvotes: 1

Related Questions