5

We're in the process of migration our product to the cloud. I'm currently testing the deployment of our web application to azure web apps. Our application consists of 2 parts. An ASP.Net Webforms application, and a ASP.Net Web API project. These projects are 2 separate applications, and need to run in azure as 2 separate applications. I've configured the web app as follows:

enter image description here

As you can see, the api is a sub application of the root. Now I have 2 deployment tasks (AzureRmWebAppDeployment@4), that deploy the website and API. The task to deploy the website runs without any issues. However, the task to deploy the api throws an error:

Got service connection details for Azure App Service:'***'
##[error]Error: Failed to create path 'site/wwwroot/api' from Kudu. Error: Conflict (CODE: 409)
Successfully added release annotation to the Application Insight : ***
Successfully updated deployment History at https://***.scm.azurewebsites.net/api/deployments/***
App Service Application URL: http://***.azurewebsites.net/api
Finishing: Publish API to Azure

Apparently it cannot create the "api" folder in wwwroot.

The diagnostic logging shows that it determines the "api" folder doesn't exist, and a conflict error occurs when trying to create it:

##[debug]Virtual Application Map: Physical path: 'site\wwwroot\api'. Virtual path: '/api'.
##[debug][GET]https://$***:***@***.scm.azurewebsites.net/api/vfs/site/wwwroot/api/
##[debug]loaded affinity cookie ["ARRAffinity=***;Path=/;HttpOnly;Domain=***.scm.azurewebsites.net"]
##[debug]listFiles. Data: {"statusCode":404,"statusMessage":"Not Found","headers":{"cache-control":"no-cache","pragma":"no-cache","content-length":"57","content-type":"application/json; charset=utf-8","expires":"-1","server":"Microsoft-IIS/10.0","x-ms-request-id":"f395b98d-89ca-450e-b4f4-9df4d81f3ef0","x-aspnet-version":"4.0.30319","x-powered-by":"ASP.NET","set-cookie":["ARRAffinity=***;Path=/;HttpOnly;Domain=***.scm.azurewebsites.net"],"date":"Thu, 16 Apr 2020 13:58:57 GMT","connection":"close"},"body":{"Message":"'D:\\home\\site\\wwwroot\\api\\' not found."}}
##[debug]setting affinity cookie ["ARRAffinity=***;Path=/;HttpOnly;Domain=***.scm.azurewebsites.net"]
##[debug][PUT]https://$***:***@***.scm.azurewebsites.net/api/vfs/site/wwwroot/api/
##[debug]Encountered a retriable status code: 409. Message: 'Conflict'.
##[debug][PUT]https://$***:***@***.scm.azurewebsites.net/api/vfs/site/wwwroot/api/
##[debug]Encountered a retriable status code: 409. Message: 'Conflict'.
##[debug][PUT]https://$***:***@***.scm.azurewebsites.net/api/vfs/site/wwwroot/api/
##[debug]Encountered a retriable status code: 409. Message: 'Conflict'.
##[debug][PUT]https://$***:***@***.scm.azurewebsites.net/api/vfs/site/wwwroot/api/
##[debug]Encountered a retriable status code: 409. Message: 'Conflict'.
##[debug][PUT]https://$***:***@***.scm.azurewebsites.net/api/vfs/site/wwwroot/api/
##[debug]createPath. Data: {"statusCode":409,"statusMessage":"Conflict","headers":{"cache-control":"no-cache","pragma":"no-cache","content-length":"87","content-type":"application/json; charset=utf-8","expires":"-1","server":"Microsoft-IIS/10.0","x-ms-request-id":"5a889012-0b6c-421a-9c38-2eced7483369","x-aspnet-version":"4.0.30319","x-powered-by":"ASP.NET","date":"Thu, 16 Apr 2020 13:59:50 GMT","connection":"close"},"body":{"Message":"Cannot delete directory. It is either not empty or access is not allowed."}}
##[debug]Deployment Failed with Error: Error: Failed to create path 'site/wwwroot/api' from Kudu. Error: Conflict (CODE: 409)
##[debug]task result: Failed
##[error]Error: Failed to create path 'site/wwwroot/api' from Kudu. Error: Conflict (CODE: 409)
##[debug]Processed: ##vso[task.issue type=error;]Error: Failed to create path 'site/wwwroot/api' from Kudu. Error: Conflict (CODE: 409)
##[debug]Processed: ##vso[task.complete result=Failed;]Error: Failed to create path 'site/wwwroot/api' from Kudu. Error: Conflict (CODE: 409)

When manually trying to add the "api" folder to the azure web app, I also get an error:

enter image description here

The deployment task to deploy the api looks like this:

  - task: AzureRmWebAppDeployment@4
    inputs:
      ConnectionType: 'AzureRM'
      azureSubscription: '***'
      appType: 'webApp'
      WebAppName: '***'
      packageForLinux: '$(Pipeline.Workspace)\API'
      VirtualApplication: 'api'
    displayName: Publish API to Azure

What's the deal here? Is there any tutorial on how to do this? Am I configuring something wrong in Azure? What do I need to change to make this work? I've tried to see if I can publish the API manually from visual studio to see if it works there, but visual studio doesn't seem to support sub applications via the interface.

PaulVrugt
  • 1,682
  • 2
  • 17
  • 40
  • Hi friend, what's the result if you use zip deploy as deployment method? – LoLance Apr 16 '20 at 09:57
  • The result is exactly the same when using zip deploy. I tested it by changing the packageForLinux property to '$(Pipeline.Workspace)\API\package.zip' – PaulVrugt Apr 16 '20 at 13:36
  • @LanceLi-MSFT I've also added the relevant diagnostic logging to the original question – PaulVrugt Apr 16 '20 at 14:04
  • According to all above, I think your issue is more related to azure/kudu side, check if suggestions from [this one](https://stackoverflow.com/questions/46362680/azure-409-conflict-cannot-delete-directory-it-is-either-not-empty-or-access-i) helps for your scenario. – LoLance Apr 17 '20 at 07:03
  • I took a look at it, and tried setting the mode to webdeploy, to no avail. The topic you refer to also is the exact opposite of what my issue is. He cannot delete a folder, while I cannot create a folder – PaulVrugt Apr 17 '20 at 13:27
  • I tried to fix it by recreating the web app. It turns out, it stops working as soon as I deploy the main application to wwwroot. Then the "api" folder disappears, and I am unable to create a new folder called api, any deployment attempts to the api application then also fail – PaulVrugt Apr 17 '20 at 14:35
  • It has properly something to do with the setting "WEBSITE_RUN_FROM_PACKAGE". The publish task for the web application sets this to 1 (I can see that in the log). This causes the api folder to be hidden. – PaulVrugt Apr 17 '20 at 14:40

1 Answers1

6

The problem turned out to be that the AzureRmWebAppDeployment@4 task automatically enabled the WEBSITE_RUN_FROM_PACKAGE setting. Enabling this causes the entire wwwroot folder to become read-only. However there is no mention of this anywhere in the interface. This makes it impossible to deploy a sub application. Disabling this option fixes the issue.

I'm now going to try to include the API sub application in the package before sending it to azure, to see if the sub application then works. Otherwise I can simply not use the "run from package" option, despite its advantages over a normal deploy

You can disable the run from package by using the following parameters in the task:

     

 - task: AzureRmWebAppDeployment@4 
   inputs:         
     packageForLinux: '<path>' 
     enableCustomDeployment: true         
     deploymentType: 'webDeploy'
PaulVrugt
  • 1,682
  • 2
  • 17
  • 40