From the course: Azure DevOps: Continuous Delivery with YAML Pipelines

Deploying code - Azure Tutorial

From the course: Azure DevOps: Continuous Delivery with YAML Pipelines

Start my 1-month free trial

Deploying code

- [Instructor] Next we want to test the deployment of our code and we're going to do that using an Azure application service. We've got a template that I created in a project if I go out onto GitHub. I've got a shortcut that'll take us there. Here it is. It's the WebAppWithSlots. I've got a number of different templates that are in here. One is for Windows. One is for Linux. Because we're doing a full dot net project I'm going to use one for Windows, but I'm going to work with this inside the visual studio so that I have the code to use in my deployments later on. In my solution of visual studio, I'm going to go out and I'm going to right-click on it and I'm going to say add a new project and the project type I'm going to add is going to be a resource group project, so if I search for Azure Resource Group you'll see that it comes up. We'll add this. I'm going to call this myWebDeploy and I'm going to go ahead and say create and then it's going to ask me where I'm going to get my templates from. Now, normally visual studio has a number of templates. I've added my arm template library into it so I can go down and I can pull up that version of it and I can add it to my project. Now, once I do this I'm going to have to do one more thing and that is I'm going to add a file so they can use this and that's a perimeter file. Now, the Azure Deploy Perimeters file is something that needs to be marked as being content to be able to use it, and in myWebDeploy I can right-click, go out and do a new deployment, which then opens up a dialogue where I can put in the template that I want to use. I'm going to do this for Windows, not Linux, so we'll pick that one and then we'll edit the perimeters and we'll put in the name of this. I'm going to call this my bnkYAML app service and I'm going to deploy this out with a single slot for staging. We'll use that later on. When I click on deploy it goes out and starts a powershell deployment of that template into Azure. Now, we'll assume this is going to finish and I'm going to go into the pipeline and we'll add the code to the pipeline to deploy to it. So meanwhile, coming back into Azure DevOps and going out to where our pipeline is, we're going to right-click on this and go say Edit. This then brings us into where we can see our pipeline that we've built so far. We have our solution going out, does the NuGet. It replaces the tokens. Does the build and then publishes the artifacts. Now, what I would like to do is I would like to take this artifact staging directory and I would like to publish the code from that out to a web service, and so I'm going to come down and I'm going to add a step down here and if I scroll down you'll see that there is an app service deployment. Now, when I pick this I'm going to use a service connection going out to my subscription that I've got and I'm running the web app on Windows. Next I pick the service name I'm going to run to. That's the YAML service, and we'll scroll down and say let's go out and deploy this and we're just going to deploy it to bnkYAML for now. Go ahead and say Add, and this adds this. Now, one thing it does is it says Package and this is not a package going from Linux. It's a package coming from Windows, but in any case, the actual directory that this is going to be working from is going to be the build artifact staging directory. Now, I'm editing it inside of this because I selected the settings over here. When I click on Add it just updates this. I could easily have just gone ahead and just edited it here as well. We're going to go ahead and say Save and once we do, then I can click on Run to run our pipeline, and now it's going to go out and it will run that build and release. Now, we can click on the job and this will let us see that the application is running, and it'll take a few minutes to finish, usually about a minute and a half, but we can speed it up like we have before, and now that it's complete, I can go out here and I can actually browse to it. I can go to bnkYAML.azurewebsites.net and it should bring up our application. There's our build number. We're running on a app service machine. We're running dot net framework 4.7 and we're running in here.

Contents