I am trying to have the tfs build server deploy a asp.net core site into and application of a .net framework asp.net web api site running iis.
I can get it to work if I create the asp.net core application as its own website sharing the same application folder.
I am calling the powershell script that visual studio generates when using web deploy.
The call it generates is
> "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
> -source:manifest='C:\Users\BuildService\AppData\Local\Temp\PublishTemp\obj\a\SourceManifest.xml'
> -dest:manifest='C:\Users\BuildService\AppData\Local\Temp\PublishTemp\obj\a\DestinationManifest.xml',ComputerName='https://server:8172/msdeploy.axd?site=Demo%20mainSite/dotnetCoreApp',UserName='username',Password='{{PASSWORD-REMOVED-FROM-LOG}}',IncludeAcls='False',AuthType='Basic'
> -verb:sync -enableRule:DoNotDeleteRule -retryAttempts:20 -disablerule:BackupRule -allowUntrusted
The error received is
Error Code: ERROR_USER_UNAUTHORIZEDMore Information: Connected to the
remote computer ("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.Error:
The remote server returned an error: (401) Unauthorized.Error count:
1.
Which is either the site cannot be found or the username / password is wrong. As I mentioned the script when changing it to a site so it shouldn't be that unless I am missing a special permission the site application needs that the site doesn't.
The build definition
The arguments string
-packOutput "$(build.artifactstagingdirectory)" -publishProperties #{'WebPublishMethod'='MSDeploy'; 'MSDeployServiceURL'='$(remoteUrl)'; 'DeployIisAppPath'='$(appName)';'UserName'='$(ausername)';'Password'="$(password)"; 'EnvironmentName'='$(environment)'; 'EnableMSDeployBackup'='$(backup)';'AllowUntrustedCertificate'='true'} -Verbose
Variables
The full log
2017-02-02T15:06:25.0517357Z . 'B:\_work\108\a\server-publish.ps1' -packOutput "B:\_work\108\a" -publishProperties #{'WebPublishMethod'='MSDeploy'; 'MSDeployServiceURL'='https://server'; 'DeployIisAppPath'='Demo mainSite/dotnetCoreApp';'UserName'='username';'Password'="********"; 'EnvironmentName'='staging'; 'EnableMSDeployBackup'='false';'AllowUntrustedCertificate'='true'} -Verbose
2017-02-02T15:06:25.0547361Z Executing the following powershell script. (workingFolder = B:\_work\108\s)
2017-02-02T15:06:25.0547361Z B:\_work\108\a\server-publish.ps1 -packOutput "B:\_work\108\a" -publishProperties #{'WebPublishMethod'='MSDeploy'; 'MSDeployServiceURL'='https://server'; 'DeployIisAppPath'='Demo mainSite/dotnetCoreApp';'UserName'='username';'Password'="********"; 'EnvironmentName'='staging'; 'EnableMSDeployBackup'='false';'AllowUntrustedCertificate'='true'} -Verbose
2017-02-02T15:06:25.6777700Z VERBOSE: Loading module from path 'B:\_work\108\a\publish-module.psm1'.
2017-02-02T15:06:25.7307946Z VERBOSE: Exporting function 'Register-AspnetPublishHandler'.
2017-02-02T15:06:25.7307946Z VERBOSE: Exporting function 'Get-AspnetPublishHandler'.
2017-02-02T15:06:25.7317771Z VERBOSE: Exporting function 'Publish-AspNet'.
2017-02-02T15:06:25.7327889Z VERBOSE: Exporting function 'Publish-AspNetMSDeploy'.
2017-02-02T15:06:25.7327889Z VERBOSE: Exporting function 'Publish-AspNetMSDeployPackage'.
2017-02-02T15:06:25.7337689Z VERBOSE: Exporting function 'Publish-AspNetFileSystem'.
2017-02-02T15:06:25.7337689Z VERBOSE: Exporting function 'Get-PropertiesFromPublishProfile'.
2017-02-02T15:06:25.7348209Z VERBOSE: Exporting function 'Get-MSDeploy'.
2017-02-02T15:06:25.7397836Z VERBOSE: Registering MSDeploy handler
2017-02-02T15:06:25.7607760Z VERBOSE: Adding handler for [MSDeploy]
2017-02-02T15:06:25.7637948Z VERBOSE: Registering MSDeploy package handler
2017-02-02T15:06:25.7647892Z VERBOSE: Adding handler for [Package]
2017-02-02T15:06:25.7657950Z VERBOSE: Registering FileSystem handler
2017-02-02T15:06:25.7667860Z VERBOSE: Adding handler for [FileSystem]
2017-02-02T15:06:25.7677977Z VERBOSE: Importing function 'Get-AspnetPublishHandler'.
2017-02-02T15:06:25.7677977Z VERBOSE: Importing function 'Get-MSDeploy'.
2017-02-02T15:06:25.7687917Z VERBOSE: Importing function 'Get-PropertiesFromPublishProfile'.
2017-02-02T15:06:25.7687917Z VERBOSE: Importing function 'Publish-AspNet'.
2017-02-02T15:06:25.7697881Z VERBOSE: Importing function 'Publish-AspNetFileSystem'.
2017-02-02T15:06:25.7707794Z VERBOSE: Importing function 'Publish-AspNetMSDeploy'.
2017-02-02T15:06:25.7707794Z VERBOSE: Importing function 'Publish-AspNetMSDeployPackage'.
2017-02-02T15:06:25.7717769Z VERBOSE: Importing function 'Register-AspnetPublishHandler'.
2017-02-02T15:06:25.8108318Z Publishing with publish method [MSDeploy]
2017-02-02T15:06:25.8558374Z VERBOSE: Adding default property to publishProperties ["SkipExtraFilesOnServer"="True"]
2017-02-02T15:06:25.8587850Z VERBOSE: Adding default property to publishProperties ["retryAttempts"="20"]
2017-02-02T15:06:25.8607935Z VERBOSE: Adding default property to publishProperties ["DeleteExistingFiles"="False"]
2017-02-02T15:06:25.8618096Z VERBOSE: Adding default property to publishProperties ["MSDeployPackageContentFoldername"="website\"]
2017-02-02T15:06:25.8638077Z VERBOSE: Adding default property to publishProperties ["AuthType"="Basic"]
2017-02-02T15:06:25.8647915Z VERBOSE: Adding default property to publishProperties ["MSDeployUseChecksum"="False"]
2017-02-02T15:06:25.8658376Z VERBOSE: Adding default property to publishProperties ["MSDeployPublishMethod"="WMSVC"]
2017-02-02T15:06:26.1098668Z VERBOSE: Found msdeploy.exe at [C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe]
2017-02-02T15:06:26.1168709Z Executing command ["C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:manifest='C:\Users\BuildService\AppData\Local\Temp\PublishTemp\obj\a\SourceManifest.xml' -dest:manifest='C:\Users\BuildService\AppData\Local\Temp\PublishTemp\obj\a\DestinationManifest.xml',ComputerName='https://server:8172/msdeploy.axd?site=Demo%20mainSite/dotnetCoreApp',UserName='username',Password='{{PASSWORD-REMOVED-FROM-LOG}}',IncludeAcls='False',AuthType='Basic' -verb:sync -enableRule:DoNotDeleteRule -retryAttempts:20 -disablerule:BackupRule -allowUntrusted]
2017-02-02T15:06:26.1218393Z VERBOSE: Found msdeploy.exe at [C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe]
2017-02-02T15:06:27.2510114Z Info: Using ID '7b0f156a-8f7a-4259-84df-93d9008e6f22' for connections to the remote server.
2017-02-02T15:06:27.2900134Z ##[error]Error Code: ERROR_USER_UNAUTHORIZEDMore Information: Connected to the remote computer ("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.Error: The remote server returned an error: (401) Unauthorized.Error count: 1.
2017-02-02T15:06:27.2910140Z ##[error]Process completed with exit code 0 and had 1 error(s) written to the error stream.
As this website mentioned, ERROR_USER_UNAUTHORIZED typically indicates an authentication or authorization problem, and can happen because of any of thee following reasons:
User does not exist
User does not have IIS Manager access to site if connecting using Web
Management Service
Site does not exist
Password is incorrect
If connecting using the Web Management Service, make sure you have checked the resolutions below:
Verify that the username and password are correct
Verify that the site exists
Verify that the user has IIS Manager Permissions to the site's scope
Also try the following steps:
Select the website in IIS Manager
Open up IIS Manager Permissions
Verify that the user you are deploying as has been added. If not, click Allow User and add it.
Related
Azure App Service Deploy finishes successfully, but the files were not updated.
I'm using the pipeline step version 4.*
The WebApp.zip is retrieved successfully from the build and it contains the files, but in a strange subfolder structure: Content\d_C\a\1\s\Platform\Backend\Backend.WebApp (my path starts at 'Platform').
I already tried to use the WebApp release step, but it says it's not compatible with zip files.
This is the log output of the release step:
2019-05-21T13:09:43.6381219Z ##[section]Starting: Azure App Service Deploy: contras
2019-05-21T13:09:43.6498586Z ==============================================================================
2019-05-21T13:09:43.6498697Z Task : Azure App Service Deploy
2019-05-21T13:09:43.6498814Z Description : Update Azure App Services on Windows, Web App on Linux with built-in images or Docker containers, ASP.NET, .NET Core, PHP, Python or Node.js based Web applications, Function Apps on Windows or Linux with Docker Containers, Mobile Apps, API applications, Web Jobs using Web Deploy / Kudu REST APIs
2019-05-21T13:09:43.6498952Z Version : 4.3.24
2019-05-21T13:09:43.6499008Z Author : Microsoft Corporation
2019-05-21T13:09:43.6499078Z Help : [More information](https://aka.ms/azurermwebdeployreadme)
2019-05-21T13:09:43.6499169Z ==============================================================================
2019-05-21T13:09:44.4804024Z Got service connection details for Azure App Service:'contras'
2019-05-21T13:09:44.9625484Z Updating App Service Application settings. Data: {"WEBSITE_RUN_FROM_PACKAGE":"0"}
2019-05-21T13:09:58.0865664Z Updated App Service Application settings and Kudu Application settings.
2019-05-21T13:09:58.4962410Z [command]"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package='D:\a\r1\a\_MoonDesk Test\drop\WebApp.zip' -dest:auto,ComputerName='https://contras-staging.scm.azurewebsites.net:443/msdeploy.axd?site=contras',UserName='$contras__staging',Password='***',AuthType='Basic' -setParam:name='IIS Web Application Name',value='contras' -enableRule:AppOffline -retryAttempts:6 -retryInterval:10000 -enableRule:DoNotDeleteRule -userAgent:VSTS_7c1c6e1c-7491-4898-bc4d-a85345921032_Release__16_26_1
2019-05-21T13:09:59.9100098Z Info: Using ID 'fe8253d8-98f3-4403-9e0d-98ceb9f2a406' for connections to the remote server.
2019-05-21T13:10:11.3653059Z Total changes: 0 (0 added, 0 deleted, 0 updated, 0 parameters changed, 0 bytes copied)
2019-05-21T13:10:11.4450004Z Updating App Service Application settings. Data: {"CloudVersion":"1.4.2"}
2019-05-21T13:10:22.5003712Z Updated App Service Application settings and Kudu Application settings.
2019-05-21T13:10:26.5732176Z Successfully updated App Service configuration details
2019-05-21T13:10:33.4106055Z Successfully updated deployment History at https://contras-staging.scm.azurewebsites.net/api/deployments/161558444226571
2019-05-21T13:10:33.4184229Z App Service Application URL: http://contras-staging.azurewebsites.net
2019-05-21T13:10:33.4378162Z ##[section]Finishing: Azure App Service Deploy: contras
Solved it here...The solution/problem lay in the VS solution, which resulted in an invalid zip content.
https://developercommunity.visualstudio.com/content/problem/587989/azure-devops-release-pipeline-azure-app-service-fi.html
This is a follow-up question to this question. The answer in the original question helped me, but I am stuck somewhere else. As a reminder, I want to deploy my application using a publish profile. My web app in Azure has two subfolders inside wwwroot and one of them is called backend. I want to deploy my application to that folder. I am not sure why msdeploy wants to create anything, since the web app is already there - I just need to get the artifacts inside the backend folder.
Here is the relevant part of the log (with some names changed to xyz):
2018-06-14T09:19:25.0295238Z Start executing msdeploy.exe
2018-06-14T09:19:25.0323018Z "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:package='D:\a\r1\a\artifacts\drop\xyz.zip' -dest:auto,computerName="https://xyz.scm.azurewebsites.net:443/msdeploy.axd?site=xyz/backend",userName="$xyz",password="***",authtype="basic",includeAcls="False" -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"D:\a\r1\a\artifacts\drop\xyz.SetParameters.xml"
-enableRule:DoNotDeleteRule -retryAttempts:6 -retryInterval:10000
2018-06-14T09:19:25.6154385Z Info: Using ID '89f1210b-39ba-4758-b7ee-76a06407a503' for connections to the remote server.
2018-06-14T09:19:28.0800802Z Info: Creating application (Default Web Site)
2018-06-14T09:19:28.2012951Z ##[debug]rc:1
2018-06-14T09:19:28.2013216Z ##[debug]rc:1
2018-06-14T09:19:28.2013360Z ##[debug]success:false
2018-06-14T09:19:28.2013523Z ##[debug]success:false
2018-06-14T09:19:28.2073234Z ##[error]Failed to deploy web package to App Service.
2018-06-14T09:19:28.2081930Z ##[debug]Processed: ##vso[task.issue type=error;]Failed to deploy web package to App Service.
2018-06-14T09:19:28.2082198Z ##[debug]{}
2018-06-14T09:19:28.2082470Z ##[debug]System.DefaultWorkingDirectory=D:\a\r1\a
2018-06-14T09:19:28.2083178Z ##[error]Error Code: ERROR_USER_NOT_AUTHORIZED_FOR_CREATEAPP More Information: Could not
complete an operation with the specified provider ("createApp") when
connecting using the Web Management Service. This can occur if the
server administrator has not authorized the user for this operation.
createApp http://go.microsoft.com/fwlink/?LinkId=178034 Learn more
at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_AUTHORIZED_FOR_CREATEAPP.
Error count: 1.
I managed to resolve the issue. According to this answer by #starian chen-MSFT, I needed to set the correct parameter in SetParameters.xml. I did this by adding the following to my Visual Studio Build task:
/p:DeployIisAppPath="xyz"
where xyz is the value of DeployIisAppPath element in the publish profile.
The reason is that Azure expecting that site name will be presented twice in scm.azurewebsites.net:443/msdeploy.axd?site=%SiteNameHere%" and the same value as a parameter, by default value from file SetParameters.xml is used for second.
So, you need to modify the value of IIS Web Application Name parameter in xxx.SetParameters.xml programming (e.g. PowerShell or other tasks), after that it should works fine.
Azure staging web deploy fails with ERROR_USER_NOT_AUTHORIZED_FOR_CREATEAPP but not for production
I am trying to build a very simple Azure Resource Manager template to provision an App Service Plan, a Web App and immediately deploy package there using MSDeploy. I created a Resource Group project in Visual Studio and added Web App and MSDeploy extension. I basically followed this article: http://blogs.technet.com/b/georgewallace/archive/2015/05/10/deploying-a-website-with-content-through-visual-studio-with-resource-groups.aspx. I haven't customized deployment PowerShell script which comes with the project.
Here is the template: http://pastebin.com/raw/aFsMyg1W
Everything looks like it should work (package is uploaded to blob, web app is created), but deployment fails with message:
Resource Microsoft.Web/sites/extensions 'xg-test-webapp5/MSDeploy' failed with message 'The resource operation completed with terminal provisioning state 'Failed'.
There is an error message accessible via Kudu console (LogFiles/SiteExtensions/MSDeploy/appManagerLog.xml):
AppGallery Deploy Failed: 'Microsoft.WindowsAzure.StorageClient.StorageClientException: The value for one of the HTTP headers is not in the correct format
Full log:
Just for the reference, here is the content of the blob where the package was uploaded. It can be seen that it is accessible at the correct URL.
Any idea what is happening? Thanks
In your ARM template, the packageUri property for the MSDeploy extension resource is the concatenation of parameters: _artifactsLocation, webdeployPackageFolder and _artifactsLocationSasToken.
I tested your actual web deploy package blob Uri below.
https://xgartifacts.blob.core.windows.net/xg-test-rg-stageartifacts/deploy/package.zip
It is a publicly accessible blob, which means it can be downloaded without the SAS token.
Hence, you should not include the SAS Token in the packageUri property of your ARM template.
Hope this helps!
"packageUri": "[concat(parameters('_artifactsLocation'), '/', parameters('webdeployPackageFolder'), '/', parameters('webdeployPackageFileName'), parameters('_artifactsLocationSasToken'))]"
I'm trying automated web site deployment in Azure and I'm at the phase were I run web deploy commands. The command for production works fine and updates the content but the one for staging is failing with the error code in the title.
I'm no sure were the problem is and if it is an authorization one I'm not sure where to set more permissions for the staging account.
This is the production command (which works):
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:package="MyTestingSite.zip" -dest:auto,ComputerName="https://mytestingsite.scm.azurewebsites.net:443/msdeploy.axd?site=MyTestingSite",UserName="$mytestingsite",Password="fromProductionPublishProfile",authtype="Basic" -verb:sync
And this is the one for staging (which fails with ERROR_USER_NOT_AUTHORIZED_FOR_CREATEAPP)
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:package="MyTestingSite.zip" -dest:auto,ComputerName="https://mytestingsite-staging.scm.azurewebsites.net:443/msdeploy.axd?site=MyTestingSite__staging",UserName="$MyTestingSite__staging",Password="fromStagingPublishProfile",authtype="Basic" -verb:sync -verbose
Help is greatly appreciated!
Thank you!
Azure expecting that site name will be presented twice - in scm.azurewebsites.net:443/msdeploy.axd?site=%SiteNameHere%" and the same value as a parameter, by default value from file SetParameters.xml is used for second.
You may modify this file or pass parameter to msdeploy directly:
-setParam:name="IIS Web Application Name",value="%SiteNameHere%"
I managed to find where the problem was ...
In a settings file created by msdeploy.exe I was using the wrong site name.
Sadly the documentation was popping up an error that had nothing to do with the wrong site name but only saying that it can't create that site because of the rights. Which somehow, in a twisted Microsoft like way, makes sense.
I have configured an IIS application pool (win server 2012 r2) to use an active directory managed service account without any issues, but I cannot publish this application from Visual Studio using Web Publish. I use my own credentials to publish to the website, and the folder structure gets created properly, but then I see this error:
Web deployment task failed. ((2014-10-07 12:45:44 PM) An error occurred when the request was processed on the remote computer.)
(2014-10-07 12:45:44 PM) An error occurred when the request was processed on the remote computer.
The account 'mydomain\iismsa$' does not appear to be valid. The account was obtained from this location: 'system.applicationHost/applicationPools/MyWebApp'.
Some or all identity references could not be translated.
at System.Security.Principal.NTAccount.Translate(IdentityReferenceCollection sourceAccounts, Type targetType, Boolean forceSuccess)
at System.Security.Principal.NTAccount.Translate(Type targetType)
at Microsoft.Web.Deployment.Impersonator.GetNTAccount(String userName, String source)
I have already granted full permissions to the service account on the target folder on the server.
Has anyone successfully used a managed service account to run IIS app pool AND been able to publish remotely?