0

I am encountering the following error when attempting to stop an IIS website using the IIS web app manage task from an Azure DevOps pipeline.

"C:\Windows\system32\inetsrv\appcmd.exe" stop site /site.name:"mywebsite" ERROR ( message:Cannot find SITE object with identifier "mywebsite". ) ##[error]Process 'appcmd.exe' exited with code '1168'.

I previously setup an environment named Prod-Env in Azure DevOps and ran the Power Shell script associated with it on the server. I confirmed the Azure Pipelines Agent service is running on the server, and under the NT AUTHORITY\SYSTEM account. The server is running IIS 10 and Windows Server 2016 Datacenter.

This site does exist, as I logged into the server and was able to execute the command C:\Windows\system32\inetsrv\appcmd.exe" stop site /site.name:"mywebsite" and it was successful (it stopped the site.)

I included the deployment stage section of my azure-pieplines.yml file below. The error is being encountered on the Stop the website task.

- stage: Deploy_Prod
  condition: and(succeeded(), eq(variables.isMain, true))
  jobs:
  - deployment: Deploy
    pool:
      vmImage: 'windows-latest'
    environment: 'Prod-Env'
    strategy:
      runOnce:
        deploy:
          steps:
          - task: IISWebAppManagementOnMachineGroup@0
            displayName: Stop the website
            inputs:
              IISDeploymentType: 'IISWebsite'
              ActionIISWebsite: 'StopWebsite'
              WebsiteName: '$(websiteName)'
              StartStopWebsiteName: '$(websiteName)'

          - task: IISWebAppDeploymentOnMachineGroup@0
            displayName: Update the website site
            inputs:
              WebSiteName: '$(websiteName)'
              Package: 'D:\a\1\drop\MyWebsite.zip'

          - task: IISWebAppManagementOnMachineGroup@0
            displayName: Stop the website
            inputs:
              IISDeploymentType: 'IISWebsite'
              ActionIISWebsite: 'StartWebsite'
              StartStopWebsiteName: '$(websiteName)'

I used the the blog post What’s new with Azure Pipelines as inspiration for how to set this CI/CD pipeline up.

Any suggestions? Am I missing something?

1
  • I would start by making sure that the IIS commands are executed on your server (and not the virtual machine that's defined in pool section). You could use appCmdCommands parameter of IISWebAppManagementOnMachineGroup to execute custom appcmd command, like LIST and get the list of existing webapps. – qbik May 17 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.