Azure App Service is HTTP-based service for hosting web applications, REST APIs, and mobile back ends. It enables you to build and host applications in the programming language of your choice without worrying about infrastructure. Apart from deployment this service comes with many other useful functionalities too, such as security, load balancing, autoscaling, DevOps etc. In this blog we will deploy a web application in Azure App service using capabilities of Azure DevOps.
So Exactly What we are going to do -
We will build a basic CI/CD pipeline to deploy a simple ASP.NET website in Azure WebApp via using Azure DevOps pipeline.
What you need to start -
- Azure Cloud Account [I am using Azure Cloud free tier]
- Azure DevOps [https://azure.microsoft.com/en-gb/services/devops/]
Stage -1 — Prepare Environment
In App Service (Web Apps, API Apps, or Mobile Apps), an app always runs in an App Service plan. (The compute resources you use are determined by the App Service plan.) So to deploy ASP.NET Website, we need to add a plan in our Azure Subscription. This can be done via Az CLI / Azure Cloud Console or via ARM Templates. Choice is yours.
Please note the available SKU and size plays an important role !
Once you are done, you can see something like this. This confirms that Azure App service plan is available to use.
Now We will add WebApp in this. Web App as a service we will use for deployment of our website. Check on the right hand side the spec of deployment. This is important and I suggest spend some time to understand the features of Azure App Service.
Once Azure Web App is deployed you can see details about your deployment. This will show the URL of your website too. Please note you can select your domain as well.
Did you notice how easy it was ! In minutes you have a complete environment which can support deployment of your ASP.NET website. The same mechanism can be used for other type of apps as well. eg: JAVA, Python, NodeJS etc
Stage -2 — Prepare Azure DevOps and Dummy WebSite
Login in you Azure DevOps portal — https://dev.azure.com/<organisation>
Create a project if it does not exist. This project will hold our repository and other artifacts if required.
Create a sample ASP.NET Website using Visual Studio and upload the code in repository. Now we will organise couple of things. Like we will create service connections for Azure Subscription which we will use in Pipeline to connect with Azure Cloud for using app service.
Stage -3 — Prepare Build and Deployment Pipeline
Now the last step !
We will use Azure DevOps YAML based pipeline instead of Azure Classic pipeline.
This pipeline will be based of two stages. First stage for Build and Second stage of Deployment.
I have attached gist for complete pipeline in this post. If you look Build Stage, it has 1 job and few steps. In these steps I am performing build and publishing the artifact for deployment stage.
# Task for Build- task: VSBuild@1
configuration: ''# Task for Publish- task: PublishBuildArtifacts@1
Now in deployment stage I am using the service connection which we created earlier to connect with Azure Cloud and perform the deployment in Specific WebApp. Please note before that I am also downloading the artifacts from previous stage.
The important point of this stage is that instead of using standard job, I am using deployment Job. Deployment Job is new concept of Azure DevOps and provide many features. This Job allow us to use another linked concept of Azure DevOps Environment .
Azure DevOps Deployment Job and Environment provide complete package of deployment !
That’s It, Lets run it.
Both Stages are successful and we can find details in pipeline. We can see, it has published artifact as well.
We can track this deployment in Azure DevOps Environment as well. Concept of Environment provides powerful features. Few of them are —
- Deployment history
- Traceability of commits and work items
- Diagnose resource health
That’s it for this post. We will discuss more on this pipeline in next post.
Thanks and Keep Learning !
Deployment jobs - Azure Pipelines
Important Job and stage names cannot contain keywords (example: deployment). Each job in a stage must have a unique…