Welcome!

Java IoT Authors: Pat Romanski, Liz McMillan, Yeshim Deniz, Elizabeth White, Frank Lupo

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
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
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 ...
SYS-CON Events announced today that mruby Forum will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. mruby is the lightweight implementation of the Ruby language. We introduce mruby and the mruby IoT framework that enhances development productivity. For more information, visit http://forum.mruby.org/.
Digital transformation is changing the face of business. The IDC predicts that enterprises will commit to a massive new scale of digital transformation, to stake out leadership positions in the "digital transformation economy." Accordingly, attendees at the upcoming Cloud Expo | @ThingsExpo at the Santa Clara Convention Center in Santa Clara, CA, Oct 31-Nov 2, will find fresh new content in a new track called Enterprise Cloud & Digital Transformation.
Most technology leaders, contemporary and from the hardware era, are reshaping their businesses to do software. They hope to capture value from emerging technologies such as IoT, SDN, and AI. Ultimately, irrespective of the vertical, it is about deriving value from independent software applications participating in an ecosystem as one comprehensive solution. In his session at @ThingsExpo, Kausik Sridhar, founder and CTO of Pulzze Systems, will discuss how given the magnitude of today's applicati...
SYS-CON Events announced today that NetApp has been named “Bronze 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. NetApp is the data authority for hybrid cloud. NetApp provides a full range of hybrid cloud data services that simplify management of applications and data across cloud and on-premises environments to accelerate digital transformation. Together with their partners, NetApp emp...
In a recent survey, Sumo Logic surveyed 1,500 customers who employ cloud services such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP). According to the survey, a quarter of the respondents have already deployed Docker containers and nearly as many (23 percent) are employing the AWS Lambda serverless computing framework. It’s clear: serverless is here to stay. The adoption does come with some needed changes, within both application development and operations. Tha...
SYS-CON Events announced today that Avere Systems, a leading provider of enterprise storage for the hybrid cloud, 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. Avere delivers a more modern architectural approach to storage that doesn't require the overprovisioning of storage capacity to achieve performance, overspending on expensive storage media for inactive data or the overbui...
SYS-CON Events announced today that Avere Systems, a leading provider of hybrid cloud enablement solutions, 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. Avere Systems was created by file systems experts determined to reinvent storage by changing the way enterprises thought about and bought storage resources. With decades of experience behind the company’s founders, Avere got its ...
Amazon is pursuing new markets and disrupting industries at an incredible pace. Almost every industry seems to be in its crosshairs. Companies and industries that once thought they were safe are now worried about being “Amazoned.”. The new watch word should be “Be afraid. Be very afraid.” In his session 21st Cloud Expo, Chris Kocher, a co-founder of Grey Heron, will address questions such as: What new areas is Amazon disrupting? How are they doing this? Where are they likely to go? What are th...
As hybrid cloud becomes the de-facto standard mode of operation for most enterprises, new challenges arise on how to efficiently and economically share data across environments. In his session at 21st Cloud Expo, Dr. Allon Cohen, VP of Product at Elastifile, will explore new techniques and best practices that help enterprise IT benefit from the advantages of hybrid cloud environments by enabling data availability for both legacy enterprise and cloud-native mission critical applications. By rev...
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, will discuss how they b...
SYS-CON Events announced today that SkyScale 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. SkyScale is a world-class provider of cloud-based, ultra-fast multi-GPU hardware platforms for lease to customers desiring the fastest performance available as a service anywhere in the world. SkyScale builds, configures, and manages dedicated systems strategically located in maximum-security...
High-velocity engineering teams are applying not only continuous delivery processes, but also lessons in experimentation from established leaders like Amazon, Netflix, and Facebook. These companies have made experimentation a foundation for their release processes, allowing them to try out major feature releases and redesigns within smaller groups before making them broadly available. In his session at 21st Cloud Expo, Brian Lucas, Senior Staff Engineer at Optimizely, will discuss how by using...
In this strange new world where more and more power is drawn from business technology, companies are effectively straddling two paths on the road to innovation and transformation into digital enterprises. The first path is the heritage trail – with “legacy” technology forming the background. Here, extant technologies are transformed by core IT teams to provide more API-driven approaches. Legacy systems can restrict companies that are transitioning into digital enterprises. To truly become a lead...
SYS-CON Events announced today that Daiya Industry will exhibit at the Japanese Pavilion 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. Ruby Development Inc. builds new services in short period of time and provides a continuous support of those services based on Ruby on Rails. For more information, please visit https://github.com/RubyDevInc.
As businesses evolve, they need technology that is simple to help them succeed today and flexible enough to help them build for tomorrow. Chrome is fit for the workplace of the future — providing a secure, consistent user experience across a range of devices that can be used anywhere. In her session at 21st Cloud Expo, Vidya Nagarajan, a Senior Product Manager at Google, will take a look at various options as to how ChromeOS can be leveraged to interact with people on the devices, and formats th...
SYS-CON Events announced today that Yuasa System will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. Yuasa System is introducing a multi-purpose endurance testing system for flexible displays, OLED devices, flexible substrates, flat cables, and films in smartphones, wearables, automobiles, and healthcare.
Organizations do not need a Big Data strategy; they need a business strategy that incorporates Big Data. Most organizations lack a road map for using Big Data to optimize key business processes, deliver a differentiated customer experience, or uncover new business opportunities. They do not understand what’s possible with respect to integrating Big Data into the business model.
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities – ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups. As a result, many firms employ new business models that place enormous impor...