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.
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
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.
We have an ASP.NET Core application build in TFS and we want to deploy the built files to multiple Azure App Services. It appears the solution is to use multiple Azure App Service Deploy steps. While testing this we are able to get the output zip copied to the App Service but we can't figure out how to copy all the raw output files. Can anyone help us understand how to do this?
Base on the screenshot you will copy the files from $(build.stagingdirectory) to App Service.
So, if you want to copy other files, then you can add a Copy Files task before the Azure App Service Deploy step to copy the files to $(build.stagingdirectory) first.
By default, the value of Package or Folder is something like
$(build.artifactstagingdirectory)/**/*.zip
So, you can try to use $(build.stagingdirectory)/** to copy all the files to App Service.
See below articles for more information:
How To: Extend your deployments to Azure App Services
Deploy a web app to Azure App Services
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.
I have successfully implemented Jenkins to deploy to a server hosted locally, but now I need to create a job to deploy to a Azure hosted website running on PaaS. Both the Jenkins host and Website hosts are Windows machines.
I have found a link for setting up a virtual machine template for Azure Slave plugin, but there is no VM because it is IaaS and I dont have additional slaves in this case.
I am asking about the plug ins and process flow please.
Which Azure Plugin should I use in Jenkins (if any)?
E.g. Azure PublisherSettings Credentials plugin
Do I use the Get-AzurePublishSettingsFile and Import-AzurePublishSettingsFile ?
Would these contain all the relevant details required for Jenkins to know
where to copy to?
Would I create a zip file of the build, upload the zip to BLOB storage,
and then extract it to the website?
Is it possible to upload a zip file and then proceeding to extract the files once the whole file has been uploaded?
If the connection is interrupted at any stage while uploading 1000 individual files then the website will be unstable and therefore I need to investigate a single file upload with extraction thereafter.
So if I were you I'd do the following:
1. Install jenkins powershell plugin, install Azure PowerShell commandlets.
2. Create a job in Jenkins that creates a the zip file and uploads it to Azure Storage
3. Create an ARM template to deploy Azure WebApp from the zip file in Azure Storage.
4. Create a job to deploy said template.
So the ARM template would take the zip file and upload it to the Azure WebApp and the WebApp would handle all the hassle with the zip file internally.