Page 30 - MSDN Magazine, September 2017
P. 30
Figure 3 Visual Studio for Mac
Publish Directly to Azure When you’re ready to move an appli- cation to run in the cloud, you’ll likely want to begin by trying it in the cloud with as little effort as possible. Both Visual Studio and Visual Studio for Mac enable you to publish an app directly from your machine to Azure App Service. App Service is a fully managed cloud environment that enables you to run your app without the need to worry about complex configuration or infrastructure management.
Publishing your app from your local machine to Azure App Ser- vice from Visual Studio or Visual Studio for Mac is as simple as right- clicking the project and choosing Publish. You’ll be asked to enter some information, such as the unique URL for your app, and you’ll be able to choose either an existing App Service Plan (how many resources you want reserved for the collection of member apps) or create a new one if you don’t have one yet. Once you’ve entered the information, your app will be running in the cloud in a matter of minutes.
Container Development Tools One of the things that’s becoming clear about modern cloud development is that containers are going to revolutionize the way people architect and build software. Containers enable you to package your application and all of its dependencies, including a copy of the runtime, into a single unit, guaranteeing that changes to the underlying server will never break your application. This enables a microservice architecture pattern in which you deploy each unit of logic within your application as a separate container, with a defined protocol to communicate between them. This lets you scale high-demand parts of the app as needed without paying the cost of scaling the entire application, and it means that fixes affect only the container that’s being updated rather than the entire application.
With that in mind, one of our goals with .NET Core is to make it the premier runtime for creating containerized microservices. Visual Studio, Visual Studio for Mac and Visual Studio Code all support building apps as Docker containers. (Note that at the time of this writing, Docker tooling support for Visual Studio for Mac requires the Docker Tools extension, and that Microsoft offers a Docker
extension for Visual Studio Code to support creating Docker containers.) To build a Docker container, you need Docker’s tools for your OS installed (learn more and download from docker.com). Once you have the requirements installed, all you need to do in Visual Studio or Visual Studio for Mac is right-click the project, choose Add and then select Docker Support. This will add a docker-compose project to your solution, and a Dockerfile to the project. These assets enable your project to be built into a Docker container. When you then run the app from the IDE, you’ll be running and debugging your application inside a container rather than on the host machine directly. The great news is that the publishing to Azure App Service experience we discussed also supports publishing Linux Docker containers.
Wrapping It Up
If you haven’t tried building a .NET Core app yet, there’s no better time to start than now. .NET Core and .NET Standard 2.0 (as covered in the “Demystifying .NET Core and .NET Standard” article) make creating a .NET application easy no matter what tools, OS, language or work style you choose.
Wehopeyoufoundthistouroftheavailable.NETCoretoolsuseful. You can continue to follow our team’s progress and future improve- ments on our blog at aka.ms/dotnetblog. Please try out the tools we discussed and give us feedback on what we can do to further improve your experience creating .NET Core apps. You can leave comments and questions on our blog posts, or send us feedback directly through Visual Studio and Visual Studio for Mac by using the Report a Prob- lem and Provide a Suggestion features built into the IDEs. n
Andrew HAll is the program manager lead for the .NET languages and tools in Visual Studio. After graduating from college, he wrote line-of-business applications before returning to school for his master’s degree in computer science. After com- pleting his master’s degree, he joined the diagnostics team in Visual Studio where he worked on the debugger, profiling and code analysis tools. He then moved to the .NET languages and tools team where he works on the .NET languages and supporting tools, including tools for ASP.NET, Web and Azure App Service. You can reach Hall via Twitter: @AndrewBrianHall.
Joe Morris is a program manager for .NET Core tools and Live Unit Testing in Visual Studio. He holds a master’s degree in Computer Science. He started his career as an application developer consultant to enterprises in the United States in the 1990s. He joined Microsoft in 1997 with Microsoft Consulting Services, Iowa, and later moved to Redmond. In the last two years his focus has been on static code analysis and developer productivity tools. You can reach Morris via Twitter: @_jomorris.
THAnks to the following Microsoft technical experts who reviewed this article: Dustin Campbell, Phillip Carter, Livar Cunha, Mikayla Hutchinson, Mads Kristensen, Jordan Matthiesen and Kasey Uhlenhuth
26 msdn magazine
.NET Core