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.

Community
  • 1
  • 1
gregsonian
  • 1,126
  • 13
  • 15
  • 2
    Having the same issue. Did you ever get it resolved? – bayological Mar 04 '20 at 16:24
  • Same here.. And Microsoft support closed the ticket he opened without resolving it. – Caio Campos May 15 '20 at 06:42
  • 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. – gregsonian May 15 '20 at 17:49
  • @gregsonian - 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. – g0y Jun 27 '22 at 07:47
  • 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. – gregsonian Jun 28 '22 at 15:30

1 Answers1

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.

Jacob Struiksma
  • 149
  • 2
  • 6