{"id":25295,"date":"2019-11-11T08:00:24","date_gmt":"2019-11-11T15:00:24","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet\/?p=25295"},"modified":"2019-11-07T16:27:13","modified_gmt":"2019-11-07T23:27:13","slug":"building-modern-cloud-applications-using-pulumi-and-net-core","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/building-modern-cloud-applications-using-pulumi-and-net-core\/","title":{"rendered":"Building Modern Cloud Applications using Pulumi and .NET Core"},"content":{"rendered":"<p><em>This is a guest post from the Pulumi team. Pulumi is an open source infrastructure as code tool that helps developers and infrastructure teams work better together to create, deploy, and manage cloud applications using their favorite languages. For more information, see https:\/\/pulumi.com\/dotnet.<\/em><\/p>\n<p>We are excited to announce .NET Core support for Pulumi! This announcement means you can declare cloud infrastructure \u2014 including all of Azure, such as Kubernetes, Functions, AppService, Virtual Machines, CosmosDB, and more \u2014 using your favorite .NET language, including C#, VB.NET, and F#. This brings the entire cloud to your fingertips without ever having to leave your code editor, while using production-ready \u201cinfrastructure as code\u201d techniques.<\/p>\n<p>Infrastructure has become more relevant these days as modern cloud capabilities such as microservices, containers, serverless, and data stores permeate your application\u2019s architecture. The term \u201cinfrastructure\u201d covers all of the cloud resources your application needs to run. Modern architectures require thinking deeply about infrastructure while building your application, instead of waiting until afterwards. Pulumi\u2019s approach helps developers and infrastructure teams work together to deliver innovative new functionality that leverages everything the modern cloud has to offer.<\/p>\n<p>Pulumi launched a little over a year ago and recently reached a stable 1.0 milestone. After working with hundreds of companies to get cloud applications into production, .NET has quickly risen to one of Pulumi\u2019s most frequently community requested features. Especially since many of us on the Pulumi team are early .NET ex-pats, we are thrilled today to make Pulumi available on .NET Core for your cloud engineering needs.<\/p>\n<h2>What is Pulumi?<\/h2>\n<p>Pulumi lets you use real languages to express your application\u2019s infrastructure needs, using a powerful technique called \u201cinfrastructure as code.\u201d Using infrastructure as code, you declare desired infrastructure, and an engine provisions it for you, so that it\u2019s automated, easy to replicate, and robust enough for demanding production requirements. Pulumi takes this approach a step further by leveraging real languages and making modern cloud infrastructure patterns, such as containers and serverless programs, first class and easy.<\/p>\n<p>With Pulumi for .NET you can:<\/p>\n<ul>\n<li>\n<p><strong>Declare infrastructure<\/strong> using C#, VB.NET, or F#.<\/p>\n<\/li>\n<li>\n<p><strong>Automatically create, update, or delete cloud resources<\/strong> using Pulumi\u2019s infrastructure as code engine, removing manual point-and-clicking in the Azure UI and ad-hoc scripts.<\/p>\n<\/li>\n<li>\n<p><strong>Use your favorite IDEs and tools<\/strong>, including Visual Studio and Visual Studio Code, taking advantage of features like auto-completion, refactoring, and interactive documentation.<\/p>\n<\/li>\n<li>\n<p><strong>Catch mistakes early on<\/strong> with standard compiler errors, Roslyn analyzers, and an infrastructure-specific policy engine for enforcing security, compliance, and best practices.<\/p>\n<\/li>\n<li>\n<p><strong>Reuse any existing NuGet library<\/strong>, or distribute your own, whether that\u2019s for infrastructure best practices, productivity, or just general programming patterns.<\/p>\n<\/li>\n<li>\n<p><strong>Deploy continuously, predictably, and reliably<\/strong> using Azure DevOps Pipelines, GitHub Actions, or one of over a dozen integrations.<\/p>\n<\/li>\n<li>\n<p><strong>Build scalable cloud applications<\/strong> using classic infrastructure cloud native technologies like Kubernetes, Docker containers, serverless functions, and highly scalable databases such as CosmosDB into your core development experience, bringing them closer to your application code.<\/p>\n<\/li>\n<\/ul>\n<p>Pulumi\u2019s free open source SDK, which includes a CLI and assortment of libraries, enables these capabilities. Pulumi also offers premium features for teams wanting to use Pulumi in production, such as Azure ActiveDirectory integration for identity and advanced policies.<\/p>\n<h2>An example: global database with serverless app<\/h2>\n<p>Let\u2019s say we want to build a new application that uses Azure CosmosDB for global distribution of data so that performance is great for customers no matter where in the world they are, with a C# serverless application that automatically scales alongside our database. Normally we\u2019d use some other tools to create the infrastructure, such as JSON, YAML, a DSL, or manually point-and-click in the Azure console. This approach is par for the course, but also daunting \u2014 it\u2019s complex, unrepeatable, and means we need an infrastructure expert just to even get started.!<\/p>\n<p>The Pulumi approach is to just write code in our favorite .NET language and the Pulumi tool will handle the rest. For example, this C# code creates an Azure CosmosDB databases with a serverless Azure AppService FunctionApp that automatically scales alongside the database:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/terrajobst\/d3c82a5df99de1f10de81fd13d4f605a.js\"><\/script> After writing this code, you run the Pulumi CLI with the pulumi up command and it will first show you a preview of the infrastructure resources it plans on creating. After confirming, it will deploy your whole application and its required infrastructure in just a few minutes.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2019\/11\/test.png\" alt=\"\" width=\"1440\" height=\"984\" class=\"aligncenter size-full wp-image-25297\" srcset=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2019\/11\/test.png 1440w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2019\/11\/test-300x205.png 300w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2019\/11\/test-768x525.png 768w, https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2019\/11\/test-1024x700.png 1024w\" sizes=\"(max-width: 1440px) 100vw, 1440px\" \/><\/p>\n<p>Later on, if you need to make any changes, you just edit your program, rerun the CLI, and it will make the necessary incremental changes to update your infrastructure accordingly. A full history of your deployments is recorded so you can easily see what changes have been made.<\/p>\n<h2>Why is .NET great for infrastructure too?<\/h2>\n<p>Many of us love using .NET to author our applications, so why not use it for infrastructure as code too? We\u2019ve in fact already seen above some of the advantages above to doing so. Many of these are probably evident if you already know and love .NET, however, let\u2019s briefly recap.<\/p>\n<p>By using any .NET language, you get many helpful features for your infrastructure code:<\/p>\n<ul>\n<li>\n<p><strong>Familiarity<\/strong>: No need to learn DSLs or markup templating languages.<\/p>\n<\/li>\n<li>\n<p><strong>Expressiveness<\/strong>: Use loops, conditionals, pattern matching, LINQ, async code, and more, to dynamically create infrastructure that meets the target environment\u2019s needs.<\/p>\n<\/li>\n<li>\n<p><strong>Abstraction<\/strong>: Encapsulate common patterns into classes and functions to hide complexity and avoid copy-and-pasting the same boilerplate repeatedly.<\/p>\n<\/li>\n<li>\n<p><strong>Sharing and reuse<\/strong>: Tap into a community of cloud applications and infrastructure experts, by sharing and reusing NuGet libraries with your team or the global community.<\/p>\n<\/li>\n<li>\n<p><strong>Productivity<\/strong>: Use your favorite IDE and get statement completion, go to definition, live error checking, refactoring, static analysis, and interactive documentation.<\/p>\n<\/li>\n<li>\n<p><strong>Project organization<\/strong>: Use common code structuring techniques such as assemblies and namespaces to manage your infrastructure across one or more projects.<\/p>\n<\/li>\n<li>\n<p><strong>Application lifecycle<\/strong>: Use existing ALM systems and techniques to manage and deploy your infrastructure projects, including source control, code review, testing, and continuous integration (CI) and delivery (CD).<\/p>\n<\/li>\n<\/ul>\n<p>Pulumi unlocks access to the entire .NET ecosystem \u2014 something that\u2019s easy to take for granted but is missing from other solutions based on JSON, YAML, DSLs, or CLI scripts. Having access to a full language was essential to enabling the CosmosApp example above, which is a custom component that internally uses classes, loops, lambdas, and even LINQ. This approach also helps developers and operators work better together using a shared foundation. Add all of the above together, and you get things done faster and more reliably.<\/p>\n<h2>Join the community and get started<\/h2>\n<p>Today we\u2019ve released the first preview of Pulumi for .NET, including support for the entire Azure breath of services. To give Pulumi a try, <a href=\"https:\/\/pulumi.com\/dotnet\">visit the Pulumi for .NET homepage<\/a>.<\/p>\n<p>There you will find several instructions on installing and getting started with Pulumi for .NET. The following resources provide additional useful information:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/pulumi\/examples\/tree\/master\/azure-cs-cosmosapp-component\">Full CosmosApp example code<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.pulumi.com\/docs\/get-started\/azure\/\">Getting started with Pulumi for Azure<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.pulumi.com\/docs\/get-started\/kubernetes\/\">Getting started with Pulumi for Kubernetes<\/a><\/p>\n<\/li>\n<li>\n<p>Integrating Pulumi with <a href=\"https:\/\/www.pulumi.com\/docs\/guides\/continuous-delivery\/azure-devops\/\">Azure DevOps Pipelines<\/a> and <a href=\"https:\/\/www.pulumi.com\/docs\/guides\/continuous-delivery\/github-actions\/\">GitHub Actions<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.pulumi.com\/docs\/intro\/concepts\/\">General Pulumi overview (concepts and architecture)<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.pulumi.com\/pricing\/\">Overview of premium Pulumi features for teams and Enterprises<\/a><\/p>\n<\/li>\n<\/ul>\n<p>Although Pulumi for .NET is listed in \u201cpreview\u201d status, it supports all of the most essential Pulumi programming model features (and the rest is on its way). Our goal is to gather feedback and over the next few weeks, and we will be working hard to improve the .NET experience across the board, including more examples and better documentation.<\/p>\n<p>Please <a href=\"https:\/\/slack.pulumi.com\/\">join the community in Slack<\/a> to discuss your scenarios, ideas, and to get any needed assistance from the team and other end users. Pulumi is also <a href=\"https:\/\/github.com\/pulumi\/pulumi\">open source on GitHub<\/a>.<\/p>\n<p>This is an exciting day for the Pulumi team and our community. Pulumi was started by some of .NET\u2019s earliest people and so it\u2019s great to get back to our roots and connect with the .NET community, helping developers, infrastructure teams, and operators build better cloud software together.<\/p>\n<p>We look forward to seeing the new and amazing cloud applications you build with Pulumi for .NET!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a guest post from the Pulumi team. Pulumi is an open source infrastructure as code tool that helps developers and infrastructure teams work better together to create, deploy, and manage cloud applications using their favorite languages. For more information, see https:\/\/pulumi.com\/dotnet. We are excited to announce .NET Core support for Pulumi! This announcement [&hellip;]<\/p>\n","protected":false},"author":11288,"featured_media":25299,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[685,196],"tags":[9,30,37],"class_list":["post-25295","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-dotnet-core","tag-net-core","tag-announcement","tag-azure"],"acf":[],"blog_post_summary":"<p>This is a guest post from the Pulumi team. Pulumi is an open source infrastructure as code tool that helps developers and infrastructure teams work better together to create, deploy, and manage cloud applications using their favorite languages. For more information, see https:\/\/pulumi.com\/dotnet. We are excited to announce .NET Core support for Pulumi! This announcement [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/25295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/11288"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=25295"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/25295\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/25299"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=25295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=25295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=25295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}