I have a release in VSTS to deploy my webapp to the azure app service. For this I use a Azure App Service deploy step. After the normal deploy of the webapp I want to add an additional zip artifact from another build result. I want to copy only those file to a specific path of the web application on azure. How can I do that?
3 Answers
If the zip file is the web deploy package, you can refer to Joy’s answer. (Need to check Application option)
Otherwise, the simple way is using Kudu REST API (remain folder structure), steps:
- Uncheck Publish using Web Deploy option of Azure App Service Deploy task
- (Optional) Add Unzip task to extract zip files to a folder in artifact folder (the folder that you want in app service, e.g.
D:/1/a/mylib
) - Specify folder (parent folder of step 2 to remain folder structure) or package (zip) in Package or folder input box
You could use Virtual applications and directories to do it.You could check my steps.
- Go to azure portal -> APPLICATION -> APPLICATION SETTINGS->Virtual applications and directories
- set virtual directory with virtual path :
/YourApplication
tosite\YourApplication
orsite\wwwroot\YourApplication
- Go to VSTS-> the release option-> the
Deploy Azure App Service
task - set virtual application to
/myApplication
Hope it can help you.
If using Azure DevOps for your CI then an alternative solution is to zip your file(s) including directory structure from the web root and add them into DevOps as a 'secure file' (find this under library/secure files once you've configured an Azure KeyVault).
Then add a pipeline task to download the secure file (use "Download secure file" task) to your build server. Make sure you add a "Reference name" to this task so you can reference the downloaded file path in a later step.
Then add a stand-alone "Azure App Service Deploy" step to deploy just this zip file. Select deployment method of "Zip deploy" and reference your downloaded secure file in the "Package or folder" section, like $(secureFileReferenceName.secureFilePath)
.
This effectively downloads the zip file from secure storage to the build agent and unzips it to wwwroot in the App Service.