TFS2010 msbuild msdeploy Unauthorized Error - asp.net-mvc

Appreciate any guidance or advice on below issue
I am using TFS2010 and below msbuild parameters in order to deploy build on staging server (continous deployment). I have done all necessery configuration such as
Management Service Delegation
Management Service
Filesystem Permission
IIS Manager Permission
msbuild parameters
/p:validatearchitecture=true /p:AllowUntrustedCertificate=True /p:DeployOnbuild=True
/p:DeployTarget=MsDeployPublish /p:MSDeployPublishMethod=WMSVC
/p:MsDeployServiceUrl=stagingserver
/p:DeployIISAppPath="cddemo" /p:UserName=username /p:Password=password
/p:Outdir="D:\Demo\Demo\\"
Having below error. how to resolve it? and How can I remove https from link and use verbosity parameter to see detailed error.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0
\Web\Microsoft.Web.Publishing.targets (3588): Web deployment task
failed.(Remote agent (URL
https://stagingserver:8172/msdeploy.axd?site=cddemo) could not be
contacted. Make sure the remote agent service is installed and
started on the target computer.) Make sure the site name, user name,
and password are correct. If the issue is not resolved, please contact
your local or server administrator. Error details: Remote agent (URL
https://stagingserver:8172/msdeploy.axd?site=cddemo) could not be
contacted. Make sure the remote agent service is installed and
started on the target computer. An unsupported response was received.
The response header 'MSDeploy.Response' was '' but 'v1' was expected.
The remote server returned an error: (401) Unauthorized.

I can only think of two things to try:
Qualify your user name with the server/domain name: /p:UserName:Server\Username
Try explicitly defining /p:AuthType=Basic or /p:AuthType:NTLM

Related

unable to deploy .net project using TFS IIS app deployment task

I am trying to deploy my project to IIS using TFS Winrm:IIS web app deployment task. I am new to this.
I am getting the following error'
"Deployment failed on machine xxx with following message : System.Management.Automation.Remoting.PSRemotingTransportException: Connecting to remote server xxx failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". "
I was able deploy the project to the same remote server using TFS Winrm: windows machine file copy task which is the prior step for web app deployment to IIS. Winrm service is running and when it type the "winrm quickconfig i am getting "winrm is already been configured".
What am i missing here ? please suggest. Thanks in advance.
The Winrm:IIS task is actually MSDeploy from Machine A to Machine B so for this to work you need to install MSDeploy on Machine B. You should then be ok to deploy from Machine A. Check this article out for more information and to see if you have all the pre-requisite. Also these articles have a bit more info.
https://learn.microsoft.com/en-us/azure/devops/pipelines/apps/cd/deploy-webdeploy-iis-winrm?view=azure-devops
https://marketplace.visualstudio.com/items?itemName=ms-vscs-rm.iiswebapp
The issue was resolved when i enable remote powershell remoting my remote machine using the command Enable-PSRemoting –force

cannot integrate Jenkins with TFS

I am trying to integrate Jenkins (2.32.2) with TFS 2013. I have installed the necessary Tfs plugin (5.3.1). However, when I try to configure the TFS plugin in Jenkins to contact the TFS Team Project Collections by mentioning THE URL of the default collection of TFS (http://10.100.2.69:8080/tfs/DefaultCollection/) and the correct credentials,
I get an error "javax.ServletException: com.microsoft.tfs.core.exceptions.TECoreExceptions: the soap endpoint http://10.100.2.69:8080/tfs/DefaultCollection/Services/v1.0/Regitration.asmx could not be contacted"
Note: I have managed to configure this successfully on my local environment at work, but cannot configure in the clients environment. The credentials are correct. Can it be something with the proxy settings at the clients end ?
Receiving a 403 response is the server telling you, “I’m sorry. I know
who you are–I believe who you say you are–but you just don’t have
permission to access this resource. Maybe if you ask the system
administrator nicely, you’ll get permission. But please don’t bother
me again until your predicament changes.”
More details please see
:403 Forbidden vs 401 Unauthorized HTTP responses
So this error seems not related to your credentials. You need to make sure the system proxy settings were correct - sometimes after upgrading to the latest version of the plugin it may be using the default Java system proxy.
You could check the info here: Jenkins > Plugin Manager > Advanced to match the wildcard domain that your TFS server resided on.

Why is Web Deploy using the wrong account?

I've verified that Web Deploy works (using NTLM authorization) when I fire it from Visual Studio on my local machine. Now I want my build server to auto-deploy (if appropriate) every night. I'm using Jenkins on the build server, and I've granted the account access in IIS on the remote machine. My parameters to MSBuild are as follows:
/p:DeployOnBuild=true
/p:Configuration=Debug
/p:Platform=x86
/p:PublishProfile=DEV
/p:AuthType=NTLM
/p:AllowUntrustedCertificate=True
/p:Username=
The DEV publish profile specifies my DEV server which uses a self-signed certificate thus necessitating an untrusted certificate. The NTLM and blank username should use the current user/account to connect.
However, the Jenkins' job's MSBuild step fails with this error
msdeploy error ERROR_USER_UNAUTHORIZED: Web deployment task failed. (Connected to the remote computer ("DEV-SERVER") using the Web Management Service, but could not authorize. Make sure that you are using the correct user name and password, that the site you are connecting to exists, and that the credentials represent a user who has permissions to access the site. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.)
When I look at the IIS logs on DEV-SERVER, I see the following:
2016-01-06 23:55:10 159.212.19.186 HEAD /msdeploy.axd site=MySite 8172 - 159.212.19.123 - 401 2 5 0
2016-01-06 23:55:10 159.212.19.186 HEAD /msdeploy.axd site=MySite 8172 CO\BUILD-SERVER$ 159.212.19.123 - 401 2 64 78
I was expecting to see CO\jenkins, the account Jenkins is running under, instead of CO\BUILD-SERVER$. (And what's with the $ on the end?) Am I correct in thinking the wrong account is being used? What do I need to do to get this working?
CO\BUILD-SERVER$ is the machine account of your build server.
If you have a slave running on that machine, is it running as a windows service? If so it's probably running as "System"
Also re Selenium tests, if the tests are running on the build server then the service may need to set to run interactively so that the tests can run against a UI.

Deploy to Azure Virtual Directory - Web deployment task failed.(Could not complete the request to remote agent URL

I'm having issues deploying an asp.net mvc 4 project from the buildserver to Azure.
We have one azure web site (strictly with nothing deployed to it directly), with a number of Apps deployed in virtual directories underneath. It is with these apps / virtual directories I'm having problems deploying to.
I can deploy direct to Azure from within VS using publish profiles, and also from a batch file which uses publish profiles locally, but it sounds like you cannot use publish profiles on a build server, so I'm using the same settings to fire MSBuild with parameters instead.
The error being returned is:
error : Web deployment task failed.(Could not complete the request to remote agent URL 'http://[site].scm.azurewebsites.net:443/MSDEPLOYAGENTSERVICE'.)
Note this first error lists the main site, not the virtual directory, though this is the value from the .pubxml file that works through VS.
Other errors listed after the first (above) are..
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(3847,5): error : This error indicates that you cannot connect to the server. Make sure the service URL is correct, firewall and network settings on this computer and on the server computer are configured properly, and the appropriate services have been started on the server.
error : Could not complete the request to remote agent URL 'http://[site].scm.azurewebsites.net:443/MSDEPLOYAGENTSERVICE'.
error : The underlying connection was closed: An unexpected error occurred on a receive.
error : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
..and the batch file including the msbuild commands & paramaters is..
msbuild projectname.csproj
/P:Configuration=DevDeployMyApp
/p:DeployTarget=MSDeployPublish
/p:DeployOnBuild=True
/p:MsDeployServiceUrl=[Site].scm.azurewebsites.net:443
/p:AllowUntrustedCertificate=True
/p:VisualStudioVersion=11.0
/P:CreatePackageOnPublish=True
/p:username=[user]
/p:Password=[password]
/p:DeployIisAppPath=[site]/[VirtualDirectoryName]
/p:MSDeployPublishMethod=RemoteAgent
/p:IgnoreDeployManagedRuntimeVersion=True
Any ideas?
Is your service is already running, try going into the Azure portal and stopping it before publishing. That sometimes helps get it unstuck.

TFS 2012 Team Build and Web Application Deployment - ERROR_USER_NOT_ADMIN

We have a solution consisting of several class libraries, and a Web
Application Project. We are using TFS 2012 with Team Build. The solution
compiles correctly on the build server.
I am currently trying to do this via MSBuild Arguments.
/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish
/p:CreatePackageOnPublish=False /p:MSDeployPublishMethod=RemoteAgent
/p:MsDeployServiceUrl=https://testWebServer:8172/MsDeploy.axd?site=direct /p:AllowUntrustedCertificate=True
/p:DeployIisAppPath="direct"
/p:AuthType=NTLM
The solution builds but does not deploy. I get the following error message:
msdeploy error ERROR_DESTINATION_INVALID: Web deployment task failed.
( Could not connect to the remote computer ("https"). Make sure that
the remote computer name is correct and that you are able to connect
to that computer. Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION_INVALID.)
[C:\Builds\1\ProjectName\Solution General Build\Sources\Temp
Source\ProjectName\Solution\Project.csproj]
Is there another argument I should be passing to specify the server? I did
not intend for https to be the server name... I have tried omitting the
https:// to no avail, error is the same, so it is getting the value from
somewhere.
I have tried this with the following values for MsDeployServiceUrl:
https://testWebServer:8172/MsDeploy.axd?site=direct
https://testWebServer:8172/MsDeploy.axd
"https://testWebServer:8172/MsDeploy.axd?site=direct"
https://192.168.X.X:8172/MsDeploy.axd?site=direct
"https://192.168.X.X:8172/MsDeploy.axd?site=direct"
testWebServer:8172/MsDeploy.axd?site=direct
Update
Alright, the following is at least connecting:
/p:MsDeployServiceUrl=testWebServer
I have seen numerous posts concerning that particular argument, and almost invariably they are a URL, not just a hostname (the ones that appear to be a hostname I thought were just written that way for brevity).
I am now, however, faced with a new problem. I have made the Build Service Account (domain account) local admin on the webserver, and I am getting msdeploy error ERROR_USER_NOT_ADMIN as well as an Audit failure in the Security log.
Resolution
These are the MSBuild arguments I am currently going with.
/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:CreatePackageOnPublish=False /p:MSDeployPublishMethod=WMSvc /p:MsDeployServiceUrl="https://SERVER:8172/MsDeploy.axd" /p:AllowUntrustedCertificate=True /p:DeployIisAppPath="siteName"
I am now getting ERROR_USER_UNAUTHORIZED. Apparently I have either not set up the delegation correctly or the IIS Manager User I have created is somehow incorrect. Regardless that will go in a different post if necessary.
What is the Server and IIS version, you are using?
IIS 6 uses Web Deployment Agent Service (MsDepSvc), whereas IIS 7 usually uses Web Management Service (WMSvc) which have different URLs (besides, you have to be an admin on the target server to execute MsDepSvc.
Can you try specifying
/P:MSDeployPublishMethod=WMSvc
Based on this article from Troy Hunt, Web Management Service (WMSvc) is using
.axd
URLs (the one you specify), whereas you are trying to force it use RemoteAgent publish method which seems to be inconsistent.
See this article for complete set of differencies between WMSvc and RemoteAgent publish methods.
I had a similar issue. To resolve the issue I tried the following steps:
As it was a hosted server we had to make sure that the port 8172 was open (obviously).
Creating a new login and set this up in IIS -> Deploy -> Configure -> Configure Web Deploy Publishing on the target server. I made sure that the password didn't have any spaces in to avoid the quotes issue just to be sure.
Actually running a manual deployment from the build server.
Finally specifying an IP address in the MSDeployServicerl:
/p:MsDeployServiceUrl=xxx.xxx.xxx.xxx:8172/msdeploy.axd
None of the web site names worked for me either. None of my parameters had quotes in. Of course if you leave a space in incorrectly in one of your parameters you will get the error:
MSBUILD : error MSB1008: Only one project can be specified

Resources