3

I've read through this question, which seems to have a similar issue, however the error message is different. I tried the solutions listed there to no avail.

Here's the rub. I have 2 apps that are both publishing to this VM. An older ASP.NET 4.6 app which publishes just fine... without any problem at all and the new ASP.NET Core app which does have the problem. I am using the same settings in the publish of the new app as the old app, except the Site name which is only different as Default Web Site/OldSite to Default Web Site/NewSite. The publish fails. I can manually dotnet publish then copy the "publish" files manually to the VM and that works fine. Is this a problem with the ASP.NET Core publish template or am I missing something?

Yes, I verified that the user I am trying to connect with is Administrator in both Windows Users and Active Directory Admin group. I've also changed the WMSVC to run under the same admin user. In my publish settings User name I've tried both with domain\username and username. Both show a green check mark when I try to Validate Connection. I am not completely blocked as I can keep manually running dotnet publish and manually copying, but an actual fix fr this would make my life a bit easier. Please help.

The actual error I get is:

Error count: 1.

More Information: Connected to 'myvm.westus.cloudapp.azure.com' using the
Web Deployment Agent Service, but could not authorize. Make sure you are an 
administrator on 'myvm.westus.cloudapp.azure.com'.  Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_ADMIN.

Error Code: ERROR_USER_NOT_ADMIN

Error: The remote server returned an error: (401) Unauthorized.
Community
  • 1
  • 1
Serj Sagan
  • 28,927
  • 17
  • 154
  • 183
  • I know this is an old question and i saw you already have resolved the issue in Github. However, I'm encountering the same issue and followed the solution provided but still getting the same error. If you still remember this, can you provide to me the command that you used? – Naim Jamalludin Sep 04 '20 at 09:15
  • I don't remember but I think `Verifying the Connection` in the publish settings before the publish, might be enough... – Serj Sagan Sep 06 '20 at 04:23

1 Answers1

3

This answer will not solve OP's question but it might provides help for others that face similar error.

In my case I was able to deploy application to the remote server via Visual Studio. However will face Error Code: ERROR_USER_NOT_ADMIN when trying to deploy using dotnet publish.

Below is the command line that I used to deploy the application to the remote server successfully:

dotnet publish HelloWorld.csproj /p:Configuration=Release /p:PublishProfile=IISProfile.pubxml /p:AllowUntrustedCertificate=True /p:UserName=username /p:Password=password

At first I thought that by just pointing to the .pubxml file already sufficient enough and it will automatically use the credentials in these two files .pubxml and .pubxml.user. Oh boy, I was wrong. Took me 2 days to figure out my mistake.

Naim Jamalludin
  • 195
  • 3
  • 16