MSDeploy fails with authorization error when using filePath provider - iis

I am trying to deploy a web application using MSDeploy. In the first step the app is deployed to test server (using the package created during the build), then to production server (source and destination are iisApp) and the next step is production web.config file deployment to the production server.
Everything works fine but the web.config file deployment reports an error
Error Code: ERROR_USER_NOT_AUTHORIZED_FOR_DEPLOYMENTPROVIDER
More Information: Could not complete an operation with the specified
provider ("filePath") when connecting using the Web Management Service.
This can occur if the server administrator has not authorized the user for
this operation. filePath http://go.microsoft.com/fwlink/?LinkId=178034
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_AUTHORIZED_FOR_DEPLOYMENTPROVIDER.
I am using the same machine for deployment, the same username and the same password. I can see the user has filePath deployment enabled (as well dirPath, contentPath, iisApp and setAcl) in the Management Service Delegation screen in IIS Manager on the machine used for deployment:
It also fails for dirPath and contentPath.
Can anybody help? Thanks
Update - log when MSDeploy executed with -verbose flag
"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy"
-verb:sync -source:filePath="C:\MyProject\DeployConfig\web\web.config"
-dest:filePath="web/web.config",computerName="https://deployement:8172/MSDeploy.axd?site=my-site",userName="publish",password="password",authtype="Basic",includeAcls="False"
-allowUntrusted -verbose
Info: Using ID '7fcedfe4-c103-48f4-ab98-4fae743d5eb7' for connections to the remote server.
Verbose: Pre-authenticating to remote agent URL 'https://deployment:8172/MSDeploy.axd?site=my-site' as 'publish'.
Verbose: Performing synchronization pass #1.
Verbose: Pre-authenticating to remote agent URL 'https://deployment:8172/MSDeploy.axd?site=my-site' as 'publish'.
Verbose: No backup was executed.
Verbose: Received response from agent (HTTP status 'OK').
Info: Adding MSDeploy.filePath (MSDeploy.filePath).
Verbose: The dependency check 'DependencyCheckInUse' found no issues.
Verbose: The current synchronization pass is missing stream content for 1 objects.
Info: Using ID '8f582c09-614e-4344-87c9-64867e44fc4e' for connections to the remote server.
Verbose: Performing synchronization pass #2.
Verbose: Pre-authenticating to remote agent URL 'https://deployment:8172/MSDeploy.axd?site=my-site' as 'publish'.
Info: Adding MSDeploy.filePath (MSDeploy.filePath).
Verbose: Received response from agent (HTTP status 'OK').
Info: Adding child MSDeploy.filePath (C:\MyProject\DeployConfig\web\web.config).

Related

Not able to run windows scheduler from Azure Devops Pipeline. Getting error like The WinRM client cannot process the request

I got the below error:
[error]System.Management.Automation.Remoting.PSRemotingTransportException: Connecting to remote server MYSERVER01 failed with the following error message : The WinRM client cannot process the request.
If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts.
Note that computers in the TrustedHosts list might not be authenticated. You can get more information about that by running the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
##[error]PowerShell script completed with 1 errors.
- task: StopWindowsScheduledTask#2
inputs:
ScheduledTaskFullName: 'TestService_Development'
ComputerNames: 'MYSERVER01'
Username: 'MYSERVER01\admin'
Password: 'xxxxxxx'
AuthenticationOptions: 'Default'
ProtocolOptions: 'HTTP'
I have looked for few solution https://www.hemalekanayake.com/2016/07/solved-winrm-client-cannot-process.html but not worked. https://learn.microsoft.com/en-us/microsoft-365/enterprise/urls-and-ip-address-ranges?view=o365-worldwide this also we used using 80, 443, 5986 port in proxy but not worked. Please help me in resolving this.
steps:
- task: WinRM - IIS Web App Management
displayName: 'Stop $(AppName) Application Pool on $(webserver)'
inputs:
machinesList: '$(webserver)'
AdminUserName: '$(username)'
AdminPassword: '$(password)'
ActionIISWebsite: StopWebsite
StartStopWebsiteName: 'UserAPI'

Deploying a web application to an Azure App Service using MSDeploy

I'm having a lot of trouble deploying my web application to an Azure App Service using MSDeploy. What are the command line arguments I need to use?
MSDeploy is a little finicky with the way it accepts parameters. First, the command will need the username and password for your App Service. This can be found by using the Azure CLI in PowerShell like so:
$publishProfile = az webapp deployment list-publishing-profiles --resource-group <ResourceGroupName> --name <WebAppName> --query "[?publishMethod=='MSDeploy']" | ConvertFrom-Json
This will place the username and password into the $publishProfile variable for use with MSDeploy later.
Next, if the path to the source published web site has spaces in it and PowerShell is being used, it will need to be converted to its equivalent short name syntax. If this is not done, MSDeploy will throw meaningless exceptions like the following that are painful to diagnose.
Error Code: ERROR_PROVIDER_NOT_FOUND
More Information: The provider 'dirPath=' could not be found. Learn more at: https://go.microsoft.com/fwlink/?LinkId=221672#ERROR_PROVIDER_NOT_FOUND.
at Microsoft.Web.Deployment.DeploymentProviderSettingCollection..ctor(String factoryName)
at Microsoft.Web.Deployment.DeploymentProviderOptions..ctor(String factoryName)
at MSDeploy.MSDeploy.GetObjectParameters(Dictionary`2 parameters, Boolean isDestination, DeploymentBaseOptions& retbaseOptions, DeploymentProviderOptions& retproviderOptions)
at MSDeploy.MSDeploy.ExecuteWorker()
at MSDeploy.MSDeploy.Execute()
at MSDeploy.MSDeploy.Main(String[] unusedArgs)
Error count: 1.
To convert the path to its short name equivalent, use the following command:
$shortPath = (New-Object -ComObject Scripting.FileSystemObject).GetFolder(".\Publish").ShortPath
And finally, here's the command to run MSDeploy and deploy the web application to Azure. In order to use the command below, the $webAppName variable will need to be defined.
$webAppName = "MyWebApp"
&"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:dirPath="$shortPath",includeAcls=false -dest:dirpath=D:\home\site\wwwroot,ComputerName="https://$webAppName.scm.azurewebsites.net/msdeploy.axd?site=$($webAppName)",UserName=$($publishProfile.userName),Password=$($publishProfile.userPWD),AuthType='Basic' -verbose -debug
The command should return output similar to the following:
Info: Using ID 'd5e5eb3d-...' for connections to the remote server.
Verbose: Pre-authenticating to remote agent URL 'https://webappname.scm.azurewebsites.net/msdeploy.axd?site=webappname' as '$webappname'.
Verbose: Performing synchronization pass #1.
Verbose: Pre-authenticating to remote agent URL 'https://webappname.scm.azurewebsites.net/msdeploy.axd?site=webappname' as '$webappname'.
Verbose: Received response from agent (HTTP status 'OK').
Info: Adding directory (D:\home\site\wwwroot\cs).
Info: Adding directory (D:\home\site\wwwroot\de).
Info: Adding directory (D:\home\site\wwwroot\es).
Info: Adding directory (D:\home\site\wwwroot\fr).
Info: Deleting file (D:\home\site\wwwroot\hostingstart.html).
Info: Adding directory (D:\home\site\wwwroot\it).
Info: Adding directory (D:\home\site\wwwroot\ja).
Info: Adding directory (D:\home\site\wwwroot\ko).
Info: Adding directory (D:\home\site\wwwroot\pl).
Info: Adding directory (D:\home\site\wwwroot\pt-BR).
Info: Adding directory (D:\home\site\wwwroot\ru).
Info: Adding directory (D:\home\site\wwwroot\runtimes).
Info: Adding directory (D:\home\site\wwwroot\runtimes\unix).
Info: Adding directory (D:\home\site\wwwroot\runtimes\unix\lib).
Info: Adding directory (D:\home\site\wwwroot\runtimes\unix\lib\netcoreapp2.0).
Info: Adding directory (D:\home\site\wwwroot\runtimes\unix\lib\netcoreapp2.1).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win\lib).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win\lib\netcoreapp2.0).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win\lib\netcoreapp2.1).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win\lib\netstandard2.0).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win-arm64).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win-arm64\native).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win-x64).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win-x64\native).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win-x86).
Info: Adding directory (D:\home\site\wwwroot\runtimes\win-x86\native).
Info: Adding directory (D:\home\site\wwwroot\tr).
Info: Adding directory (D:\home\site\wwwroot\zh-Hans).
Info: Adding directory (D:\home\site\wwwroot\zh-Hant).
Verbose: The dependency check 'DependencyCheckInUse' found no issues.
Verbose: The current synchronization pass is missing stream content for 201 objects.
Info: Using ID '1f1ab053-88c6-40a2-90e4-5347157542e6' for connections to the remote server.
Verbose: Performing synchronization pass #2.
Verbose: Pre-authenticating to remote agent URL 'https://webappname.scm.azurewebsites.net/msdeploy.axd?site=webappname' as '$webappname'.
...
Verbose: The HTTP connection (ID='1f1ab053-88c6-40a2-90e4-5347157542e6', type ='GetTraceStatus') is being kept alive while the request is processed.
Verbose: Received response from agent (HTTP status 'OK').
...
Verbose: The dependency check 'DependencyCheckInUse' found no issues.
Verbose: The synchronization completed in 2 pass(es).
Total changes: 231 (230 added, 1 deleted, 0 updated, 0 parameters changed, 44498979 bytes copied)

Azure Deployment Pool Agent Fails to install IIS

Goal
I'm trying to install IIS on remote server using azure devops. I have done this on other vm servers without issue.
Problem
When running this stage the Agent Errors with very little details
Agent Errors when installing IIS
Error
2020-08-11T19:06:19.1822182Z ##[section]Starting: IIS Web App Manage
2020-08-11T19:06:19.1984662Z ==============================================================================
2020-08-11T19:06:19.1985052Z Task : IIS web app manage
2020-08-11T19:06:19.1985379Z Description : Create or update websites, web apps, virtual directories, or application pools
2020-08-11T19:06:19.1985671Z Version : 0.5.15
2020-08-11T19:06:19.1985908Z Author : Microsoft Corporation
2020-08-11T19:06:19.1986227Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/iis-web-app-management-on-machine-group
2020-08-11T19:06:19.1986625Z ==============================================================================
2020-08-11T19:06:21.2180244Z Installing IIS. This may take few minutes.
2020-08-11T19:06:46.1602426Z ##[error]The request to add or remove features on the specified server failed.
Installation of one or more roles, role services, or features failed.
The source files could not be found.
Use the "Source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077. Error: 0x800f081f
2020-08-11T19:06:46.1908491Z ##[section]Finishing: IIS Web App Manage
Stage Settings
steps:
- task: IISWebAppManagementOnMachineGroup#0
displayName: 'Manage IISWebsite'
inputs:
EnableIIS: true
WebsiteName: 'Default Web Site'
AddBinding: true
Bindings: '{"bindings":[{"protocol":"http","ipAddress":"All Unassigned","port":"80","hostname":"","sslThumbprint":"","sniFlag":false}]}'
CreateOrUpdateAppPoolForWebsite: true
AppPoolNameForWebsite: default
I solved this by stop trying to use the prebuilt IIS web app manage tool and ended up just installing iis via power shell command
Install-WindowsFeature -name Web-Server -IncludeManagementTools

Azure Function deployed using FTP, how to fix non-existence docker container issue

I am in development phrase, and I am trying out Azure Function, with the following settings:
Linux
Premium Plan,
NodeJS 12
Deploy using FTP
What I have done:
I have deployed a sample Durable Functions HTTP Starter as specified here: https://learn.microsoft.com/en-us/azure/azure-functions/durable/quickstart-js-vscode#client-function-http-starter
And deployed my code to the xxxxxxxxxxx.ftp.azurewebsites.windows.net under /site/wwwroot
And I received the following Error in LogFiles/2020_06_10_xxxx_docker.log:
2020-06-10T01:05:51.825Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2020-06-10T01:05:51.845Z INFO - Stopping site XXXXXXXXXX because it failed during startup.
2020-06-10T01:09:59.152Z INFO - Pulling image from Docker hub: mcr.microsoft.com/azure-functions/node:3.0-node8-appservice-stage6
2020-06-10T01:10:00.049Z ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"manifest for mcr.microsoft.com/azure-functions/node:3.0-node8-appservice-stage6 not found: manifest unknown: manifest tagged by \"3.0-node8-appservice-stage6\" is not found"}
Upon inspection, this mcr.microsoft.com/azure-functions/node:3.0-node8-appservice-stage6 docker image didn't exists, so it failed.
My question is, how to instruct Azure Function to use a valid docker image instead of a non-existing one? Or if any step above I done wrong so result in this issue? Thanks
Completely removing the Azure Function and creating a new one fix this issue.

Why is Web Deployment Agent Service (MsDepSvc) crashing with a FileNotFoundException?

I'm attempting to deploy a .NET 4 web application to a Windows 2008R2 server using Web Deploy V2. As part of this deployment we copy some batch files to the target machine. When I execute the command below, Web Deployment Agent Service (MsDepSvc) stops and a FileNotFoundException is logged to the system Application event log.
The web deploy command:
"C:\Program Files (x86)\IIS\Microsoft Web Deploy V2\msdeploy.exe" -verb:sync -source:contentPath="C:\work\27f84e3eca3a33d5\Output\BatchFiles" -dest:contentPath="c:_DeployCommands",computerName="192.168.1.14"
Full console output:
C:\Windows\system32>"C:\Program Files (x86)\IIS\Microsoft Web Deploy
V2\msdepl y.exe" -verb:sync
-source:contentPath="C:\work\27f84e3eca3a 3d5\Output\BatchFiles"
-dest:contentPath="c:_DeployCommands",computer ame="192.168.1.14" Info: Using ID '326b55b4-602c-4cdf-ae5c-052e9d44b377' for connections
to the remote server. Warning: Retrying the sync because a socket
error (10054) occurred. Retrying operation 'Serialization' on object
MSDeploy.contentPath (sourcePath). Attempt 1 of 25. Info: Using ID
'a6e468ca-53b9-474b-8568-42dba196bd72' for connections to the remote
server. Error Code: ERROR_COULD_NOT_CONNECT_TO_REMOTESVC More
Information: Could not connect to the destination computer
("192.168.1.14" using the specified process ("Web Deployment Agent
Service") because the serve did not respond. Make sure that the
process ("Web Deployment Agent Service") i started on the destination
computer. Error: The remote server returned an error: (503) Server
Unavailable. Error count: 1.
Event Log Entry:
Application: MsDepSvc.exe Framework Version: v4.0.30319 Description:
The process was terminated due to an unhandled exception. Exception
Info: System.IO.FileNotFoundException Stack: at
Microsoft.Web.Deployment.Tracer.TraceError(Microsoft.Web.Deployment.DeploymentTraceSource,
System.String, System.Object[]) at
MSDepSvc.WDAgent.BeginProcessRequest(System.Net.HttpListenerContext)
at System.Net.LazyAsyncResult.Complete(IntPtr) at
System.Net.ListenerAsyncResult.IOCompleted(System.Net.ListenerAsyncResult,
UInt32, UInt32) at
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32,
UInt32, System.Threading.NativeOverlapped*)
How can I diagnose this?
We ran into a similar issue. You're best bet is to decompile using ILSpy and add extra logging in every catch block and replace the exe on the client to see the exact error. In our scenario, we used on older version 7.1.1631.0 that works. There's a newer version 7.1.1762.0 that's caused the problem. The exe is copied from the client and not the server.
I had the exact same issue. It turned out to be a bug in Web Deploy 3.5 as described here: Could not find file or assembly Microsoft.Web.Deployment.Tracing with Web Deploy V3 using tempagent

Resources