Release Agent Configuration necessary for Web App Add task
Asked Answered
S

1

7

To create a directory under and add a web app to IIS, I put this script in Azure DevOps Server Deployment Group job Powershell task:

New-Item -Path "C:\inetpub\wwwroot" -Name "MyNewApp" -ItemType "directory" `
C:\Windows\system32\inetsrv\appcmd.exe add app `
/site.name:"Default Web Site" `
/path:"/MyNewApp" `
/physicalPath:"C:\inetpub\wwwroot\MyNewApp"`

When this task runs it throws an error: (timestamps removed for clarity)

APP object "Default Web Site/MyNewApp" changed

ERROR ( hresult:80090016, message:Failed to commit configuration changes.

Keyset does not exist )

After executing the above code from a Powershell console while logged in as either myself or the service account, the following messages are returned:

APP object "Default Web Site/MyNewApp" added

VDIR object "Default Web Site/MyNewApp" added

I can confirm in IIS Manager that the directory and application was created.

I cannot reproduce the error in a console. It is only when it is running as the Release Agent and initiated through the DevOps Server web interface that this error occurs.

I have tried the following:

Update 1:

I determined the "Keyset does not exist" error was coming from trying to use the DefaultAppPool application pool as part of the setup. This application pool was not setup with the service account but was still set with default Application Pool Identity.

However, after making this change I have a new error:

APP object "Default Web Site/MyNewApp" changed

ERROR ( hresult:80070057, message:Failed to commit configuration changes.

The parameter is incorrect. )

...

Process 'appcmd.exe' exited with code '87'.

Any guidance is greatly appreciated.

Update 2:

I logged an issue with Microsoft community that is currently being looked at. You can see it here.

Speedometer answered 5/4, 2019 at 20:8 Comment(5)
Having the same issue. Did you ever get it resolved?Wenger
Same here.. And Microsoft support closed the ticket he opened without resolving it.Emendate
Microsoft reps asked me for information which I provided. There were no updates after that. I'll look at what I setup and share it here but it won't be within the next week or two.Speedometer
@Speedometer - I have the same issue with regards to this and can't find a solution. All solution from other articles didn't help me. Do you solve your issue? Thanks in advance.Democracy
No, I was never able to resolve this issue. Our Server team got busy with other work and so we hijacked the Build Definition pipeline to deploy to a share directory with another task checking for changed files and copying them. Prehistoric but work for now.Speedometer
D
0

You could also look at the .net implementation with the servermanager:

https://learn.microsoft.com/en-us/iis/manage/scripting/how-to-use-microsoftwebadministration

https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.administration.servermanager?view=iis-dotnet

Should not be very hard to use this in powershell.

Dyspeptic answered 1/10, 2020 at 19:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.