Wednesday 23 October 2024

Building and Deploying your Code with Azure Pipelines

hi my name is Abel and I'm a senior cloud developer advocate specializing in DevOps today I'm going to show you the ultimate DevOps tool for creating your own CI CD pipelines for any language targeting any platform I'm gonna be showing you a sure pipelines with Azure pipelines we've made it ridiculously simple to go from nothing at all to a new as your pipelines project see people have been telling us it's too complicated to get started with your DevOps tools and guess what we listen so let's go check this out let's say your code is sitting somewhere like on github and you don't have an azure DevOps account and now you want to create a CI CD pipeline well just go to this landing page click on start free with pipelines and it's going to create for you your own organization where now all you have to do is jump in here type in your project name click create and bam that is all you need to do now when it's done creating the project you'll have an empty Asscher pipeline project like this so let's go ahead and create our first pipeline so we'll jump into our pipelines and we'll go ahead and create a brand new one and the very first thing it asks you is where is your code is it up and github is it in and Azure repos we also support tfv c and bitbucket cloud but for those you have to use the visual designer now my code is sitting out in github so let me go ahead and authorize with github and once it's done authorizing with github I'll be able to see all of my private repos and public repos out in my github account so let me choose my repo and now it's going to go and analyze the code and the technology used inside my repo and based on what it sees it's going to offer me a couple templates it just so happens my application is an asp.net app but if my repo held let's say no js' app running in a docker container guess what it will create for me a bill pipeline that makes sense for the technologies that we picked all right so now it's going to create for me my pipeline using a yamo file now I'm gonna go ahead and add a couple more tasks and basically the tasks that I'm gonna add I'm just gonna go ahead and copy my zip file that's created and deploy and take my build artifacts and publish them back up to Azure pipelines now once that's done let's go ahead and save and run this build and voila that is literally all we have to do and now it's kicked off our build so now it's gonna go ahead and spin up a build agent and it's gonna go ahead and build our application for us now it's going to download my code from github is gonna restore my packages from you get is gonna compile everything using Visual Studio it will go ahead and run my unit test right is this right here is just what we used to have in V STS now if you remember we defined this build using a yamo file if you guys like yamo files that's freaking awesome I love yamo files because pipeline s code what we're doing here this really speaks to the DevOps in me right however if you still want to define our builds or describe our builds using the visual editor you absolutely still can and hooray for that looks like our build has finished let's go ahead and jump into the summary where now you can see a timeline of everything that's happened during this build including all the tests that were run now notice the one thing that's missing is going to be where's my deployments well there are no deployments because we haven't created a release yet so let's go ahead and create a release for this build I'll go ahead and click on the release link and it will take me to the visual editor for the release pipeline now because I'm deploying into Azure it makes things insanely simple let's choose the azure app service deployment template click apply and hurray for that that's all we need to do now when you go and create a pipeline for your releases the first thing you have to do is you have to define your stages so we'll call this our staging and next you have to define what are the tasks that are going to run for this particular stage now everything is filled out for us because we're using a template but I do need to connect my accounts with my subscription so what I'm doing right now is I'm connecting my Asscher pipelines account to my Azure subscription once this is done we can go ahead and jump in here and select the app service that we're going to be deploying to in my case I am deploying to Azure DevOps launch now there's one other change that I want to make because this is my staging environment so I'm going to go ahead and deploy this into my slate staging slot so first I have to choose my resource group then I have to come in here and choose my staging slot now what if you wanted to do more than just deploy an app to Azure app service well to customize these release pipelines what you would do is add and remove tasks now out of the box as your pipeline gives you about a hundred tasks that you can just download and start using now if what you want to do doesn't exist out of the box it's not a big deal because go to the marketplace in the marketplace our partners have created over 700 build and release tasks that you can just download and start using now if what you want to do doesn't exist in the marketplace and doesn't exist out-of-the-box guess what you can create your own custom tests as well custom tasks those are nothing more than PowerShell or no js' so what that means is anything you can do from the command line you can easily get Azure pipelines to do as well all right so we've created a really small pipeline right we're just deploying into one staging environment let's go ahead and look at this a little bit deeper because after you've created your stage and you've created the tasks that should run in your stage you have the ability to add approvers before and after each stage so let's go ahead and add a post deployment approver and I'm just going to add myself select that and you know what let's go ahead and clone this because I want to add a new stage I want to add a new stage where I can deploy to my production so we'll call this production and from here jump into the production tasks and I do need to make a couple of changes one of them that I'd need to make is instead of deploying to a slot this is production so I'm just going to deploy it to my app service itself so I'll go ahead and save this now and now let's go and release this I'll click on release click create and just like that I've created a release and now the release will start flowing through our staging environment and after I approve it it can flow all the way out into production easy peasy so there you go Azure pipelines for your code we've made it so simple to go from nothing to a full CI CD pipeline for any language targeting any platform and yes this is your code sitting in your repository of choice deploying to wherever you need it to be deployed it can be in Azure of course but it can also just as easily be behind your firewall in front of your firewall anywhere remember any language targeting any platform and not only that if you have an open source project guess what if you get all of this for free you get 10 parallel pipelines out-of-the-box and if you need more just ping us and we'll give you more so go and check out as your pipelines today by going to dev calm

No comments:

Post a Comment

Building Bots Part 1

it's about time we did a toolbox episode on BOTS hi welcome to visual studio toolbox I'm your host Robert green and jo...