How to publish Angular App to Azure web app for Linux/ FTP using Azure DevOps Pipelines explained from scratch
Tags: angular, devops, azure, webdev
Published: 2020-05-17 13:56:29

In this post, I will explain from scratch in 10 steps, how to build a Azure DevOps pipeline to publish Angular app in Azure Web app for Linux using FTP method. Using this method you can also publish app in any FTP location also.

**Azure DevOps** — Is a continuous integration tool offered by Microsoft.

For creating **Azure Web app for Linux** checkout this
https://dev.to/bharatdwarkani/how-to-publish-an-angular-app-in-azure-linux-web-app-service-explained-from-scratch-4e9m

1. Login in your **Azure DevOps** account. [https://azure.microsoft.com/en-in/services/devops/](https://azure.microsoft.com/en-in/services/devops/)

1. Create a new **Pipeline**

![](https://cdn-images-1.medium.com/max/3784/1*9nUm11GkTDRfSHEbziEieQ.png)

3. Select the source where your application source code is located.

Since my source is located in Gitlab, so I have selected Other Git , you can select based on your need

![](https://cdn-images-1.medium.com/max/2918/1*37EWFF8Rre2XcfYcMdgyww.png)

4. Select new service connection

![](https://cdn-images-1.medium.com/max/3160/1*z78bqbRjskFLUmW7L8dHGQ.png)

Fill the details related to your Source Git repository and click continue.

![](https://cdn-images-1.medium.com/max/2544/1*-rGXRjv8iI7kL-OUM5Xvaw.png)

5. Select Empty Job in template.

![](https://cdn-images-1.medium.com/max/3104/1*WezeTCtDvgCV4QPHjH_Xaw.png)

Now pipeline view will appear. There are various predefined tasks available in Azure DevOps. In next few steps I will explain which tasks to add to build and publish Angular app.

**i) NPM Install
ii) NPM Build
iii) Publish Artifact
iv) FTP Upload**

6. Add task — **NPM**

![](https://cdn-images-1.medium.com/max/3124/1*f12o332u4C8reBzYitv9wA.png)

Click on npm install. In property select your app location.

Here I have filled** $(Build.SourcesDirectory)/myapp**

Since in repository, my source is located not directly in root folder instead inside myapp folder. Based on your source folder structure you can fill appropriate source path folder which contains package.json file

![](https://cdn-images-1.medium.com/max/2092/1*vgebDzzwNd0o9rw0J_iSQg.png)

![](https://cdn-images-1.medium.com/max/3108/1*mzRgGSfsZzO92Hrl4zRMiA.png)

7. Next, again search NPM and add npm task. This task is for build.

![](https://cdn-images-1.medium.com/max/3146/1*-8JIXJjTTkXBg12Lh_JaGQ.png)

Change properties as shown in screenshot for Build task.

i)** Command** to Custom

ii) **Working folder** — $(Build.SourcesDirectory)/myapp

iii) **Command and arguments **— run build-prod-agent

build-prod-agent — depends on what you have set in package.json file of your app.

![](https://cdn-images-1.medium.com/max/2000/1*4Lj1vs_uuxiH7Qn-N3IIiQ.png)

![](https://cdn-images-1.medium.com/max/3126/1*5TGXJ6tyWb6FFph1_9AJog.png)

8. Now add one more task **Publish build artifacts.** Using this you can download published files after CI completes. If this is not added after build completes you wont be able to access published files.

![](https://cdn-images-1.medium.com/max/3130/1*Dh-j-9jgqQnRyZLrovxxyg.png)

Change artifacts properties

**Path to publish **→ Angular dist folder path
**Artifact name **— publish

![](https://cdn-images-1.medium.com/max/3134/1*1_7DCLTvxQ4WDKO3W1eZWw.png)

8. Final step is to Create a **FTP upload task**. Select and add.

![](https://cdn-images-1.medium.com/max/3156/1*kogiax9hDq8wAeprdT1irw.png)

Click on manage FTP to add a FTP connection for your azure app service.

![](https://cdn-images-1.medium.com/max/3084/1*q2DrRGNy4w0pXJ9-cHwEFg.png)

On clicking manage a Service connection page will appear. Click new Service connection.

![](https://cdn-images-1.medium.com/max/3986/1*Gc5XzlOzdxrEunfU1HWtVw.png)

Select type — Generic

![](https://cdn-images-1.medium.com/max/2778/1*0ujAu8BcxSQfgn-_1O6N9A.png)

Now go to your Azure app, Click on Deployment center and get Endpoint, Username and password.

![](https://cdn-images-1.medium.com/max/3880/1*8TJwFEYJhHq0agwLDH54lQ.png)

File the details in FTP connection page and click OK.

After that in FTP task properties select recently created FTP service connection name and fill root folder

Root folder is your publish location where your app creates publish dist folder.
$(Build.SourcesDirectory)/myapp/dist/publishfiles.

If your app produces files directly in dist then can just give $(Build.SourcesDirectory)/myapp/dist

![](https://cdn-images-1.medium.com/max/3262/1*rFcl9EMmQP4Ww9uEaNc3lg.png)

9. Final step is to create a trigger. Here I am creating a trigger scheduled task. Every day at 2 AM Pipeline will run at 2.00 AM to build and publish development branch source to Azure app service for Linux.

![](https://cdn-images-1.medium.com/max/3146/1*dG9a0xZIK2y2OhV_Hb3qPw.png)

10. You can also run manually build from pipelines page.

![](https://cdn-images-1.medium.com/max/3890/1*JfmBpTgN2BphGD2QKkYdOw.png)

On clicking pipeline you can view details and also download publish files

![](https://cdn-images-1.medium.com/max/3666/1*KiS7zieYkaYPzoiaOLu1ng.png)

Hope, you have found this post useful. Azure DevOps has several inbuilt tasks you can add to enhance your pipelines. Like adding Test, Security testing etc., There is one more way by using yaml file you can create pipeline.

**For more such interesting technology related blogs, resources visit my site**
(https://sharetechlinks.com/)