Welcome!

Java IoT Authors: APM Blog, Stackify Blog, XebiaLabs Blog, Liz McMillan, William Schmarzo

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
In his session at 21st Cloud Expo, Carl J. Levine, Senior Technical Evangelist for NS1, will objectively discuss how DNS is used to solve Digital Transformation challenges in large SaaS applications, CDNs, AdTech platforms, and other demanding use cases. Carl J. Levine is the Senior Technical Evangelist for NS1. A veteran of the Internet Infrastructure space, he has over a decade of experience with startups, networking protocols and Internet infrastructure, combined with the unique ability to it...
"There's plenty of bandwidth out there but it's never in the right place. So what Cedexis does is uses data to work out the best pathways to get data from the origin to the person who wants to get it," explained Simon Jones, Evangelist and Head of Marketing at Cedexis, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
Large industrial manufacturing organizations are adopting the agile principles of cloud software companies. The industrial manufacturing development process has not scaled over time. Now that design CAD teams are geographically distributed, centralizing their work is key. With large multi-gigabyte projects, outdated tools have stifled industrial team agility, time-to-market milestones, and impacted P&L stakeholders.
Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
"Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
"IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
"Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
SYS-CON Events announced today that Evatronix 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. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
Leading companies, from the Global Fortune 500 to the smallest companies, are adopting hybrid cloud as the path to business advantage. Hybrid cloud depends on cloud services and on-premises infrastructure working in unison. Successful implementations require new levels of data mobility, enabled by an automated and seamless flow across on-premises and cloud resources. In his general session at 21st Cloud Expo, Greg Tevis, an IBM Storage Software Technical Strategist and Customer Solution Architec...
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
An increasing number of companies are creating products that combine data with analytical capabilities. Running interactive queries on Big Data requires complex architectures to store and query data effectively, typically involving data streams, an choosing efficient file format/database and multiple independent systems that are tied together through custom-engineered pipelines. In his session at @BigDataExpo at @ThingsExpo, Tomer Levi, a senior software engineer at Intel’s Advanced Analytics gr...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things’). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing? IoT is not about the devices, it’s about the data consumed and generated. The devices are tools, mechanisms, conduits. In his session at Internet of Things at Cloud Expo | DXWor...