Jump to content

Featured Replies

Posted

There is a common scenario that customers want their app service being allocated inside private network and cannot be accessed by public network. Therefore, they usually enable private endpoint as well as configure Access Restriction to deny all the public traffic.

 

 

 

When the private endpoint is enabled and public traffic is denied to the web app, all the public traffic to this app is cut off. Since there is a range of IP addresses where agents are deployed, they have a public IP. Obviously, these agents are unable to reach web app.

 

mediumvv2px400.png.5b62cdf89d696157e68d90871e85a61b.png

 

 

 

As a solution, we can either allow the IP ranges list in the firewall or use self-hosted agents to deploy.

 

You may check below document for more information Microsoft-hosted-agents for Azure Pipelines

 

 

 

In below lab, we will demo 2 tests. One is what if we deploy code to a web app with private endpoint by Microsoft-agent and another one is how to deploy by a self-hosted agent.

 

 

 

Lab

 

Test1: deploy using Microsoft-hosted agent

 

Result: We will see Error: Failed to deploy web package to App Service. Ip Forbidden (CODE: 403) since web app is not accessible via internet.

 

 

 

Create a new pipeline

 

399x42vv2.png.d020a94fb9ab1687c05dea02a886bb7a.png

 

 

 

Here, I select GitHub in this demo

 

mediumvv2px400.png.3a20d069107dc771fc0e34ee1792c16e.png

 

 

 

Deploy a Django app. So I choose the second one.

 

mediumvv2px400.png.768d18a0ec40076259e1a7711927ad90.png

 

 

 

Select subscription and web app name

 

mediumvv2px400.png.fe8139d4b49f150ffdeacf0ed0b1bef5.png

 

 

 

Save and run

 

mediumvv2px400.png.f63b3a88d8d62729491ed9258fae9b25.png

 

 

 

Web app is private endpoint enabled which means the inbound traffic needs to be a private IP from the same subnet as web app or an IP that has permission to access this app service.

 

However, Microsoft-agent works over public network. It is deployed failed and the Error - Failed to deploy web package to App Service. Ip Forbidden (CODE: 403)

 

mediumvv2px400.png.b5c7a9617263f1a6870255f8a44e77ce.png

 

mediumvv2px400.png.02e64f443b9b25f83793507c1eec9f91.png

 

 

 

Test2: deploy using self-hosted agent on Linux VM (Ubuntu 20.04)

 

Result: it works fine. Deploy successfully.

 

 

 

Create Linux VM (Ubuntu 20.04) in the same VNET as web app.

 

mediumvv2px400.png.c5e07d41aa6594bc7789bd22f5004872.png

 

In Azure Devops portal, Add agent pool

 

mediumvv2px400.png.c96c3d00b9d38747df0c71b25575783f.png

 

mediumvv2px400.png.a76256347c5a83d0e3cde8f321113ef5.png

 

 

 

Then New Agent and choose operating system of your build machine. (Here, I choose Linux)

 

mediumvv2px400.png.dd7c261aacb63ba492688ae3660699e2.png

 

 

 

Get Personal Access Tokens

 

 

 

mediumvv2px400.png.0edad397baf7fc1df81a90611c641ef5.png

 

 

 

New token and grant permission to agent pools

 

mediumvv2px400.png.bdad1d7b14a3df542d6dad1858175c32.png

 

 

 

Remember to record this token as it will not displayed again.

 

mediumvv2px400.png.c2926f9749a270997cb0b0a015565378.png

 

 

 

SSH into Linux VM and configure agent to connect Azure pipeline

 

Download and create agent

 

mediumvv2px400.png.57398ef3de9c29f6c4d3fa3d17e3c466.png

 

 

 

Configure agent settings

 

Sever URL:

 

  • mediumvv2px400.png.09a4493cb5f2317babea73ae60969e9e.png

 

Please refer to Deploy an Azure Pipelines agent on Linux - Azure Pipelines | Microsoft Learn

 

mediumvv2px400.png.26c9d67522729c4546e2ad398a92e7de.png

 

 

 

Run agent

 

mediumvv2px400.png.482a8b3c3793ca2407de2163e5bc33ce.png

 

 

 

Check from portal that agent is online

 

mediumvv2px400.png.be164d243d030c1df8a1c7c78aa297a4.png

 

 

 

In order to get confused, we create a separated pipeline here.

 

Creation Steps are the same as previous steps:

 

New Pipeline -> GitHub -> Python to Linux Web App on Azure -> Select subscription -> Select web app name -> Save and run

 

 

 

Modify the yml file. Change pool to the one just created.

 

mediumvv2px400.png.74f9b8f197f4a2d801112aef30de09b6.png

 

 

 

Then, run the pipeline again. We can see that it deployed successfully this time.

 

mediumvv2px400.png.f250717ad75c40bb1c77e92e8575a743.png

 

 

References

 

Deploy an Azure Pipelines agent on Linux - Azure Pipelines | Microsoft Learn

 

Microsoft-hosted-agents for Azure Pipelines

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...