Self-Hosted Azure DevOps Agents: From Setup to .NET Core Build on Windows Server

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone I'm SEL and welcome to Omega codex to build your source code and to deploy it using EO pipelines we need at least one Azure devops agent it can be a Microsoft hosted agent or a self-hosted agent today we are going to explore how to set up a self-hosted agent on a Windows Server this can significantly optimize your cicd pipeline especially if you're dealing with specific security privacy or performance requirements first we will discuss what a self-hosted Azure agent is and why it might be beneficial for your projects next we will delve into the installation and configuration of azure agent on Windows Server after that we'll build our net core application using our newly configured agent if you are new to Azure devops pipelines you can check out this video to learn and about how to set up pipelines using Azure devops in that video we had used a Microsoft hosted agent to deploy and build code without further Ado let's jump into the details and understand what a selfhosted aure agent is so grab cup of coffee and let's get [Music] started before we dive into the technical setup it's crucial to understand what a self-hosted agent is and why they can be significant addition to your devops toolkit let's get a clear picture of what we are working with Azure devops provides two types of Agents Microsoft hosted agent and self-hosted agent Microsoft hosted agents are managed and maintained by Microsoft in contrast self-hosted agents are set up and maintained by you on your own inure this could be on premise or in a virtual machine in the cloud why choose a selfhosted agent firstly it gives you more control over the environment the agent runs in allowing you to customize the hardware the installed software and the Network it operates in this is particularly beneficial for specific build or test requirements that are not readily available in Microsoft hosted environments for organizations with strict compliance or security requirements self-hosted agents ensure that your code and data never leave your controlled environment you may also have an internal artifact repository or or a Newgate source which you want to use for your build which is not accessible on a Microsoft hosted agent also you can get a better performance as you have more control on the resources you use for setting up the agent now that we have understood what and why let's talk about how but first we need to ensure we have everything in place to set up a selfhosted Azure agent you will need few things a server windows or Linux this can be an existing server or a new virtual machine and Azure devops account and administrative access to both make sure your server meets the minimum hardware and software requirements for Azure devops agents we'll be using a Windows server for this video setting up the Windows Server involves a few key steps ensuring that the operating system is up to date configuring the necessary network settings and ensuring all required software is installed first and foremost ensure your windows is up to date this means running any pending updates an updated system not only ensures compatibility with Azure devops but also keeps environment secure your server should be able to to communicate with Azure devop services this might involve configuring firewalls or proxies if you are operating in a restricted environment ensure that all software required by the agent is also installed this includes the Net Framework or any other dependencies specific to your development needs as your server will be part of your cicd pipeline it's important to follow best practices this includes using a service account with limited privileges for the agent and ensuring your server is protected against unauthorized access I will be using a Windows VM on Azure to use as my server if you are new to it or need to know how to create one you can check out this video which is mentioned above in that video as well I have used a Windows am and explained how to create one so let's connect to the server here we will use the standard RDP connection to connect to the ser [Music] I've connected to my server let's first install the required net version so the code which I'm going to build is is relatively older code on net 6 so we will install net 6 we'll just come to downloads and we look for an older version let's go to net 6 and install Windows x64 SDK so for building the code we will need the SDK if it was to run U an application the runtime would have been sufficient I'll just quickly run the installer and install the SDK we click install installed now that the required dependency is installed let's come to the main event that is installing our agent so for that let's come back to R devops and this is the project which I will be deploying uh using this agent and this has been the same project I have been using in the previous videos uh related to a devops so to install a new agent we'll have to download the agent we can click on this project settings bottom and then come to agent pools if we come to agent pools you can see the already configured agent pools which are using the Microsoft hosted agents to add a new pool we'll click add pool and we have to mention what type of agent we will have in that pool so we select selfhosted and let's call the agent pool as self hosted agents we Grant access to pipelines and create it so now let's open it and let's click on this new agent so this gives you three options Windows Mac OS or Linux so Mac OS would work on if you have a Mac machine you can use that or if you have a Linux server you can use the Linux agent we have a Windows Server so we'll be using the windows agent so let's click on download to download the agent so let's save it let's copy this agent and put it in our agent server we could have opened the same portal here as well but that's fine okay so we have copied the agent let's extract it and maybe to C drive [Music] agent it's exported to our agent folder now let's open command prompt and start it as an administrator and let's go to the agent folder and all we have to do is run the config command so here it will ask for the server URL so for that we have to come back to devops portal and just copy the URL till the part of your organization name so whatever is your devops url azard devops server URL like if you're using azard devops Services then it is dev. a.com and then SL you would have an organization name so we have to only copy till that part and that is our server URL and the authentication type so here it's asking press enter for Pat so Pat is personal access token so we'll be using Pat so for that let's come to our account come to personal access tokens and let's create a new token call it s posted agent maybe keep it valid for 90 days and here if you come you if you click on all Scopes show all Scopes here at the bottom we have to select in a pools read and and read manage and we have to copy this value mentioned here make sure you copy it and keep it safe because as your devous will not show this value again so let me just put it somewhere safely and close let's come back to our server and yes we want to use Pat so let's press enter and this just paste the personal access token you can just right click and it would if you have copied the personal access token it will just paste it now we have to mention the agent pool name let's come back here and this is the name of our agent self hosted agent so let's put the name of the agent pool and whatever name we want to give so I can also press enter and it would pick the server name as the name of the agent so to make it simple let's keep it the same and now it is scanning and then setting up the agent so you can specify what you want to call the work folder for your agent so work folder is the folder used by the agent whenever it is building your source code so we'll just press enter to use the default and whether we want the agent to run as a service we want to do run it as a service yes to enter enable service type we'll just make it yes and we want whether we want the user account to use the user account we want to use for the service is n Authority network service and next is enter weather to prevent the service starting immediately medely after configuration is finished no we want the service to start so with that our agent is set up which was not very difficult and let's see if our agent is connected to a devs or not now if we come to the agents tab you can see that our server is online and the agent version is mentioned here so now agent our agent is set up so let's go back to the pipelines and try to run it using this one so we'll edit it so here on this pipeline we have yaml file which is using templates so let's jump to individual templates and update the pool name let's use name as the self hosted agent so that's our pool name and save it so now for our build process we have defined the self hosted agent so let's see how it works out let's open this so now since it is the first run it is downloading all the required tasks which it needs to run on our agent it's almost done with the build and it is publishing the artifact artifact staging directory that's it so build is completed using our selfhosted agent and if you see it has started with the next step since we didn't make any changes to the next stage it is still using a Microsoft hosted agent so even this can be done that in different stages you can use different agents and since Microsoft gives you one free agent one selfhosted free agent and one Microsoft hosted agent when you're using aure devop services so you can utilize both of them by using different agents in different stages so if you come to this pipelines and parallel jobs under project settings you can see that you know how much of uh free jobs are available for you so one parallel job is available with 1,00 minutes on as a Microsoft hosted agent and you have one selfhosted agent with no restrictions for minutes so the stages which are taking more time to build you can do it on your self hosted agents and then other things you could do with your Microsoft hosted agent even with the best setup issues can arise let's look at some problems and how to solve them when setting up aure devops agent if your agent isn't connecting to Azure devops check your network settings ensure that the server can reach Azure devops Services over the Internet also verify your firewall and proxy settings if applicable for build failures examine the build logs in detail look for errors related to dependencies environment configuration or script failures these logs are invaluable for pinpointing the source of the problem if you have installed any new dependencies make sure that you restart the agent on the services window if your agent is slow or unresponsive check the server's resource utilization overutilization can lead to Performance issues consider scaling your server's resources or optimizing your build process now it's important also to maintain your agent keep your server and agent software up to date this ensures compatibility and security regularly check the health and status of your agent set up alerts for any critical issues always back up your agent configurations in case of server failures this will allow you to quickly set up the agent use a dedicated service account with limited Provisions for running the agent this enhances security setting up a self-hosted agent might seem daunting at first but as you have seen it's a process filled with valuable learning opportunities not only does it give you more control over your builds and deployments but it also enhan enhances your overall devop skills try setting up your own self-hosted agent use this video as a guide and don't hesitate to experiment make sure you install all required dependencies to run the build successfully if you have any questions thoughts or experiences you would like to share please leave them in the comment section below your feedback not only helps me create better content but also helps others who might be facing similar challenges you can also find the link to the source code in the description box below if you find this video helpful please give it a thumbs up and consider subscribing to Omega CeX if you haven't done it already thanks for watching stay curious keep learning and I'll see you in the next video adios
Info
Channel: OmegaCodex
Views: 389
Rating: undefined out of 5
Keywords: azure agent pool, azure devops, azure devops agent install, azure devops agent pool, azure devops agent setup, azure devops pipeline, azure devops pipeline self hosted agent, azure devops tutorial, cicd, education, how to add self hosted agent, how to create self hosted agent azure devops, omegacodex, self hosted, self hosted agent, self hosted agent azure devops, self hosted agent azure devops windows, self hosted agent pool azure devops, software development, windows server
Id: mBcWoMsXF7U
Channel Id: undefined
Length: 14min 45sec (885 seconds)
Published: Sat Dec 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.