Friday, May 24, 2013

MSDEPLOYAGENTSERVICE 401 unauthorized–Resolution


We recently migrated a production environment for a client to new Servers. I had previously been using MSDeploy to deploy the websites/services to the servers so I figured all I had to do was install MSDeploy, point Update my deploy scripts to point to the new servers, and deploy! I was using MSDeploy 2 on the previous servers so I figured it would work on the new ones. Unfortunately it didn’t turn out to be that easy.
When I ran the updated scripts I got the following error:
Fatal: Request to remote agent URL 'http://myserver/MSDEPLOYAGENTSERVICE' failed.
Fatal: The remote server returned an error: (401) Unauthorized. Fatal count: 1
I was using an admin account and I could hit that URL above in a browser so I knew it wasn’t an authorization issue.
Here are the things I tried that DIDN’T work:
  1. Uninstall/Reinstall MSDeploy 2
  2. Install MSDeploy 3
  3. Create the fake user group on the server per these instructions:
  4. Check the file permissions on the Target server
  5. Bang my head against the wall and start crying…
After many hours of searching, I finally came across this brilliant post that solved my issue:http://forums.iis.net/post/1960329.aspx
here are the scripts from the IIS Forum post for easy access:
dism /online /enable-feature /featurename:IIS-WebServerRole 
dism /online /enable-feature /featurename:IIS-WebServerManagementTools
dism /online /enable-feature /featurename:IIS-ManagementService
Reg Add HKLM\Software\Microsoft\WebManagement\Server /V EnableRemoteManagement /T REG_DWORD /D 1
net start wmsvc
sc config wmsvc start= auto


It turns out that the MSDeploy installers don’t tell you that you need to have some of the windows features installed in order to work properly. The installers just move forward and then fail to do the dreaded 401 unauthorized error. I uninstalled MSDeploy, ran the scripts there from the command prompt and installed. IT WORKED!

After that, I did run into 1 more issue regarding file permissions on the redirection.config file, but that was easily fixed via this post: http://weblogs.asp.net/jdanforth/archive/2010/04/29/insufficient-permissions-problems-with-msdeploy-and-tfs-build-2010.aspx

I hope this saves someone as much time as I wasted over the past 2 days.

No comments:

Post a Comment