Deploy to Azure using publish profile : Works when publishing on VS2017 fails when using Jenkins - visual-studio

I downloaded the Publishing Profile from my App Service and created a profile on my WebApi.
When I execute "publishing" using VS 2017, it works fine.
When I try to execute deploy command on Jenkins if fails. The error message I have is :
Deployment task failed. (Connected to the remote computer ("XXXXXXXX") using the Web Management Service, but could not authorize.
Make sure the site name, user name, and password are correct. If the issue is not resolved, please contact your local or server administrator.
Connected to the remote computer ("xxxxxxxxxxx") using the Web Management Service, but could not authorize.
The remote server returned an error: (401) Unauthorized.
I have a step on Jenkins using PowerShell command line like :
msbuild My.WebApi /P:AllowUntrustedCertificate=true /P:DeployOnBuild=True /p:PublishProfile=$myPublishProfile
It builds without errors
$myPublishProfile is a valid Path
This Jenkins instance runs on a Server, not on my machine.
Jenkins has its own SMC user and server auth user.
App Service has WEBSITE_WEBDEPLOY_USE_SCM set to False
I am using the same Publishing Profile to build on Jenkins and on Visual Studio.
If both are using the same Publishing Profile, why I am getting the Auth error ?
Is there is any other config I should do to perform Deploy from Jenkins ?

When you publish using visualstudio the password is stored in an encrypted file on your disk. If you need to publish with the msbuild-command you can add credentials on the commandline or in the publishprofile
append theese properties on the commandline:
msbuild ... /p:UserName=XXX /p:PassWord=YYY
or include in the profile
<UserName>XXX</UserName>
<Password>YYY</Password>

Related

How to deploy to docker-registry via Visual Studio

I have a webapi project created in Visual Studio 2017. Also I have Dockerfile and docker-compose file for building final image.
It is required to deploy this image to remote linux-host with docker installed. I have url and credentials for connection via ssh.
I tried to create publish profile using Custom Container Registry template, which requires Registry URL and credentials for it. I have putted url and credentials which I have.
After I press Publish image build process starts and image builds successfuly. But stage of deploying ends with error: WARNING! Using --password via the CLI is insecure. Use --password-stdin.Error response from daemon: Get https://zzz.net:443/v2/: dial tcp x.x.x.x:443: connect: connection refused"
Sorry, I am new in Docker and maybe I did something wrong.
I hope there are cosy ways to deploy with Visual Studio tools

Running PowerShell script on VSTS deployment group

I am configuring a deployment group phase inside my release definition at VSTS.
I added a PowerShell script task that is supposed to start a process (.exe console app) on the target machine.
I have tested the PowerShell script manually on the target PC and it is working great:
start-process -filepath c:\myfolder\myprogram.exe
But when the release runs, the script seems not to be working. It executes properly but my process is not initiated.
There is no error message on the release log.
How can I fix that?
The deployment group agent must be running as Interactive mode. Article: Configure the agent
Download agent (Agent queues admin page> Click Download agent)
Run Command Line as administrator
Run .\config.cmd --machinegroup command
Specify Server URL, PAT token, Project Name, Deployment Group Name, Agent name
Press Enter (N) when it asks if you want to run the agent as a service
Call .\run.cmd to start agent
Modify release definition, specify that deployment group for Run on deployment group.
--machinegroup no longer support in the Agent installation,
So go with below,
.\config.cmd --deploymentgroup --deploymentgroupname "{Deployment Group Name}" --agent $env:COMPUTERNAME --runasservice --work "{Working Folder}" --url "{VSTS/Azure DevOps URL}" --projectname "{Project Name}" --auth PAT --token "{Token generated from azure DevOps portal with relevant release permissions}"

Jenkins build project "Unable to access to repository"

I am a complete Jenkins noob so if I have missed something completely obvious I apologise in advance!
I am building an intranet web application using Visual Studio 2010 and commit changes using AnkhSVN to a repository stored on a server that is running Visual SVN Server.
Due to budget restrictions this server is also acting as our web server and also running Jenkins. It is connected to our internal network but doesn't have external internet access so I have had to manually install Jenkins plugins and dependencies.
I am trying to build a Jenkins project that would build the web application when it detects a commit but when I enter the repository URL and the user credentials in the source code management window I get the following error message:
Unable to access to repository
However when I enter the url in a browser and enter the same credentials I can access the repository without any errors.
Any ideas would be greatly appreciated.
Server Specs
Windows Server 2012 R2 Datacenter 64bit
Visual SVN Server
Port: 443
Version 3.5.6
Jenkins
Port: 8080
Credentials Plugin 2.1.9
MapDB API Plugin 1.0.9.0
Pipeline: SCM Step 2.3
Pipeline: Step API 2.5
SCM API Plugin 1.3
SSH Credentials Plugin 1.12
Structs Plugin 1.5
Subversion Plug-in 2.7.1
check if the ip of jenkins server can access the svn ip server....i have the same problem and i found that my ci server can not access the svn server .using ping command
That actually might be okay. For some reason I see similar error message (could be a bug in Jenkins frontend) when edit SCM details for a job in Jenkins, but it does work flawlessly if I actually save and run the job.
Give it a try it might actually work during the build time.

Not able to web deploy to ec2 instance

I am trying to web deploy to a ec2 instance using the msbuild
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
/p:Configuration=Release;MsDeployServiceUrl=ec2-instance
name.compute.amazonaws.com:8172/msdeploy.axd;MSDeployPublishMethod=RemoteAgent;username="adminuser";password="password";DeployIisAppPath=Sitename;CreatePackageOnPublish=true;DeployOnBuild=true;DeployTarget=WebPublish
"my.Web.csproj"
I get a
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web
.Publishing.targets(3847,5): error : Web deployment task failed.(Could not comp
lete the request to remote agent URL ':8172/msdeploy.axd/MSDEPLOYAGENTSERVICE'.) This error indicates that you cannot connect
to the server. Make sure the service URL is correct, firewall and network sett
ings on this computer and on the server computer are configured properly, and t
he appropriate services have been started on the server.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.P
ublishing.targets(3847,5): error : Error details:\r
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.P
ublishing.targets(3847,5): error : Could not complete the request to remote age
nt URL ':8172/msdeploy.a
xd/MSDEPLOYAGENTSERVICE'.
I have
1.Open ports in security group for 8172
2.Reinstalled web deploy 3 in target
3.Made a admin user and using that
Help would be really appreciated.
The URL its using is incorrect. Since you are publishing over the web you are using web management service and hence the url should be in either one of the following formats:
Publishing as an admin:
https://myserver.com:8172/msdeploy.axd
If you are publishing as an owner of one site on the server and have permissions just to your own site then:
https://myserver.com:8172/msdeploy.axd?site=<sitename>

Web Deploy returns 401 unauthorized when publishing via [proj].deploy.cmd

I'm having a bit of a problem with Web Deploy I just can't seem to iron out. Every time I try and publish to WMSvc via the [proj].deploy.cmd command in the package I'm getting "The remote server returned an error: (401) Unauthorized". The command looks like this (project is called "Web", server is named "AutoDeploy"):
Web.deploy.cmd /Y /M:https://AutoDeploy:8172/MsDeploy.axd -allowUntrusted
I can publish fine to https://AutoDeploy:8172/MsDeploy.axd via Visual Studio so the service is definitely running and I can successfully authenticate to it as administrator. Running this locally on the machine against the package while logged on as administrator (it's just a little local Win 2k8 VPC) isn't working and adding /U and /P parameters with the administrator account does nothing.
I've enabled failed request tracing and am getting this output so at least there's something to refer to but unfortunately I can't determine what the root cause is. I'm trying to connect to the same service with the same credentials as in Visual Studio but obviously something is different.
Just out of interest, I can publish fine to the Web Deployment Agent Service (MsDepSvc) as follows:
Web.deploy.cmd /Y /M:http://AutoDeploy/MsDeployAgentService /U:AutoDeploy\Administrator /P:...
But I really want to get WMSvc running! Any thoughts?
Sayed's comment above got me pointed in the right direction. After making the build output verbosity "Detailed" and also setting UseMsdeployExe to true in the .csproj (another tip from Sayed's blog), I found the command generated by Visual Studio was setting the authentication type to basic which retrospectively, is obvious given the plain text username and password.
The MSDN post on How to: Install a Deployment Package Using the deploy.cmd File explains you can just add an "a" flag to the command to set this. So in short, here's how it now looks (and actually works):
Web.deploy.cmd /Y /M:http://AutoDeploy/MsDeployAgentService /U:AutoDeploy\Administrator /P:... /A:Basic

Resources