CI/CD / Data / Development / DevOps

Visual Studio 2017 Offers Live Unit Testing, and DevOps for the Database

8 Mar 2017 11:35am, by

This week’s release of Visual Studio 2017 marks 20 years that software has been Microsoft’s flagship integrated development environment (IDE), and it might also mark the point when DevOps becomes truly mainstream.

Visual Studio still caters for a wide audience — from the hobby developers who use the free Community edition, to large outsourcing providers in India who need to distribute the software on DVD because their workplaces still don’t have internet connections, and to “super agile organizations who really are embracing the DevOps mentality,” Principal Program Manager for Visual Studio, Tim Sneath told The New Stack. “But we certainly see DevOps moving fast into the mainstream.”

DevOps is one of the key areas of focus for Visual Studio 2017, although Microsoft wants to make this about shifting right as well as the more usual “shift left” explained John Montgomery, the Director of Program Management for Visual Studio. “DevOps is still something that we’re learning about and getting better at [as an industry]. The end to end DevOps workflow is a pretty long flow; it starts with code editing, it goes all the way through the CI/CD pipeline and eventually comes out with an analytics service; the developer might look at the results of that and then go back to their editor.”

Live unit tests in Visual Studio are marked as passing and failing — and the dash shows code with no test coverage.

Tighter Loops

“‘Shift left’ takes all that stuff that’s happening later in the CI/CD pipeline and brings it back into the inner loop so the developer as they’re typing can start to see exactly what’s happening to their app — before check-in happens, before deployment happens. I think we can do better, to tighten that cycle so you can catch a bunch of issues before check-in and identify issues in production a lot faster, right in the code editing experience,” suggested Montgomery.

That includes tools in the editor like exception helpers that show root cause, live unit testing and code analysis into the editing experience. You can see as you edit your code whether you have full test coverage, or if a change you make to your code means it no longer passes a test, and instead of waiting until you build the project or check the code into your CI server to do static code analysis, you get hints and suggestions in the editor. Those can include team coding practices like using explicit types instead of ‘var’ (stored in the “EditorConfig” file in the repo for your project), as well as code suggestions that help you pick up language features like the new C# 7 syntax for throwing nulls, or tuples.

Suggestions can be based on team coding style.

Getting earlier visibility of problems that will affect deployment is only the first step. You also need the tooling to build the whole DevOps workflow. Visual Studio 2017 offers integration with other systems and services, from Microsoft’s own Xamarin Test Cloud (with real devices), Azure App Services for hosting mobile apps and Visual Studio Team Services (VSTS) for online team development, to Docker and Git, so you can containerize apps and auto-deploy from Git repositories.

You can do a lot more with Git from inside Visual Studio now; you can see the diff for outgoing commits, use a force push to complete a rebase or push an amended commit, remove your upstream branch, or continue patch rebase. That integration is now based on GIT.EXE Git core, so it supports SSH and keeps your existing configuration options.

Code suggestions help you pick up new language features.

DevOps increasingly means using open source code and external components. For Visual Studio 2017, Microsoft worked with WhiteSource to integrate its open source security and management service into VSTS (and the on-premise equivalent, Team Foundation Services) as a build task you can add to give you reports on any known vulnerabilities in open source components you’re relying on. (Visual Studio Enterprise subscribers can use WhiteSource Bolt on one project free for six months.)

For larger businesses who want all of this, Microsoft is bundling up Visual Studio, VSTS, the Azure services for CI/CD (including load testing, mobile app testing and WhiteSource Bolt), plus discounted Azure pricing, training as an Enterprise DevOps Accelerator; a sure sign that existing Microsoft customers are interested in adopting DevOps.

 

Devops for .NET

For Microsoft shops, it’s likely that Microsoft’s .NET and .NET Core will be a big part a big part of interest in DevOps.

Visual Studio is “cloud agnostic,” Montgomery promised, but he also noted the options Azure has for supporting .NET and .NET Core (which you can think of as a refactoring of .NET that fits in a lightweight Docker container and runs fast).

“When Visual Studio and .NET Core are deploying to Azure, we can do debugging and diagnostic magic. We can trace to the line of code of your faulting app in production. We can integrate App Insights telemetry back in the application without the developer having to write a single line of code.”

Using Azure App Services directly from Visual Studio, without having to go through the Azure portal, is only the first Connected Services option in Visual Studio 2017; Montgomery says there will be more. You can build containerized .NET and .NET Core applications using Docker containers for Windows and Linux from inside Visual Studio. Because Visual Studio knows you’re building a .NET app, it puts the ASP.NET image in the Docker file for you. You can even debug from Visual Studio on Windows into a Linux container, and deploy not just one container but multiple containers into an orchestrator. Even the build environment is supplied in a Docker image.

 

 

 

Covering the whole DevOps workflow is where the idea of “shift right” comes in. “’Shift right’ is the idea that building in quality from the very beginning is not enough,” explained Montgomery; “You need the continuous feedback from users that pulls all the process together; things like testing in production, and experimentation, and user telemetry collection.” They’re all “shift right” practices and Visual Studio is going to integrate more and more of them.

The Redgate tools included with Visual Studio 2017 make databases part of the DevOps workflow.

Database DevOps

One of the areas often left out of DevOps workflows is databases, but Visual Studio 2017 includes three tools to help you manage the DevOps cycle across databases as well. Redgate’s SQL Search tool, which helps you find SQL fragments and objects across multiple databases, is included in Visual Studio Community, Pro and Enterprise, which should improve database developer productivity.

Visual Studio Enterprise 2017 also includes ‘core editions’ of Redgate’s ReadyRoll database versioning and schema management tool, as well as IntelliSense-style SQL Prompt code completion.

ReadyRoll Core helps you develop migration scripts and manage database changes using source control, so it’s basically “config as code” for databases. The SQL Prompt Core extension helps you write, format and refactor SQL code, said Montgomery. SQL Prompt pops up suggestions as you type, completing operators like UPDATE and reminding you that the next command after UPDATE needs to be SET. You can run a script checker once you finish editing, as well. “These do for databases what VSTS does for source code.”

Use ReadyRoll as a build task to update your database as you build your code.

Usually, changes to code and changes to database schema are made and deployed independently, even though the code may depend on a particular version of the database schema. ReadyRoll helps co-ordinate that, explained Sneath.

As the user manipulates the database schema in production, ReadyRoll journals the differences between the current version and the previous version of the schema and can create migration scripts from one to the other. The user can check those into source code just like any other version.

“You always know what version of database schema you were on, you know what version you’re trying to get to and you can migrate forward just by running these scripts,” Montgomery said.

That means you can keep your front end and back end changes synchronized, even when developers make changes to a local version of the database, because ReadyRoll syncs their changes back to the project, refreshes the schema — and creates a changelog. You can see the contents of the scripts before you apply them, and you can make deploying schema updates to a database part of the build process.

Microsoft is in the process of updating its database development tools generally . Sneath noted that SQL Server 2016 moves its tooling into more recent versions of Visual Studio. “SQL Server 2012 was using the Visual Studio 2010 tooling; now it’s based on Visual Studio 2015.”

For enterprise developers, the strong DevOps integration between Visual Studio and SQL will be useful, but will Microsoft take that further?

NoSQL support in Visual Studio is still based on extensions rather than being a built-in feature, but that is the way Microsoft approaches new Visual Studio features, Sneath noted. “Our philosophy is to start with great extensions. The Docker support started as an extension in Visual Studio 2015 and now it’s a core part of the product, and the same is true of other features. Where things are moving very fast, where there’s a lot of rapid experimentation you’ll see us continue to ship extensions that then make their way into the core product.”

Feature image: “Sculptor’s Studio” by Louis Moeller, from the New York Metropolitan Museum of Art, public domain.

A newsletter digest of the week’s most important stories & analyses.

View / Add Comments

Please stay on topic and be respectful of others. Review our Terms of Use.