ggn979
ggn979

Reputation: 197

Find Azure slot location in azure App Service Deploy

How to find Destination path of deployed web site on Azure App Service Deploy - Azure Slot ?

I need to delete existing old files on a destination specific folder which are generated uniquely on each release(during build process).

This has to be done during pre-deployment.

I used Delete Files Task which is not deleting. Here is YAML.

In Kudu , I am able to see my web site location is D:\home\site\wwwroot\

I wanted to delete files from the path D:\home\site\wwwroot\scripts\libs>

steps:

enter image description here

enter image description here

Upvotes: 1

Views: 927

Answers (2)

Leo Liu
Leo Liu

Reputation: 76910

Find Azure slot location in azure App Service Deploy

You may not delete the correct folder.

According to the first image in your question, we could to know you are deleting the file from the folder $(build.artifactstagingdirectory).

As we know, the folder $(build.artifactstagingdirectory) is the local path on the agent where any artifacts are copied to before being pushed to their destination.

Check Build variables for some more details.

However, I do not find any task in your build definition to copy file to the artifacts.

Besides, you said you delete existing old files on a destination specific folder which are generated uniquely on during build process.

So, I am bold to guess that the file you want to delete should be in System.DefaultWorkingDirectory instead of artifacts. But I am not very sure about it, since I could not distinguish folder type from the path D:\home\site\wwwroot\scripts\libs>.

So, to resolve this issue, you can try to delete the file from $(System.DefaultWorkingDirectory).

Or you can use a Inline Powershell task to outcome the value of $(build.artifactstagingdirectory):

Write-Output '$(Build.ArtifactStagingDirectory)'

Then check if the value is match the path of folder you want to delete D:\home\site\wwwroot\scripts\libs>.

Hope this helps.

Upvotes: 0

Kasun Kodagoda
Kasun Kodagoda

Reputation: 4024

You don't have to manually delete old files on your App Service Instance or its Deployment Slots. When you are using Azure App Service Deploy task you have the option built-in to remove any unused files at the destination (in this case App Service Instance/Deployment slot). Here is how to do it.

On the Azure App Service Deploy task,

  1. Expand Additional Deployment Options.
  2. There make sure Select Deployment Method checkbox is selected
  3. From the Deployment Method drop down, Select Web Deploy
  4. Select the Remove additional files at destination checkbox
  5. If you want to keep any file that is installed with App Service Extensions or WebJobs select Exclude files from the App_Data folder as well

What this will do is it will compare the files that are already at the destination (App Service) with the files that will be copied over from the Artifacts. Then it will delete any file that is not available in the artifacts that you are doing to deploy.

Upvotes: 0

Related Questions