Jenkins deploy website to Azure Platform as a Service - azure

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.

Related

Copy a file from build agent to App Service without using FTP

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.

FTP task in Azure DevOps does not unzip the artifact to target Azure cloud server

I have a web based .Net application whose artifacts are being uploaded to Azure cloud through FTP Upload task. The issue is, it does upload the artifact but it is a zip file. How can I have it unzipped over the target location as there is no option of unzipping in FTP upload task.
I do not have the FQDN or IP of the Azure cloud server as it a PaaS based infrastructure, all I have is FTP location.
You cannot unzip file on FTP server. No matter what client/library/framework you are using. FTP protocol simply does not allow that.
See also:
Can we unzip file in FTP server using C#
How to unzip files via an FTP connection?
Based on my understanding, if you want to use Azure DevOPs FTP Upload task you need a FTP server address, username and password.
If it is that case, you could use the Azure logic App FTP(add or modify file) trigger to extract the file.
If it is not working for you and Azure storage is acceptable.
My workaround is that you could use the [Azure File copy] task to copy the file to your azure storage. Then you can control it by yourselves, for example: you could use the Azure function blob trigger to extract the file with you customized code.
The question is quite vague, but it sound like you might be trying to upload to an Azure WebApp which has FTP and also zip deploy functionality that uses the Kudu interface.
https://learn.microsoft.com/en-us/cli/azure/webapp/deployment/source?view=azure-cli-latest#az-webapp-deployment-source-config-zip
Using this Azure CLI command it will push your zip and deploy/unpack it into the WebApp for you.
PS. It's impossible to FTP without a DNS name or IP so you will have one of them in specified in the FTP location you've been given

How to download container blob into Azure App Service wwwroot?

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.

How to deploy NodeJS project to Azure websites?

We have a NodeJs project we are building with TeamCity, then using FTP, uploading the built files to our Azure web app (.azurewebsites). The project contains thousands of files, so the FTP upload times are very slow (takes a very long time). We would prefer to package the build as a ZIP file, then upload the ZIP with FTP (much faster). However, how do we unzip the ZIP file on Azure using script?
Or is there a better way to deploy our build to our Azure web app?
NOTES:
This is an Azure web app service, does not live on a VM
Our process needs to be automated with script to support CI/CD
Deployments with Git and other repos are not feasible
You can use the Kudu API or MsBuild to deploy an app (web app or Function) to Azure App service. The deployment is usually done in 2 parts:
Deploy the app service using ARM templates
Deploy the code/App using one of these methods
If you're using VSTS, there are templates for both steps and make it a 2min process to setup. If you're not using VSTS, the Kudu API is he best way to solve the problem.
You can find more information here : https://github.com/projectkudu/kudu/wiki/REST-API
You can also use the Azure PowerShell Management cmdlets to achieve the same. However, this is at the moment only supported on Windows

FTP'ing a Suave app to Azure

Having never used Azure before I'm attempting to deploy a simple F# Suave app to Azure using FTP. Ultimately I want to deploy via github but I initially thought FTP'ing it would be the easy first step. According to https://suave.io/azure-app-service.html it should be straight forward.
These are the steps I followed
Created a new web app in Azure including a resource group
and app service plan. All on the Free Tier.
Downloaded the publishsettings XML file that Azure created.
Cloned this repo: https://github.com/isaacabraham/fsharp-demonstrator
Used FileZilla to connect via FTP using the creds
from step 2.
Uploaded the files (via FTP) from
fsharp-demonstrator/src/SuaveHost (which includes the necessary web.config file) from the repo cloned at step 3 to
the site\wwwroot on Azure.
Navigated to Azure site url.
Then I receive the error:
The specified CGI application encountered an error and the server terminated the process.
(When I look at the folders on Azure under site\wwwroot I don't see any obj or bin folders. I don't think any msbuild process occurred. That doesn't seem right.)
Anybody got any idea what the problem is?
I suspect the issue is that when you deploy via FTP, then Azure does not automatically run the deploy script specified in the .deployment file.
The build.fsx script uses Kudu service to deploy the built files, so it might be easier to just use Github deployment rather than FTP - this way, Azure will do the deployment for you.
If you want to deploy via FTP, you'll need to build the project locally and upload the output. I'm not sure how to best do this with Isaac's Kudu-based demo though (ultimately, you need web.config that points to your built executable like this)

Resources