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:
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:
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.
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With