Welcome!

Microsoft Cloud Authors: Janakiram MSV, Yeshim Deniz, David H Deans, Andreas Grabner, Stackify Blog

Related Topics: Microsoft Cloud, Java IoT, Microservices Expo, Linux Containers, Agile Computing, @DevOpsSummit

Microsoft Cloud: Article

What Should Be in Your .NET Toolkit? [#DotNet]

The easiest way to cover the list of deployment steps and the best tools to use

These days, implementing automatic deployment for .NET web projects is easier than ever. Drastic improvements started in Visual Studio 2010 when basic deployment strategies and tools were incorporated into VS itself. Yet, documentation was quite poor at that time, so you had to scour the Internet to find good tutorials in blogs or conference videos. Things have been constantly improving since then; now, we have even more functionality available out-of-the-box and documentation provided in a way that allows you to get started from zero understanding of the process to working deployment in less than two days. Some good places to start are this tutorial for an end-to-end guide on configuration and MSDN's overview.

In this article, I will show you the easiest way to cover the list of deployment steps and the best tools to use.

Trigger your deployment from build server
Whatever build server you're using for doing continuous integration (CI), it is an ideal tool to trigger your deployments, as it provides core benefits of audit (you always know who/when triggered deployment at which version). Just set up deployment build plans for each platform to which you want to deploy. The amount of deployment planning largely depends on branching and application lifecycle management (ALM) strategies you employ. For example, you could have something like the following:

  • Integration - Builds from master branch to deploy to integration platform where UI tests are executed as of the latest developed source code. Triggers whenever a new set of commits appears in the repository.
  • QA - Builds from master branch to deploy new features to QA environment whenever QA and Dev teams agree they need a new version validated. Triggered manually.
  • Release - Builds from a particular commit of master branch to deliver a validated version of the application to production environment.

You will want to add similar build plans for release or feature branches if you are using them in your workflow. You could also add a nightly build plan to deliver a nightly version of your application for preview (this is what we do when stakeholders need better visibility of the progress to get faster feedback without distracting the team).

A build server guarantees that a build plan is triggered on the source code exactly as of specific commit, so you're safe from "wrong source code version deployed" kind of errors.

Deployment out-of-the-box (configuring deployment in several clicks)
Visual Studio and MSBuild teams have been working hard to make the deployment experience a smooth one in the past few years, and we have some pretty neat features these days as a result (for example, you can configure basic auto-deployment in a few steps).

Visual Studio has a concept of publish profiles. In a nutshell, a publish profile is a versioned (you should store it in the repository) XML file that holds information about the destination environment and deployment settings. In a simple scenario, you'll have a publish profile for each of your platforms.

Right-click your project in solution explorer and go to the publish dialog:

You can add a publish profile using manage profiles dialog (this is what you do for your on-premises environments). Just fill in WebDeploy endpoint address and password - and you're done.

For those using Azure: ready-to-use publish profiles can be downloaded directly from Azure, which is even easier.

Now check-in your freshly generated profile and modify your deployment build plan to execute the following:

Msbuild.exe Web.csproj /p:DeployOnBuild=true /p:Configuration=Release /p:PublishProfile=staging /p:Password=p0ssw0rd

And you're done. MSBuild will take care of building your application in the desired configuration (release) and publishing it to the desired environment (staging in this case).

You can extend/customize packaging to address your specific needs (e.g., do not Remove /Uploads folder). Check out Sayed Hashimi's blog for some interesting examples.

Version your configuration
One of the most frequent deployment errors when done manually is incorrect configuration. Connection strings, timeouts, custom errors, external services endpoints, and much more can be different in production compared to development; moreover, configuration evolves along with the application, so every time a new version arrives to production, intelligent merge of dev and production config files is required. I don't know a single dev/ops person who likes merging these files by hand. If you're still doing that, stop it now. You can spend your time doing something much more useful. Config transformations to the rescue.

Config transformations have been introduced in VS 2010. Essentially, config transformation is a simplified version of xslt to transform your .config files in an efficient way. A transformation is just another .config file sitting next to your original .config file and applied upon publish. Transformation files use a very simple language.

You can have configuration-specific (release/debug) and publish-profile-specific (QA/production) transformations. MSBuild chains transformation files so that first configuration-specific transformation is applied and then profile-specific transformations finish the job:

For example:

  • Configuration-specific transformation turns on custom errors for release (needed in release regardless of the environment used);
  • Publish-profile-specific transformation changes connect strings (which are different across different environments).

Now your process of configuration maintenance is simple and defined:

  • Production configuration is always built automatically from dev configuration;
  • Transformations are versioned in the version control system and evolve naturally with source code and dev configuration changes.

No more manual merging of dev and production configuration. No more storing of configuration changes in emails/wiki pages. No more headache.

Database updates
Your database changes as your source code changes, so it makes perfect sense to version both together (otherwise they will get out of sync at some point). There are a couple of ways to do so, but these days, most of our teams tend to use migration frameworks (as they provide fine-grained control over what's happening). We have plenty of migration frameworks for .NET (e.g., FluentMigrator, EntityFramework migrations); simply use the one you like most.

Migrations can be configured to update the database on the first use (when application starts), or you can execute a console migrations runner in your migration script. While the former option is easier, I strongly recommend the latter (running database migrations as part of you deployment script), as this allows you to detect errors before users hit your application.

To do this, just add this to your deployment build:

Migrate.exe MyMvcApplication.dll /startupConfigurationFile="..\web.config"

Deployment scripting with MSBuild
MSBuild is your best friend in executing all those deployment steps. It has some built-in capabilities to copy files, run executables and manage configuration properties. For example, use WebDeploy client to control IIS (recycle ApplicationPool, take the application offline before deployment, bring it online after deployment).

Use extension libraries to do the rest (set ACL, backup database, etc):

For example, use the SqlExecute task to back up the database before deployment. Or use a folder task to set ACL permissions to the uploads folder. Check out the list of tasks in these libraries, and you can do pretty much everything your deployment process requires without much effort so that no manual interaction is needed.

Summary
Every new practice takes time to adopt, but with modern tools, implementing automatic deployment can be quite easy. If you're sold on the idea but are unsure on where to start (or can't sell it to your manager), I suggest you to start with automating QA builds, as they require less custom steps (e.g. you don't' necessarily need to take the application down during QA deployment). Once this is in place, you'll have the proof you need to confidently expand deployment to production.

More Stories By Ivan Antsipau

Ivan Antsipau is a senior .NET developer at Itransition specializing in architecting and implementation of business-specific web applications. With a specialist degree in Radiophysics and Computer Science, a knack for team leading, and years of hands-on programming experience under his belt, he sees the key to sustainable and accelerated delivery of software projects in elimination of stressful manual efforts with the help of continuous integration and automated testing.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, discussed how they built...
In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
DevOps at Cloud Expo – being held June 5-7, 2018, at the Javits Center in New York, NY – announces that its Call for Papers is open. Born out of proven success in agile development, cloud computing, and process automation, DevOps is a macro trend you cannot afford to miss. From showcase success stories from early adopters and web-scale businesses, DevOps is expanding to organizations of all sizes, including the world's largest enterprises – and delivering real results. Among the proven benefits,...
@DevOpsSummit at Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, is co-located with 22nd Cloud Expo | 1st DXWorld Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait...
Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will be held June 5-7, 2018, at the Javits Center in New York City, and November 6-8, 2018, at the Santa Clara Convention Center, Santa Clara, CA. Digital Transformation (DX) is a major focus with the introduction of DX Expo within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive ov...
SYS-CON Events announced today that T-Mobile exhibited at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. As America's Un-carrier, T-Mobile US, Inc., is redefining the way consumers and businesses buy wireless services through leading product and service innovation. The Company's advanced nationwide 4G LTE network delivers outstanding wireless experiences to 67.4 million customers who are unwilling to compromise on qua...
SYS-CON Events announced today that Cedexis will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Cedexis is the leader in data-driven enterprise global traffic management. Whether optimizing traffic through datacenters, clouds, CDNs, or any combination, Cedexis solutions drive quality and cost-effectiveness. For more information, please visit https://www.cedexis.com.
SYS-CON Events announced today that Google Cloud has been named “Keynote Sponsor” of SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Companies come to Google Cloud to transform their businesses. Google Cloud’s comprehensive portfolio – from infrastructure to apps to devices – helps enterprises innovate faster, scale smarter, stay secure, and do more with data than ever before.
SYS-CON Events announced today that Vivint to exhibit at SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California. As a leading smart home technology provider, Vivint offers home security, energy management, home automation, local cloud storage, and high-speed Internet solutions to more than one million customers throughout the United States and Canada. The end result is a smart home solution that sav...
SYS-CON Events announced today that Opsani will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Opsani is the leading provider of deployment automation systems for running and scaling traditional enterprise applications on container infrastructure.
SYS-CON Events announced today that Nirmata will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Nirmata provides a comprehensive platform, for deploying, operating, and optimizing containerized applications across clouds, powered by Kubernetes. Nirmata empowers enterprise DevOps teams by fully automating the complex operations and management of application containers and its underlying ...
SYS-CON Events announced today that Opsani to exhibit at SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California. Opsani is creating the next generation of automated continuous deployment tools designed specifically for containers. How is continuous deployment different from continuous integration and continuous delivery? CI/CD tools provide build and test. Continuous Deployment is the means by which...