{"id":3418,"date":"2024-02-01T10:22:09","date_gmt":"2024-02-01T16:22:09","guid":{"rendered":"https:\/\/microsoftgeek.com\/?p=3418"},"modified":"2024-02-01T10:22:09","modified_gmt":"2024-02-01T16:22:09","slug":"setup-self-hosted-linux-agent-in-azure-devops","status":"publish","type":"post","link":"https:\/\/microsoftgeek.com\/?p=3418","title":{"rendered":"Setup Self Hosted Linux Agent in Azure DevOps"},"content":{"rendered":"\n<p>Let us learn how to create and configure a Self-Hosted Agent in Azure DevOps (ADO).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEg_sKTp6r-BtF7EkVI8ZRLPmvV51ZcKbRvqgQA64iemTEpNTiVyibfvZpfrXOidVKSJTARrIe1YEIUg1j8Jz-lej4_OOR67l75MO7eeoQurauJMRGdHtFthHI_p3FFztz7Ir9ZGmKbIMZ3UzYg_50agKCLnxF6kn2Y1_MLQ7HSWpmtFSQ0oXTqbxfSD\/w400-h224\/Screen%20Shot%202023-01-25%20at%2010.10.10%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong><u>What is an Agent?<\/u><\/strong><\/p>\n\n\n\n<p>An agent is computing infrastructure with installed agent software that runs one job at a time.<\/p>\n\n\n\n<p>To build your code or deploy your software using Azure Pipelines, you need at least one agent. As you add more code and people, you&#8217;ll eventually need more.<\/p>\n\n\n\n<p>When your pipeline runs, the system begins one or more jobs.&nbsp;<\/p>\n\n\n\n<p>In Azure pipelines, there are two types of build agents:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong><u>Microsoft-hosted agents<\/u><\/strong>&nbsp;&#8211; This is a service totally managed by Microsoft and it&#8217;s cleared on every execution of the pipeline (on each pipeline execution, you have a fresh new environment).<\/li>\n\n\n\n<li><strong><u>Self-hosted agents<\/u><\/strong>&nbsp;&#8211;&nbsp;This is a service that you can to set up and manage by yourself. This can be a custom virtual machine on Azure or a custom on-premise machine inside your infrastructure. In a self-hosted agent, you can install all the software you need for your builds, and this is persisted on every pipeline execution. A self-hosted agent can be on Windows, Linux, macOS, or in a Docker container.<\/li>\n<\/ol>\n\n\n\n<p><strong><u>Pre-requisites:<\/u><\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Microsoft account setup<\/li>\n\n\n\n<li>Azure account and subscription setup<\/li>\n\n\n\n<li>Create a VM(Ubuntu 18.0.4) in Azure Cloud<\/li>\n\n\n\n<li>Create Personal Access Token in Azure DevOps<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong><u>How to configure Self-hosted build agent?<\/u><\/strong><\/p>\n\n\n\n<p>1. Go to Azure DevOps dashboard &#8211;&nbsp;<a href=\"https:\/\/dev.azure.com\/\">https:\/\/dev.azure.com\/<\/a><\/p>\n\n\n\n<p>2. Select your project dashboard<\/p>\n\n\n\n<p>3. Go to your project settings<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgijAfcHkGc6NltBr7jIF8fctrbxln8pde--SnzlPR-_VZQYE1gH7_7j8iheltCAkUnrYtI-KCKp6X4NVqWp1hDbWhv3KcGo_X-bLDpP0yRM_e08V4on2TwxTuJJ1tON2uf8l4z_eMgSYOIL462uuNiY2sNN_dhM4hRH4N7Q5JzQYGdDYYzLYBxekse\/s320\/Screen%20Shot%202023-01-11%20at%2010.59.57%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>4. Click on Agent pools<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjneVP2qJTMNVix3f0-sKFCYC6QSvGY-rM-oookGItKDhFEE2lt5SaioZrrbV2bAjNZTp8y-M5sDrNOpquBVdRvgPWJr7RTPGe7kwGUtXAjGYV9W8Zt-gztdYuz52-O3ttvTipCWvZwBfZKgB-8PWtu7aHEkncuSQDHSqlczL27gh5o4o6dyk0HxP7v\/s320\/Screen%20Shot%202023-01-11%20at%2011.00.21%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Create a new Agent pool name<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEiGSnTkyiJnvR5u_pUQ81QtES2YNSZ7fkyteX8C34ia-yiu2elm37psz0XOgFQChVgCPPjoYyrtSknWyoUowrwAJ6yE-qgkYca6evJCgL8MTvhUKXQfVk6x9OTng4_wD1ht6RYY7zSBanRBJMoOsh2JmPDRbWcAKYev9xFFifaY0tkjR1o_ievxRg08\/s320\/Screen%20Shot%202023-01-22%20at%209.01.27%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Enter name as&nbsp;Ubuntu18-VM-Pool or any name<\/p>\n\n\n\n<p>Make sure you select Grant access permission to all pipelines<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhgtx6eSnaxIbzRmTVa7MY9DCKOYJbFxLSrYtl65HWz1LnkYo_F_ItwtrzZ9Mhe5sI_F5XXg0cmN32FjFp4ZEJNnJynT773znSM1a4uQYbfN1eJII-2uXKL2U934YY_8ZzabbrVYDeNs9kZfxrGKjzIsJ0kyP97Qyg39-8CDosRLprQf5Auh--VNXr0\/s320\/Screen%20Shot%202023-01-22%20at%209.03.09%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>click on&nbsp;Ubuntu18-VM-Pool, Agents, New agent<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEh5MJyoKSNcAuRCoaY-L2ODw5N8Dk7QfDbYr3UO2HbT8ztsuqI2wxGtfGe_yST3cHYcteFjEiPxGWvpfotk5NG1iWKXy8bhUXYeKtgUkrXiZP3vOLz3kgufbWJyoH_m696uKxuz30oKHyr8EhJkZQR6yeJiSnpsubZCq0OH5CmmWpMxVWmEKxJJH79_\/s320\/Screen%20Shot%202023-01-22%20at%209.05.34%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Click on Linux<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEi1ZGXJz_C1Muel6bs9PzMTmQMCeF7bsFoQDwbsJzo6O_YT0P_S_AXEH-6rq7JQf6q1OQf7ollkR4onb3o2dvGMYZvFEvVqgIj_RaHG_lABiDgWQPXr48_XJB_HPBcKTn42-NwPPNRpd7-WaP2P6Z4GvEI729lidApENF7-dcbKMFbqDsGH4bqkRt-6\/s320\/Screen%20Shot%202023-01-16%20at%209.51.07%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Note down the steps to configure Linux build agent.<\/p>\n\n\n\n<p>Login to your Azure VM now.<\/p>\n\n\n\n<p><strong><u>Step #1 &#8211; Create the Agent<\/u><\/strong><\/p>\n\n\n\n<p>mkdir myagent &amp;&amp; cd myagent<\/p>\n\n\n\n<p><strong><u>Step #2 &#8211; Download the agent<\/u><\/strong><\/p>\n\n\n\n<p>wget https:\/\/vstsagentpackage.azureedge.net\/agent\/2.214.1\/vsts-agent-linux-x64-2.214.1.tar.gz<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjg3fSYGIYF3P9X_Dh5pLUf0sNzO2B5r4oKy8sDm-3fuDrMBRlwGXT7Xi_NTwkVDgmx2I6yb8jO4_DLeW4-7RM-0_U4QmKWfMB4E-fZO1jU4bLFA9laQTS7-3d6o0o31aE9sNpxmgZhYZagxwXnnZvypWTOXUrARFVp4BFyxRfLxioIsRmC-qcWEWTF\/s320\/Screen%20Shot%202023-01-22%20at%208.17.26%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong><u>Step #3 &#8211; Configure the Agent<\/u><\/strong><\/p>\n\n\n\n<p>tar zxvf vsts-agent-linux-x64-2.214.1.tar.gz<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhR6ZB9OuuincImSdgc1MtarnqjjJ2gVkDXqh5tigap9EAPN__Bybwiifa66184kd4QPFeEvoQSOK9wM9bSGOdC4MMbkBunZrvjyHhyq-XomM0fdMYy3-ZbTg-mHc1at78IOWx_TE8zfcAIBV8YP0B0pR9qFxbZBHhH-qF2anzAqOwSB74Mp8s_gqE8\/s320\/Screen%20Shot%202023-01-22%20at%208.20.37%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>List the files in the directory after extracting.<\/p>\n\n\n\n<p>ls -al<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEiNJw9rNZ3UoXWf65IELnVFyXeJoOB_2fnFsVsTMbeqcs3XojutIGXeIptTAXIM7juVWOGkn-9qGHp5dPLjNCyDBBUVduwaScKLzAvVtSgpGcX0I7McQAQdB9GWWm84T7D0wuYw-NmpFx0N5F7ebODTDJnP7qavuYP50x98mHGUR-t13h1mHPyxpPQr\/s320\/Screen%20Shot%202023-01-22%20at%208.22.18%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong><br><\/strong><\/p>\n\n\n\n<p><strong><u>Step #4:<\/u><\/strong><\/p>\n\n\n\n<p>Run the below command:<\/p>\n\n\n\n<p>.\/config.sh<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEi1_YavkzPzoSkgZzlx5Hgb7znnC_woZVpLcAzRBPuWX5_2RJeO4arKRgkAIVoUYB8jriNwk8NxE-4rBe7yrDCnF0wApUdNFaY-2XrkTcm83VAFOUI8py1I5lxAhzkobHbEUwyKcxqKi5C_JxTPD_ghb09y0bDjVSxQuS0zfHnTh2U9GrrNAC748D8t\/s320\/Screen%20Shot%202023-01-17%20at%2010.10.45%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Accept the Team Explorer Everywhere license agreement now?<\/p>\n\n\n\n<p>Type&nbsp;Y&nbsp;and enter<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjkLCSjY6zbbc-mRptNiCFFdmLpJefwOmBKTHwXhKp32RgUY6IViqNshWT-qgdPuZYRy3_5PAfQXZ6FIcQymsRPLIiXBTcYlLdh_AyqgODgpBTqwqkJx7E9KqZLU8RSnAs5t6ZTYNyBIsyT3p2QAFZkDjV5znup7MmwMUeNJqYSGeYFOa8d5AfNNS2P\/s320\/Screen%20Shot%202023-01-16%20at%2010.07.14%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong><u>Step #5:<\/u><\/strong><\/p>\n\n\n\n<p><strong>Enter server URL &gt;<\/strong><br><strong>https:\/\/dev.azure.com\/<\/strong><strong>yourorganization<\/strong><\/p>\n\n\n\n<p><strong><u>Step #6:<\/u><\/strong><\/p>\n\n\n\n<p>Enter authentication type (press enter for PAT) &gt;&nbsp;PAT<\/p>\n\n\n\n<p><strong><u>Step #7:<\/u><\/strong><\/p>\n\n\n\n<p>Enter personal access token, generated from\u00a0this step<\/p>\n\n\n\n<p><strong><u>Step #8:<\/u><\/strong><\/p>\n\n\n\n<p>Enter Agent pool<\/p>\n\n\n\n<p>Give some name<\/p>\n\n\n\n<p><strong><u>Step #9:<\/u><\/strong><\/p>\n\n\n\n<p>Enter Agent name &#8211;&gt;&nbsp;myBuildAgent_1<\/p>\n\n\n\n<p><strong><u>Step #10:<\/u><\/strong><\/p>\n\n\n\n<p>Enter work folder &gt; enter<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgOZG8Yw3GvxvvBH2qg7wnwaN5tn-rQ0np_MJZ3H1FFZk7BGPWCkZpnYtacq9T_EymSpReCITM0Fz6jujPKZ7t4i0PZp_e8ax-Ahqg-WKhODD66EeMCdi1mfcB3z9SFZCI4jxT4E6c6mckAutpkr2IcoEO04Tkyx8a1DTOPgrriQP14N5pNdYAhdpMN\/s320\/Screen%20Shot%202023-01-16%20at%2010.35.02%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>that&#8217;s it agent is successfully configured.<\/p>\n\n\n\n<p>Configure the Agent to run as a Service<\/p>\n\n\n\n<p>sudo .\/svc.sh install &amp;<\/p>\n\n\n\n<p>Execute now to run as a service<\/p>\n\n\n\n<p>.\/runsvc.sh &amp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgiXqITgAEPYTtOiTAYSTr8NaHJBfrCRuxNX4SR_8Na0LsysOPIsTOj24z-r0U1B3WtdXuLBQJCWdHmet9Kh9h_QmRtdY_VrUZgZou7gItMvBeHubhQ7PN-_BlZJvb4C8zn7cBymh_hzXt6CpVAAZEdxqgKRJfGHkqloHxIR22McKx_M7Zz3DuYEJ8h\/s320\/Screen%20Shot%202023-01-16%20at%2010.58.44%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong><u>Check the status of build Agent<\/u><\/strong><\/p>\n\n\n\n<p><strong><u>Click on Ubuntu-18-VM pool name<\/u><\/strong><\/p>\n\n\n\n<p><strong><u>Click on Agents<\/u><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjWkuNW0ibuM49l2BxuTB9ieyaJEsOfm-ufBq6w4_jwmu3VqbV8rDnqHQi1iZqkiHbujsImYWQ6ZF7RCWMIx8AKwSe2wSpXn9t6gXWSTeW639mHeExxtO2BZ04xKUG16SKBjfbilXWUY--QMJJs_rWi-gTlYVUSyHySl0HuTzGKiqJCGdENqy8nUWy0\/s320\/Screen%20Shot%202023-01-23%20at%209.12.38%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>This confirms that Build agent is successfully configured in Azure DevOps and is available to run builds.<\/p>\n\n\n\n<p><strong><u>Steps for removing Agent from the agent pool<\/u><\/strong><\/p>\n\n\n\n<p>Remove the service first<\/p>\n\n\n\n<p>sudo .\/svc.sh uninstall<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhG1Ncl_T2yP32M5qWzh9j0WlowgJzHdx7XWB_zChgGnAtzTuzzTh3TAXG9dntyeDefV7Ug8Ij8xfAOAUt_VeegCniUU9oBU3eVOqrWQF_8YmrH-jgbGKb3Ywo4xwqnChM6sLfx2kNTquIBoBHaVUvMpNmw6vA-nJfpoWCnlGDaTK7ewnU9OG_YL5CY\/s320\/Screen%20Shot%202023-01-22%20at%208.54.45%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>.\/config.sh remove<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEi7EHbOW0gOmiv440VqyJHXNK1K7E1hEiBAVwcvcc1Rio9TVTbabP2keqWHy3WcjTDC5r-7WLE01jcSWad2lYx7XltPtJaSK92xlfllh2vWblEG1G1h2-5ER5P4HDywL54ZyGUumAsYh2BTsChhnbOgWO8OvACWmYFn_Vl3xsm8i6wQbFdT6MQKPgBO\/s320\/Screen%20Shot%202023-01-22%20at%208.56.29%20PM.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>To Perform Java related builds on this Agent, make sure you install Java and Maven on this VM.<\/p>\n\n\n\n<p><strong>Install Java 11<\/strong><\/p>\n\n\n\n<p>sudo apt-get install default-jdk -y<\/p>\n\n\n\n<p><strong>Maven Installation<\/strong><br>Maven is a popular build tool used for building Java applications. You can install Maven by executing below command:<br><br>sudo apt update &amp;&amp; sudo apt install maven -y<\/p>\n\n\n\n<p>Check if Maven got installed<\/p>\n\n\n\n<p>mvn &#8211;version<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let us learn how to create and configure a Self-Hosted Agent in Azure DevOps (ADO). What is an Agent? An agent is computing infrastructure with installed agent software that runs one job at a time. To build your code or deploy your software using Azure Pipelines, you need at least one agent. As you add [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69,35,77],"tags":[],"class_list":["post-3418","post","type-post","status-publish","format-standard","hentry","category-azure","category-cloud-computing","category-devops"],"_links":{"self":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3418","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3418"}],"version-history":[{"count":1,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3418\/revisions"}],"predecessor-version":[{"id":3419,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3418\/revisions\/3419"}],"wp:attachment":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}