Careers   |   Events   |   Contact   |   402.238.1399   |   contactus@deliveron.com

Deliveron
Connect with us on FacebookConnect with us on LinkedInFollow Us on Twitter

Category List


Tag List

Business (2)
microsoft test manager (2)
Automated Testing (10)
Office 365 (1)
Visual Studio Online (6)
action-filters (2)
zap (1)
reporting (2)
Build (6)
tags (2)
dependency-injection (2)
alerts (2)
AzureAD Admins (1)
asp.net-mvc (6)
nintex (4)
netstandard (2)
Cosmos DB (1)
visual studio (8)
test cases (2)
tokenization (1)
testing (5)
nebraska code camp (2)
dbpro (2)
lab environments (1)
connect() (1)
automatedui (1)
sharepoint 2010 (10)
business intelligence (2)
bundling (2)
event-handling (2)
team deploy (2)
Document (1)
react (1)
windows 8 store app (2)
sql server 2008 (2)
performance (3)
pipelines (1)
planning poker (4)
MFA (1)
whitesource (1)
ssrs (4)
TFS 2015 (6)
silverlight (2)
whitelist (1)
faq (2)
feedback (2)
Decisions (2)
artifacts (1)
alm (9)
ssl (1)
top 5 (1)
ssas (2)
xaml (2)
single page applicaiton (1)
test controller (2)
entity-framework (6)
webparts (2)
sharepoint (5)
azure mobile services (2)
data warehousing (2)
Functions (2)
example (2)
owasp (3)
ninject (2)
sql saturday (2)
team foundation server 11 beta (2)
Big Data (2)
AAD (2)
fields (2)
scrum (8)
github (1)
agile (12)
visual studio 11 beta (2)
home projects (1)
IntelliSense (1)
serverless (3)
opensource (1)
burndown (2)
alm rangers (1)
microsoft alm rangers (2)
Nuget (1)
PBI (1)
windows azure (2)
AzureAD (1)
exchange (2)
preview (1)
azure resource manager (1)
web application firewall (1)
visual studio 2010 (18)
tfs 2017 (1)
pdf (2)
tfs 2010 (2)
asp.net-mvc-3 (4)
business insight (2)
mstestv2 (1)
load tests (2)
test agent (2)
c# (13)
Keith Holt (1)
DevSecOps (2)
vsdbcmd (2)
Infrastructure (1)
Azure (14)
OAuth2 (1)
licensing (2)
application insights (2)
Template (1)
tls 1.2 (1)
onenote (4)
webcast (4)
code-first (4)
test automation (1)
sharepoint 2013 (6)
cascading-dropdown (2)
dns (2)
mvvm (2)
angular 2 (3)
performancepoint services (2)
my work (2)
HOLs (1)
Multi-Factor Authentication (1)
load testing (2)
ARM Template (1)
Quality (2)
continuous inegration (2)
user profiles (4)
coded ui tests (6)
tfs odata (2)
kanban (1)
powershell 2.0 (8)
2013 (2)
asp.net-mvc-4 (2)
continuous integration (2)
spc14 (4)
Azure Functions (1)
deliveron agile delivery process (2)
certificates (2)
webpack (1)
fluentvalidation (2)
wit (2)
release management (7)
web (1)
bi (2)
lync (2)
visual studio code (1)
Node.js (1)
requirements (2)
M Query (1)
Analytics (2)
team foundation server 2012 (4)
work item (2)
Web API (1)
power tools (2)
Mike Douglas (4)
storyboarding (2)
Power BI (3)
razor (4)
service-fabric (1)
MVP (2)
msi (2)
angular (1)
installation (2)
gulp (2)
json (2)
Collaboration (2)
rest assured (1)
CI (3)
outlook (2)
sharepoint 2007 (2)
javascript (3)
vsts (22)
association (1)
visual studio team services (1)
workflow (2)
database projects (4)
tfs 2013 (2)
Data Analytics (1)
team foundation 2012 (2)
gherkin (2)
database publishing wizard (2)
jquery (4)
selinium (1)
adfs (3)
team build (2)
API Tests (1)
lunch and learn (2)
web performance tests (2)
bdd (2)
sql server (2)
video (2)
lab management 2010 (2)
site collections (2)
MSBuild (1)
Visual Studio 2017 (4)
tips (2)
security (1)
team foundation server (6)
visual studio 2012 (10)
wiki (1)
Java (1)
webs (2)
sp1 (2)
REST (1)
microsoft case study (2)
tfs (11)
pipeline (1)
swagger (1)
DevOps (14)
TestArchitect (5)
tfs 2012 (4)
necc (2)
deployment (2)
asp.net-mvc-routing (2)
xunit (1)
table-valued-parameters (4)
team web access (2)
nunit (1)
web deploy (1)
insiders (1)
Powershell (1)
deliveron alm delivery guidance (2)
subsites (2)
selenium (4)
Meetings (1)

Archive

Azure DevOps Projects - Adding an Additional Environment

Jul 18, 2018

Are you wanting to use Azure and not sure where to start when it comes how to deploy and host your application?  New to a platform like Azure Kubernetes Service (AKS) and not sure what you have to do to go from repo to deployed application?  An Azure DevOps project is the perfect tool to get started with any Azure application.  With a few clicks, an Azure DevOps project will create a repo with a sample app, create a Visual Studio Team Services (VSTS) build and release pipeline, provision the environment, and provide an application dashboard site in Azure.

My two top reasons for using Azure DevOps projects

  1. Quick start and learn how to deploy most common types of applications to Azure with VSTS
  2. Provide foundation for building out the full CI/CD pipeline for all environments

I think the tool does a great job with #1 and truly provides an easy and quick way to get any type of application started in Azure.   

As for #2, I know there are improvements coming but there are quite a few manual steps for adding additional environments.  This article  will discuss all of the steps to go from everything automatically created in one environment to being able to deploy to an additional environment.

What are Azure DevOps projects?

Azure DevOps projects are a resource in Azure that you configure to provision the resources in Azure and VSTS that you need for source control, CI builds, and CD pipeline with everything configured to deploy to the Azure resources.  I will highlight a couple aspects about Azure DevOps projects but refer to the Overview of Azure DevOps Projects for more information.

In the Azure Portal, when you choose to create a new DevOps Project, you will get the following dialog. Here you can choose from a number of sample projects or even use your own code base. If you are new to Azure or building CI/CD pipelines in VSTS, I recommend starting with their sample and then swapping you code in after the repo has been created. In this case I'm creating a .NET web application using ASP.NET hosted in a Web App and choosing those options in the next couple of screens.


new_devops_project.jpg

Once you have choosen the type of application to use, you then select the VSTS account and Azure configuration.
TIP - Use the "Change" link to display additional Azure configurations including changing the pricing tier from Standard to D1 Shared.

devops_project_creation_azure.jpg

 

After you confirm these settings, the provisioning process will begin.  This takes longer than other resources because it isn't just provisioning the Azure infrastructure, this is also creating the VSTS resources including the Git Repo, CI Build, and Release pipeline.  Once the pipeline succeeds everything will be provisioned and the application will be deployed.  The Azure DevOps project provides a nice dashboard of the major aspects of your application including the CI/CD Pipeline, Azure resources, and Application Insights.

azure_devops_project_dashboard.jpg

 

Adding Additional Environments

My favorite feature of Azure DevOps project is that all of the artifacts it creates are standard items in Azure and VSTS.  This means that none of this is magic and isn't a black box that can't be customized.  This allows the you to use Azure DevOps projects to achieve the goals I outlined at the beginning.  At the very least, you can use it to learn how all the pieces work together and how to deploy a particular application type.

More importantly, I want to use this as the foundation for the rest of my CI/CD Pipeline.  So I will walk through what is needed to add an additional environment for an ASP.NET web app.

Dev Environment Changes

The end result of the Azure DevOps project deployment is deployment to the Dev environment.  However, we are going to rename this in the CI/CD pipeline to production, so name  the resources when creating the Azure DevOps project like it is production.  This allows the application focused resources to be production scoped instead of dev only. 

The CI/CD pipeline currently deploys the app but doesn't provision the infrastructure.  This is the first thing to add.  Each environment deployment should be responsible provisioning the infrastructure and deploying the application. The ARM template is included in the repo for web app, however it doesn't include the environment parameters.  

Clone Repo

Clone the repo that was created for you during the Azure DevOps project creation.  This will allow us to add the files we need and commit them to the remote repo.  To add the environment parameter files, we need to identify what they are currently set to.  The template will have a list of parameters but to see the values, we can find the actual values in the portal under deployments.

arm_template_parameters.jpg

 

Add the environments parameters files

Create prod and test environment parameter files.  Using the values (minus the skuCode setting) from template settings in the portal above.  Properties should match.

arm_template_environment_parameter_files.jpg

 

Commit the changes and push these files to the Git remote repo.  This will kick off the CI/CD process but because we haven't updated that yet, nothing will be updated.

Update CI Build to publish ARM Templates

The build publishes the application but doesn't include the ARM template and config.  Add an additional publish task and upload the ARM artifacts.  Save and queue a new build to add the files to the artifacts.

devops_ci_build_publish_arm_artifacts.jpg

 

Edit Release Definition - Add Infrastructure task

First rename the Dev environment in the release to production.  Now that the environment config files are part of the build artifacts, add an Azure Resource Manager task to the Prod environment to publish the infrastructure.  Since Prod is already deployed, technically this should do nothing but will be required for deploying to the test environment.  Unfortunately the service endpoint created by the Azure DevOps project was scoped to the website.  Typically these are created at the resource group level or for a group of resource groups.  In this case let's create a new one scoped to our resource group.  One the Azure Subscription item, click Manage.  Choose New Service Endpoint > Azure Resource Manager.  Call it it something like "Your Project - Prod", and select your subscription and the resource group for this project.

 

Use this new connection for the Azure subscription setting.  The resource group should show up in the Resource group list.  Location should be the same as what you originally selected when creating the DevOps project.

For the Template setting, use the ellipsis to open the Linked Artifacts dialog and choose the newly added ARM template files.  Choose the template JSON file.  Repeat the project for the Template parameters to add the prod JSON parameters.

vsts_select_arm_artifact.jpg

 

Now that the template and parameters have been selected, here is what the task should look like.

vsts_release_add_infrastructure_task.jpg

Save the release definition and queue a new release to verify the infrastructure deploys correctly.  Again for Prod, the deployment should detect that the infrastructure is already deployed and do nothing.  

Adding Test Environment

Now that the Prod environment is deploying both the infrastructure and the application, we want to repeat this process for test.  Release management provides a clone environment option to quickly repeat the all of the steps from the previous environment.  This is exactly what we want to do.  In the pipeline view, choose the clone option and rename the environment to Test. Next switch the environments so Test comes before Prod.  To do this, click on the Pre-deployment conditions for Prod and select After Release.  Then change Prod to After environment and select Test.  It should look like the image below.

vsts_swap_environments.jpg

Update the following to point to the test environment

  • Azure subscription - we will need to create a new service endpoint connection this time to the test resource group. This resource group doesn't exist yet, so you will need to open the Azure portal and create an empty resource group before you can create the endpoint. You could create the service endpoint at the subscription level but I like making it more specific so each pipeline doesn't accidently deploy to a wrong resource group.
  • Resource group - choose the test resource group to the newly created test resource group
  • Template parameters - update this value to the test JSON parameters file

Wrap up

The Azure DevOps portal is updated to reflect the new environments.  However it doesn't update any of the application resources that is why I wanted to treat the original resources created by the tool as production.  This is still an area I want to investigate to see if updating the ARM settings will show the application resources for all environments.  

devops_project_dashboard_testprod.jpg

There were are a few limitations that I noticed when using Azure DevOps projects

  • One DevOps project per Team Project
  • No built in support for additional environments and there are quite a few manual steps to do this
  • Azure infrastructure provisioning isn't using the ARM template in the VSTS CI/CD Pipeline

Here are some possible next steps to add to fully create your CI/CD Pipeline.

  • Branch Policies for Pull Requests - see Improve code quality with branch policies 
  • Add Production environment approval gate - Add a pre-deployment approval - See Release deployment control using approvals 
  • Parameterizing the application for each environment. Typically things like connection strings and other settings are environment specific. You can use the ARM template to set the app settings, web config parameterization, or several other techniques

That's it!  As you can see, by getting the items set up correctly, make adding additional environments quick and straight forward.  I hope you use the Azure DevOps projects to quickly get started.  As always feel free to discuss any questions or comments on Twitter at @mikedouglasdev



Category: DevOps

Mike Douglas

user_avatar

He is a solution consultant focused on helping organization build high quality application effectively utilizing DevOps practices. He is a Microsoft DevOps / ALM Ranger and you can reach him on Twitter at @mikedouglasdev


We believe in helping our customers create software solutions in a better way.
We do this by having a project delivery process and technology expertise that ensures we are solving the right problem in the right way and driving the most business value.