In my Azure DevOps release pipeline, I want to upload a file from the build agent to app service server. For security reason, FTP is disabled by my organization. Is there a way to achieve this without FTP?
You could try Azure App Service Deploy task to deploy the file to the app service. In this task, set Package or folder argument to the folder path where the file exists.
Related
I've a two applications, backend and frontend, hosted on the same Azure web app (os : windows).
Actually, i Deploy the two artficats via FTP/S.
I use wwwroot folder to the front and a subfolder in wwwroot folder to the backend
I would use Azure Devops to create a Azure Release to deploy the two application to my web app.
I can't use two app service for the backend and the frontend.
What is the best approch to deploy ? and It's possible to specify a subfolder target in Azure App service into Azure release ?
Regards
It is impossible to specify a subfolder to deploy to in azure release pipeline using the deployment tasks. The artifacts will be deployed to wwwroot folder by default.
However,You can use copy files task in your release pipeline to copy the backend artifacts into the subfolder which resides in the frontend artifacts folder. And then deploy the frontend artifacts folder which contains the backend artifacts in its subfolder. See below:
You can also run Kudu rest api in azure powershell task to deploy to azure web app service.
You can first use the command api to create a subfolder in wwwroot.
{
"command" = 'md subfolder',
"dir"='D:\home\site\wwwroot'
}
Then you can deploy the backend artifacts to the subfolder using zip deploy api
$apiUrl = "https://{sitename}.scm.azurewebsites.net/api/zip/site/wwwroot/subfolder"
Please check out this blog for more information. See this thread for example using azure powershell task to call kudu rest api
During the Azure Release pipeline, I would like to copy a file in a Git repo to the wwwroot directory in the app service. The output from the task says it copies the file but it is not there. I am thinking I am not specifying the target folder properly. I currently have it as d:\home\site\wwwroot. Thanks for any help.
Copy file to Azure App Service During Release Pipeline
You could not use the copy task to copy a local file to the Azure app service. This task only supports local replication.
When you set it as d:\home\site\wwwroot, the copy task will copy the file to the folder in the agent, which runs this task rather than the Azure app service.
To resolve this issue, you could use Azure App Service Deploy task to deploy this file to the app service. In this task, set "Package or folder" path to the folder where the file exists.
Or you can consider the advice of Leo Varghese, to use the FTP upload task to copy that file to the app service.
Hope this helps.
#Doug, You an make use of the FTP upload task to copy a file in your build artifact to the wwwroot folder. Assuming your file in gitlab is present inside the artifact after the execution of build pipeline.
Please refer this article -> https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/ftp-upload?view=azure-devops
For performing FTP upload you will need your FTP credentials available for your web-app. This can be obtained from the Deployment Center of your web app.
Hope the above answers your question. Please let me know if you have any queries on this.
We have an Azure DevOps release pipeline using the deploy azure app service task to deploy an application.
We would like to run a task prior to this deploy task to delete all files in the bin folder of the app service.
We do not want to delete all files on the target, just the ones in the bind folder.
I can't see any obvious task that will enable me to do this. Tasks seem to run in the context of the deployment server rather than the app service and so don't enable access to the app service file system.
What's the best way to do it?
If you are looking to avoid unwanted files then in the Azure App Service Deploy task there is an option "Remove additional files at destination" which while not explicitly deleting the bin folder content will ensure there is no residue from previous releases.
I have a zip file in a container under an Azure Storage account.
I want to download this zip file as a pipeline task after the deployment of the .NET Core app to an Azure App Service slot (Azure DevOps). The front-end (index.html) of this app is in this zip file, which must be downloaded/extracted to the wwwroot.
I tried it with a Azure PowerShell script: InlineScript task but there is no wwwroot folder available as seen in the Kudu debugconsole of the App Service.
Is there a(n easier) way to achieve this?
I'm not sure I quite understand the issue (you're deploying a webapp, then you want to download another zip from blob storage, and deploy that to the same webapp?), but I'll have a stab at it.
Deploy the webapp with Azure App Service Deploy task as normal.
Add an Azure PowerShell task, which will run on the Build Agent, not on the webapp, so it won't see the wwwroot folder. It can however run Get-AzureStorageBlob to download the zip, save it locally in a local folder (like $(Build.ArtifactStagingDirectory)/tmp or something).
Have an Azure App Service Deploy deploy it ($(Build.ArtifactStagingDirectory)/tmp/*.zip) up, just make sure that you haven't selected "Remove additional files at destination" when you do the second deploy or it will wipe the first site out.
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?
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 to site\YourApplicationorsite\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.