Intro
One facet of Azure that many developers have found increasingly practical is Continuous Deployment. Conversely, Continuous Deployment has proved to be quite challenging to execute correctly. Fortunately, while proper continuous Deployment (including unit tests) is a time-consuming job to set up, this post will explain how to create a simple Continuous Deployment using Microsoft Azure’s App Service.
An Introduction to Continuous Deployment
Continuous Deployment is an integral part of their development cycle and a handy, time-saving tool for many software engineers. Continuous Integration and Continuous Deployment is a practice that allows multiple developers to spend more time developing and less time having to wrestle with delivering those changes to the world. Unfortunately, while many developers may know how to set up and use version control tools such as Git or TFS (Microsoft’s Team Foundation Server) to facilitate their Continuous Integration practices, not everyone has the same knowledge of setting up Continuous Deployment. This is understandable, as continuous Deployment is a hassle and time-consuming job. For many users, those are reasons enough to avoid spending time learning and setting it up.
Still, imagine three separate requests for changes come in, with each change requiring Deployment. That’s three different times the changes need to be published. Maybe the changes need to be published at the end when all changes are merged. Even so, the user must remember to post those changes. Not only does continuous Deployment remove the time needed to publish those changes manually, but it also reduces the chance of human error. Too bad it’s just such a hassle to set it up. Oh, wait, this blog post is supposed to show an easy way of doing it.
A Simple Solution
As stated in both the title and introduction, the solution uses Microsoft Azure, specifically Azure’s App Services, to implement a simple continuous deployment process. We need two tools: Azure and a source control such as Git. First, create or select an existing Azure App Service that will contain Continuous Deployment; for the purpose of this demonstration, I’ll be creating a new service using .Net 3. You could configure the continuous deployment process during the App Service creation step, but I’ll be configuring it after App Services is created for the sake of this exercise.
Continuous Deployment can be set up to skip Deployment if unit tests fail and/or if the unit tests do not pass a sufficient percentage of code coverage.
Next, click the App Services to use Continuous Deployment and go to the Deployment Center tab. Here you can select where your source code resides. I’ll be using Github. Microsoft will ask you to authorize the connection if you are using third-party source control such as Github or Bitbucket.
Select the organization, repository, and branch where your code resides, and choose “Add a workflow” for the “Workflow Option” section. Doing so will create a file that includes what steps should occur during the deployment process. The default workflow file will build the project and deploy it to the web. Finally, double-check to ensure the Runtime stack matches the source code’s framework and click Save up at the top.
That’s it. Let me reiterate. That’s it. Continuous Deployment should (assuming the connection was successful) be complete. But let’s go to Github to make sure. Go to the Actions tab of the selected repository. If configured correctly, a new workflow run titled “Add or update the Azure App Service…” should appear. If a green check appears next to said item, it means a simple Continuous Deployment has successfully been set up. Congratulations!
Test Continuous Deployment by pushing a change to your repository! Although simple, the workflow item can be drilled into to see what happens during the build and deployment process, and if unsuccessful, will show where the process failed.
Pros and Cons
I mentioned this before, but proper Continuous Deployment is time-consuming, but as shown in this blog, a simple Continuous Deployment can be easy to set up. Adding Continuous Deployment removes the hassle of manually deploying changes, not to mention time-saving. But this setup does contain some downsides. Firstly, Azure is not entirely free. I say not entirely because the Azure service could be free depending on the plan (based on location, features, and resources used). Here’s a link to Microsoft’s App Service pricing.
This process does not include advanced deployment steps such as unit testing. It is recommended to have unit tests to ensure the newly committed changes do not break existing functionality and make sure new functionality is working as expected. Continuous Deployment can be set up to skip Deployment if unit tests fail and/or if the unit tests do not pass a sufficient percentage of code coverage. The steps shown in this blog do not include unit tests or code coverage during the deployment process, but it IS possible. During the setup process, I mentioned you should select “Add a Workflow.” You can either modify the newly created .yml file or instead select “Use Available Workflow” to use an existing workflow file and include unit tests and code coverage during the deployment process. Unfortunately, modifying said workflow file to include those steps is outside the scope of this post. Follow up with Tallan for more info on Azure cloud services!
Conclusion
Look, Continuous Deployment looks challenging to set up, but it’s undoubtedly a valuable process to have for software engineers that will save a lot of time in the long run. The steps described here may not be perfect, but it is a fast and easy way to help kickstart the process — Test it out with your own project!
Tallan’s cloud infrastructure & security consulting services can assist your company with cloud migration, cloud adoption, and cloud application development using today’s most cutting-edge strategies & technologies. Click here to get started.