6

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.

Kapol
  • 6,383
  • 3
  • 21
  • 46
  • Have you specified the virtual application in the App Service's Application Settings? – juunas Jun 14 '18 at 09:48
  • Sounds like it thinks the app doesn't exist in IIS and it wants to create one but the deployment user account can't do that. – juunas Jun 14 '18 at 09:48
  • @juunas I have a virtual application specified: **/backend** maps to **site\wwwroot\backend**. Maybe I should change it to a virtual directory instead of an application? – Kapol Jun 14 '18 at 10:08
  • It's been a long time since I tried virtual directories so I can't say directly what the problem is. Have you looked at this article: https://blogs.msdn.microsoft.com/tomholl/2014/09/21/deploying-multiple-virtual-directories-to-a-single-azure-website/? – juunas Jun 14 '18 at 10:10
  • I think I have it set up correctly. When I publish manually from VS 2017 using the same publish profile, the publish is successful and my app runs inside the **backend** folder. – Kapol Jun 14 '18 at 11:03
  • If VS does it correctly, check the command it is using from the build logs :) – juunas Jun 14 '18 at 12:17
  • For task issue, you can submit a issue here: https://github.com/Microsoft/vsts-tasks/issues – starian chen-MSFT Jun 15 '18 at 06:57

2 Answers2

12

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.

Kapol
  • 6,383
  • 3
  • 21
  • 46
  • Somehow this did not work for me: changes to this build parameter or the passed xml to the deployment task causes no change to that site parameter shown in the deployment log. Any idea? I did also use the clean option in the build. – spikey Apr 21 '19 at 18:45
  • `xyz` usually matches Web App name as well. When I had to deploy to virtual directory under Web App, I had to change it to `xyz\v2`, for example. – Yehor Androsov Jan 27 '21 at 14:20
4

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

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • Thanks so much! I was investigating the problem for 4 days on row in Azure Pipelines! At last, I used a Powershell script task for replace the value in SetParameters.xml – batressc Sep 23 '20 at 00:02