<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Azure Developers - Medium]]></title>
        <description><![CDATA[Technical articles for developers building, automating and deploying cloud applications on Azure with a focus on DevOps written and curated by Azure engineers. - Medium]]></description>
        <link>https://medium.com/azure-developers?source=rss----f16d2eae0c47---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Azure Developers - Medium</title>
            <link>https://medium.com/azure-developers?source=rss----f16d2eae0c47---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 01:54:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/azure-developers" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introducing Buffalo-Azure]]></title>
            <link>https://medium.com/azure-developers/https-medium-com-marstr-introducing-buffalo-azure-f7243670c7f9?source=rss----f16d2eae0c47---4</link>
            <guid isPermaLink="false">https://medium.com/p/f7243670c7f9</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[gobuffalo]]></category>
            <dc:creator><![CDATA[Martin Strobel]]></dc:creator>
            <pubDate>Thu, 12 Jul 2018 20:26:53 GMT</pubDate>
            <atom:updated>2018-07-12T20:47:42.064Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OeRZvzCvQ9quWnp5pMZ_pA.png" /><figcaption>The image of Azure Gophers was drawn by<a href="https://medium.com/@ashleymcnamara"> Ashley McNamara</a>, based on artwork by <a href="https://reneefrench.blogspot.com/">Renee French</a>. It is licensed under the <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons 4.0 License</a> - .</figcaption></figure><p><strong>The word ‘buffalo’ means a lot of things</strong></p><p>For Go developers, <a href="https://gobuffalo.io/">Buffalo</a> is a Ruby-on-Rails style rapid web development framework. e.g. There’s a lot of boiler plate code associated with writing a web application, and while it’s a super useful and fun exercise to run through writing all of that once, this will get your project started a <em>lot</em> faster. Anybody who’s written a console application in Go that takes flags knows that using the `flags` standard library package is fine, and a lot better than parsing the os.Args slice yourself. However, anybody who’s tried <a href="https://github.com/spf13/cobra">spf13’s Cobra</a> knows it’s a lot better and a lot faster to get started with. Buffalo offers the same improvement over the standard library’s `http` package that Cobra provides over the `flag` package.</p><p><strong>Stairway to Heaven</strong></p><p>While Buffalo without plugins offers a tremendous amount of value for generating a website and developing on it locally (and fast) you still need a way to get it into the cloud. Depending on your experience level, setting up a website can be a relatively heavy lift. If you’re thinking of creating your own VMs, networking, and load balancing infrastructure, it could be quite time consuming. There are a lot of benefits to leaning on your cloud provider to handle the infrastructure for you.</p><p>Running a managed Kubernetes cluseter (i.e. Microsoft’s AKS, Amazon’s EKS, Google’s GKE, etc.) is a pretty awesome and flexible way to get your website running. You can run a whole host of containerized microservices and amortize the performance hit across a lot nodes. However, if you are running a self-contained website, using a Kubernetes cluster is a little excessive.</p><p>Another option is to take advantage of an Azure product called “App Services” or “Azure Web Applications”. This service is a tremendous fit for running a single Buffalo application because they are specifically targeted at running monolithic web applications with all of the trimmings you’d expect: auto-scaling, loading balancing, CPU usage metrics, and response time metrics to name a few.</p><p>That’s where <a href="https://github.com/Azure/buffalo-azure">Buffalo-Azure</a> comes in.</p><p>Using the command `buffalo azure provision`, an Azure App Service will be created to host your site. In addition, Buffalo-Azure reflects over the site defined in your working directory to provision a managed instance of the database you’re using (if it’s Postgres or MySQL). Once you’ve provisioned once, it will add two files to your project, `azuredeploy.json` and `azuredeploy.parameters.json`. These will allow you to use Buffalo-Azure, the <a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest">Azure CLI 2.0</a> or the <a href="https://portal.azure.com/">Azure Portal</a> to deploy your site again with all of the same settings.</p><p><strong>Stop polling, start reacting</strong></p><p>Azure Event Grid is an HTTP based messaging service. If you have microservices talking to each other directly, restructuring your application to take advantage of Event Grid Topics for message distribution can dramatically simplify the retry logic in your code. Not to mention, introducing an intermediary can reduce how tightly coupled your services are by allowing services to declare what they’re interested in, instead of putting the onus on the producer of the event.</p><p>The <a href="https://github.com/Azure/azure-sdk-for-go">Azure SDK for Go</a> already has <a href="https://github.com/Azure/azure-sdk-for-go/tree/7971189ecf5a584b9211f2527737f94bb979644e/services/eventgrid">several packages</a> that make it easier for you to publish and deserialize Event Grid events. That’s great, but there can be a lot of work that goes into setting up an endpoint that receives and dispatches on a string in your payload. Again, this is an opportunity for the Buffalo-Azure plugin to help you out. Run the command `buffalo generate eventgrid`, and a new Buffalo action will be created in your application that already knows how to dispatch and deserialize your Event Grid Events, even if they’re custom types that you defined.</p><p><strong>Bottom Line</strong></p><p>Rapid web development has arrived in Go, and there’s no better time to build and play with your web application. No matter who you are, and how much web-dev experience you have, there’s nothing stopping you from getting your website hosted in Microsoft Azure right now. Go try <a href="https://github.com/Azure/buffalo-azure">Buffalo-Azure</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7243670c7f9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azure-developers/https-medium-com-marstr-introducing-buffalo-azure-f7243670c7f9">Introducing Buffalo-Azure</a> was originally published in <a href="https://medium.com/azure-developers">Azure Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Level 3+: Kubernetes and Chef Habitat on Azure]]></title>
            <link>https://medium.com/azure-developers/level-3-kubernetes-and-chef-habitat-on-azure-22fc122e9d5?source=rss----f16d2eae0c47---4</link>
            <guid isPermaLink="false">https://medium.com/p/22fc122e9d5</guid>
            <category><![CDATA[chefs]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[azure-cli]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[David Justice]]></dc:creator>
            <pubDate>Thu, 01 Jun 2017 16:01:01 GMT</pubDate>
            <atom:updated>2017-06-06T14:59:49.841Z</atom:updated>
            <content:encoded><![CDATA[<p>For those of you that have been following my DevOps on Azure progression series, you will know this topic is a bit out of order in the series. I was intending on covering container based immutable infrastructure a bit later in the series, but after presenting Habitat packages deploying to Kubernetes on Azure Container Service at ChefConf 2017 it seems like a great opportunity to pen this content while it’s still fresh in mind.</p><p>Here’s a link to the begining of the series if you’d like to catch up a bit on the previous posts. If not, don’t worry, this post will be self contained and you will no worse for not having reviewed the previous posts.</p><p><a href="https://medium.com/azure-developers/a-prequel-to-open-source-application-development-on-azure-244dba30791e">A Prequel to Open Source Application Development on Azure</a></p><h3>What are we going to do today?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0u_EQ9Yv4i6b5AYXlcAIzg.png" /><figcaption>Rails + Ember Todo List</figcaption></figure><p>In this post we are going to deploy a Rails + Ember + CosmosDB application to Kubernetes using Azure Container Service and Chef Habitat. We’ll provision an Azure Container Registry, Kubernetes cluster, and CosmosDB instance in MongoDB mode. After provisioning the infrastructure, we’ll then package our Rails application with Chef Habitat and export a docker image. We’ll push the docker image to our private registry, and finally, deploy our application in our Kubernetes cluster.</p><p>All of the code for this project can be found in Github in the following repository.</p><p><a href="https://github.com/devigned/hab-rails-todo">devigned/hab-rails-todo</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FD_DQTDpm4TA%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DD_DQTDpm4TA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FD_DQTDpm4TA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/64c93e63158591bb18b775b8b6a80207/href">https://medium.com/media/64c93e63158591bb18b775b8b6a80207/href</a></iframe><h3>Prerequisites for running the demo</h3><ul><li><a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli">Azure CLI</a></li><li><a href="https://www.habitat.sh/docs/get-habitat/">Chef Habitat</a></li><li><a href="https://docs.docker.com/engine/installation/">Docker</a></li></ul><h3>Project Structure</h3><p>If you clone the devigned/hab-rails-todo locally, you will see the following project structure.</p><pre>$ tree . -L 1<br>.<br>├── LICENSE<br>├── README.md<br>├── azure<br>├── demo.sh<br>├── habitat<br>└── src</pre><p>The ./azure directory contains provision.sh, which builds the Azure infrastructure. The ./habitat directory contains the Chef Habitat related files. The ./src directory contains the source for the Rails todo application we’ll be deploying. Finally, ./demo.sh contains a rough script you could follow on your own to replicate the steps described in this post.</p><p>In the rest of the post, it is assumed all commands execute from the root of the devigned/hab-rails-todo repo.</p><h3>Provisioning Azure Infrastructure</h3><p>Let’s first go through the infrastructure provisioning script. You can execute the provisioning script by running ./azure/provision.sh.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d430788408971a6cef015b63549a974/href">https://medium.com/media/1d430788408971a6cef015b63549a974/href</a></iframe><p>First thing to take away from this script, is that it is designed using the Azure CLI to reach a goal state, and can be re-run any number of times.</p><ul><li><strong>Lines 5–11:</strong> Setup some variables to be used in the rest of the script</li><li><strong>Lines 18–23:</strong> Create our resource group if one doesn’t already exist</li><li><strong>Lines 25–31:</strong> Create a local public and private key pair for cluster authentication</li><li><strong>Lines 33–39:</strong> Create the CosmosDB instance in MongoDB mode</li><li><strong>Lines 41–48:</strong> Create the Azure Container Service instance in Kubernetes mode with 2 agents for running containers</li><li><strong>Lines 50–58:</strong> Create the Azure Container Registry</li><li><strong>Lines 60–67:</strong> Login to the newly created container registry using the generated credentials</li><li><strong>Lines 69–75:</strong> Fetch Kubernetes credentials and store them in ~/.kube/config in preparation for using kubectl</li><li><strong>Lines 77–80:</strong> If kubectl is not in the path, install it</li><li><strong>Lines 82–83:</strong> Create the Habitat ./habitat/default.toml with default configuration</li></ul><p>At the completion of this script, we’ll be ready to deploy container images to Kubernetes using our private container registry.</p><p>Ok… so now I have all of the Azure infrastructure setup, how are we going to package and deploy our Rails application onto my Kubernetes cluster? We are going to use Chef Habitat!</p><h3>What is Chef Habitat?</h3><p><a href="https://www.habitat.sh/">Chef Habitat</a> is a packaging, deployment and application management tool, which provides an abstraction over then environment the application is to be run within (virtual machines, containers, bare metal, etc.). It allows you, the developer, to concentrate on less on environmental configuration, process supervision and deployment details and more on delivering delight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CbJQw7ephpKV3CHMz3UTcw.png" /></figure><p>As an aside, Habitat is written in Rust, and is incredibly snappy. Take a look at the rudimentary comparison to kubectl below. Habitat is <strong><em>an order of magnitude </em></strong>quicker.</p><pre>$ time hab -h 1&gt;/dev/null</pre><pre>real 0m0.011s<br>user 0m0.004s<br>sys 0m0.003s</pre><pre>$ time kubectl -h 1&gt;/dev/null</pre><pre>real 0m0.131s<br>user 0m0.108s<br>sys 0m0.019s</pre><h3>Ok… so how do I package this Rails application?</h3><pre>hab studio enter<br>build<br>hab export pkg docker devigned/rails-todo</pre><ul><li>hab studio enter creates and opens a Habitat clean room (Docker container) for building your application. It provides an environment with all of the tools you need to build and package your application.</li><li>build builds the Habitat package, a signed .hart file, which is really just a tar.gz</li><li>hab export pkg docker devigned/rails-todo exports the .hart package to a docker image.</li></ul><p>After exiting out of Habitat studio, and running docker image --format &quot;table {{ .Repository }}\t{{ .Tag }}&quot;, you should see the following.</p><pre>$ docker images --format &quot;table {{ .Repository }}\t{{ .Tag }}&quot;<br>REPOSITORY                                  TAG<br>devigned/rails-todo                         0.1.0-20170531150240<br>devigned/rails-todo                         latest<br>habitat-docker-registry.bintray.io/studio   0.24.1</pre><blockquote>Wat!? Habitat just built me a Docker image. Dope!</blockquote><h3>That seems too easy… What just happened?</h3><p>Remember the ./habitat directory in the root of the repo? Well, that directory holds the details of how we will package the Rails application in ./src. Here’s a listing of the ./habitat directory.</p><pre>$ tree ./habitat/<br>./habitat/<br>├── config<br>│   ├── mongoid.yml<br>│   └── secrets.yml<br>├── default.toml<br>├── hooks<br>│   ├── init<br>│   └── run<br>└── plan.sh</pre><p>The main file is the ./habitat/plan.sh, which describes the packages the application depends upon (lines 8–21), what ports the application exposes (lines 22–23), how to build and install the application (lines 40–53) as well as other pertinent pieces of metadata about the application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9195aece8ede21dd8d702e0b06f26f45/href">https://medium.com/media/9195aece8ede21dd8d702e0b06f26f45/href</a></iframe><p>The config directory contains handlebars templated configuration files, which will have values replaced based on values in the ./habitat/config/default.toml file. For example, ./habitat/config/mongoid.yml will have the {{cfg.mongodb_uri}} (line 4) replaced with some_connection_string from ./habitat/config/default.toml (line 2). Similarly, ./habitat/config/secrets.yml will have configuration values injected.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33a4ec30c9b96e47b313137ba18a1c96/href">https://medium.com/media/33a4ec30c9b96e47b313137ba18a1c96/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/277523884a64343252408d8c2d32ced8/href">https://medium.com/media/277523884a64343252408d8c2d32ced8/href</a></iframe><p>The ./habitat/hooks directory contains scripts, which will be run by the Habitat supervisor at different lifecycles of the application. For this application, we’ll only be using two of the hooks, init and run. There are multiple other hooks (file_updated, health_check, reload, suitability, reconfigure, etc.). You can find more information about hooks in the <a href="https://www.habitat.sh/docs/reference/plan-syntax/#hooks">Habitat documentation</a>.</p><p>The init hook runs when a Habitat topology starts. As you can see from the following gist, the init hook moves our application’s files into the running directory the application, /hab/svc/$pkg_name/staic.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61bed245ed6c9425a563b9c7627b5712/href">https://medium.com/media/61bed245ed6c9425a563b9c7627b5712/href</a></iframe><p>The run hook runs when one of the following conditions occurs:</p><ul><li>The main topology starts, after the init hook has been called</li><li>When a package is updated, after the init hook has been called</li><li>When the package config changes, after the init hook has been called, but before a reconfigure hook is called</li></ul><p>As you can see from the following gist, the run hook sets up our Rails environment variables, and kicks off the Rails server bound to the IP and port defined in our Habitat configuration default source, ./habitat/default.toml.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0991d811f3602ca5457cc68e44e4e7c9/href">https://medium.com/media/0991d811f3602ca5457cc68e44e4e7c9/href</a></iframe><p>Ok… we’ve deep dived enough into our Habitat configuration and packaging. Let’s deploy this application onto our Kubernetes cluster.</p><h3>Deploying to Kubernetes on Azure</h3><p>At this point, we have a Docker image container our application, and we have our Azure infrastructure provisioned. We just need to tag and push our image to our private repository, and then ask Kubernetes to run our image.</p><p>To push the image to our private registry, run the following commands.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c54723d3efe4654952eeab6306b73a72/href">https://medium.com/media/c54723d3efe4654952eeab6306b73a72/href</a></iframe><p>Once the image is pushed to the private registry, we are ready to deploy the image to our Kubernetes cluster.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ccc7a6dd2e72560d371c0a94ffef8ba/href">https://medium.com/media/2ccc7a6dd2e72560d371c0a94ffef8ba/href</a></iframe><p>The above set of commands will deploy, load balance and scale out your Chef Habitat packaged Rails todo application on Azure Container Service running Kubernetes!</p><h3>Leveling up your DevOps</h3><p>Each of the posts in this progression series have focused on leveling up your DevOps practices (mostly focused on deployment and provisioning). In this post we have described an example of a container based immutable infrastructure deployment using Chef Habitat, Kubernetes and Docker, but we haven’t talked about the why. Why is this a progression from previous models (handcrafted pets, infrastructure as code, etc.) a progression in DevOps maturity?</p><p>As systems grow in complexity it becomes increasingly difficult to reason about the state of a system. In an already complex system, additional complexity is accumulated when you must account for the mutating state of each individual component of the system to fully understand of the state of the entire system. When running “pets” (machines with mutating state with long lifespans), we need to constantly be aware of the state of the pets, and ensure they don’t skew too far out of compliance, thus adding to the overall complexity of the system. When building infrastructure with code, one is able to define, test and rebuild infrastructure though automated processes, thus creating an environment where it’s easy to build and destroy infrastructure leading to less state. When building immutable infrastructure with containers, we are able to define, test, build and persist packaged infrastructure. The key here is the ability to reason about a stateless piece of packaged infrastructure. The packaged infrastructure is versioned, signed and will not mutate state. Pair immutable packages with the added benefit of speedy container deployment and teardown, and we further reduce the complexity of the system while making it easier to replace infrastructure components.</p><p>Another interesting aspect of Chef Habitat is that the package metadata acts similarly to how we manage code dependencies, and offers many of the same benefits. We can reason about upstream changes and rebuild / redeploy packages based on those changes. For example, this application takes a dependency on core/openssl. If there was an important upstream change to that package (perhaps, a vulnerability was found), then we could be alerted of such a change and redeploy with the latest patch. This isn’t limited to direct dependencies. It could include the transitive closure of all of the application’s dependencies (all the app’s dependencies as well as all of the dependency’s dependencies recursively). This helps us to better understand the state of our system in the context of an ever changing ecosystem of dependencies.</p><p>The impact of Chef Habitat package metadata provides a higher level abstraction to packaged infrastructure, which allows us to reason about more than just dependent packages. The package metadata enables us to expose promises (intentions). For example, our application promises to expose a service on port 3000. In a more complex topology, this could allow another infrastructure component to bind to this promise. In fact, there a <a href="https://en.wikipedia.org/wiki/Promise_theory">whole theory behind this promise stuff</a>.</p><blockquote>Promise theory may be viewed as a logical and graph theoretical framework for understanding complex relationships in networks, where many constraints have to be met</blockquote><p>With infrastructure acting like autonomous agents describing their intentions, the system can reason about topology and self-organize. It almost starts to sound like a biological system. A system that is able to reason about it’s own organization lowers the complexity for operators of the system by automating organization and constraint resolution.</p><p>At the end of the day, we need to grok the state of our already complex systems. Anything we can do to limit complexity and provide more clarity into the state of our systems is leveling up our operation awareness and maturity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22fc122e9d5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azure-developers/level-3-kubernetes-and-chef-habitat-on-azure-22fc122e9d5">Level 3+: Kubernetes and Chef Habitat on Azure</a> was originally published in <a href="https://medium.com/azure-developers">Azure Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windowsless in Seattle, part 6]]></title>
            <link>https://medium.com/azure-developers/windows-in-seattle-part-6-c4f271eff9f3?source=rss----f16d2eae0c47---4</link>
            <guid isPermaLink="false">https://medium.com/p/c4f271eff9f3</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[free-software]]></category>
            <category><![CDATA[microsoft-build]]></category>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[seattle]]></category>
            <dc:creator><![CDATA[JJ Merelo]]></dc:creator>
            <pubDate>Fri, 19 May 2017 06:22:44 GMT</pubDate>
            <atom:updated>2017-05-18T16:46:07.079Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h4>The war (and MS Build) is over</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hulvlmuw1CJWrMp4n4IMmQ.jpeg" /><figcaption>Hacking the hours away during Ms bUILD</figcaption></figure><p>Sometimes the argument between two different ways of understanding the technology, pay-per-use vs. free to share, is told as a war, as in us vs. them or evil vs. motherhood and apple pie and the American way of life. There are never such clear cut lines between fields, but then that’s the case also for real war.</p><p>That is why, when people see Microsoft adopting open source, using Linux and even including it as part of its products, are eager to declare “War is over, <em>and we won”.</em></p><p>That is a great thing to think, and you feel great and cuddly as you ride your laptop into the sunset. However, in technological war, as in real life, wars are never won by anyone. There are deaths and, after a lot of flag waving, well, it has been a bloody war.</p><p>Besides, framing this in terms of war begs to argue who has really won. I am still surrounded by proprietary software in places where it probably should not be. I still see scant support by the administrations to a way of developing not only software, but knowledge, that should be the default one in publicly funded projects or organisms. And I still find it difficult to acquire computers that have OEM free operating systems or that make as easy as peeling a scab to install it. If this is how wars are won, well, I don’t see it’s still the moment to turn our swords into ploughshares. Mainly because we have no idea what is a ploughshare. If it’s the Uber of crop harvesting, maybe it’s something we should be looking for venture capital to fund. But it does not seem to be, so still talking about wars and about winning them, or not, does not help anyone, or for that matter the technology.</p><p>It does help, however, to hold hackathons which is the way to go if you want to engage the community. During a hackathon today, I have been helped by the expert guidance of <a href="https://github.com/JJ/siva-container">Adrien Blind to create a data container for environmental data in Andalucía</a>. Several other projects were hurled to the small crowd gathered there, and Microsoft professionals along with assorted hackers were keying away in their laptops with all the right stickers in them. After lunch, the people in charge of the Technical Advisory Groups (to which, full disclosure, I belong) has emphasized the need to listen, coordinate and help. Is that winning a war? It looks more like nurturing and caring about a community created around open source projects whose main engineers work for a company.</p><p>Eventually, we devs like to meet each other, talk trash and trade, and learn new things. MS Build is completely different from FOSDEM except where it is exactly the same: people meeting around open source and sharing knowledge. <a href="http://fosdem/">FOSDEM</a> is filled to the hilts with it, while MS Build has it only in a few rooms, in a few minutes during the keynotes, and in a few stands. Not perfect, but it looks like for some reason Microsoft has taken a bit of the love potion number nine and is kissing everyone in sight. Or just a few. Be that as it may, I think it is better to express what has happened with Microsoft and open source in terms of love, as in the penguin featured in the <a href="https://medium.com/p/windowsless-in-seattle-part-1-2ed46d3e350d">first article in this series</a>, instead of war.</p><p>Because love always trumps war.</p><blockquote>Check out the <a href="https://medium.com/@jjmerelo/windowsless-in-seattle-part-5-7cd1cec8673a">previous installment of this series</a>, with links to all the others.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4f271eff9f3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azure-developers/windows-in-seattle-part-6-c4f271eff9f3">Windowsless in Seattle, part 6</a> was originally published in <a href="https://medium.com/azure-developers">Azure Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Level 1: Azure + Rails + Ember + CosmosDB]]></title>
            <link>https://medium.com/azure-developers/level-1-azure-rails-ember-cosmosdb-c3951c61bda3?source=rss----f16d2eae0c47---4</link>
            <guid isPermaLink="false">https://medium.com/p/c3951c61bda3</guid>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[azure-cli]]></category>
            <category><![CDATA[cosmosdb]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[David Justice]]></dc:creator>
            <pubDate>Thu, 11 May 2017 19:18:19 GMT</pubDate>
            <atom:updated>2017-06-06T14:58:03.271Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s level up our Azure DevOps and DevOpsSec. Join me in building a robust Rails + Ember application on Azure. This application illustrates an incremental increase to our “<strong>Level: 0”</strong> maturity model, and will leverage the following Azure services, Virtual Machine Scale Sets (VMSS), Content Delivery Network (CDN), Key Vault, CosmosDB, and Azure Active Directory.</p><p><a href="https://medium.com/azure-developers/level-0-deploy-your-rails-app-on-azure-e7202828199">Level 0: Deploy Your Rails App on Azure</a></p><p>If you would like to follow along at home, all of the code for this post is located in GitHub and is free for use. There are instructions for running the demo locally as well as deploying it out to Azure. If you find issues or would like to contribute, please do.</p><p><a href="https://github.com/devigned/level1">devigned/level1</a></p><p>The entirety of this blog post we’ll be explaining this following script. The two key parts of this script are ./script/provision.sh, which provisions our infrastructure in Azure, and bundle exec cap production deploy:initial, which will deploy the Rails + Ember Todo List application onto our Azure infrastructure.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ad883481d2a966526da8eccce1772fd/href">https://medium.com/media/6ad883481d2a966526da8eccce1772fd/href</a></iframe><p>You will need the following installed to run this demo:</p><ul><li><a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli">Azure CLI</a></li><li>Ruby: I generally use <a href="https://rvm.io/rvm/install">RVM</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZ-RVxQ4db1Q%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZ-RVxQ4db1Q&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZ-RVxQ4db1Q%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a1d6bb051cf11a0bbd3a9bb6d3090fe/href">https://medium.com/media/6a1d6bb051cf11a0bbd3a9bb6d3090fe/href</a></iframe><h3>The Rails + Ember Todo List</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0u_EQ9Yv4i6b5AYXlcAIzg.png" /><figcaption>Rails + Ember Todo List</figcaption></figure><p>What’s the simplest application we can build and yet still be relatively real world, a todo list. This todo list application allows you to create a list of todo lists and todo items. The lists and items are displayed via a Ember.js single page application backed by a Rails API application. The Ember application communicates to Rails via JSONAPI over HTTP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qaNZU1aPDdL-A9xsohSaQw.png" /><figcaption>Rails + Ember Todo Item</figcaption></figure><p>The Rails API application uses <a href="https://docs.mongodb.com/ruby-driver/master/mongoid/#ruby-mongoid-tutorial">Mongoid</a> ODM framework for data persistence. Mongoid ODM is backed by <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/introduction">CosmosDB</a> (previously DocumentDB) using the MongoDB wire format. By using CosmosDB with MongoDB wire format, Rails + Mongoid thinks it’s talking to MongoDB, so we can use all of the tools we know and love that work with MongoDB. Also, by using CosmosDB we can take advantage of its managed data service which is truly global scale, so no more worrying about dealing scaling and clustering of a MongoDB cluster.</p><p>If you are not familiar with CosmosDB, I definitely recommend you take a look at it. It offers impressive global scalability and SLA’s for Latency, Throughput, Consistency and Availability at P99. For example, it guarantees end-to-end low latency at the 99th percentile to its customers. For a typical 1-KB item, Cosmos DB guarantees end-to-end latency of reads under 10 ms and indexed writes under 15 ms at the 99th percentile, within the same Azure region. The median latencies are significantly lower (under 5 ms).</p><h3>Infrastructure Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xh_bEyR1jyzGAlzaLzsYdQ.png" /><figcaption>Infrastructure components</figcaption></figure><p>Now that we have an understanding of the application we are going to deploy, let’s describe the infrastructure we are going to build to host this application. Our goal with this exercise is to create a real world application infrastructure which would provide for scaling and security.</p><p>For this blog post, we’ll only concern ourselves with hosting the application within a single region. We’ll expand to multiple regions in a future post.</p><p>The following are the Azure infrastructure services and their role in hosting this application:</p><ul><li><strong>Virtual Machine Scale Sets:</strong> provide a set of virtual machines to host Nginx, Rails and Azure CLI, which we can scale up and down as needed. These virtual machines will be provisioned with a certificate from Key Vault via the Azure provisioner to enable the applications running on the machines the ability to access other Azure resources.</li><li><strong>Load Balancer:</strong> load balance public HTTP and SSH traffic across the virtual machines in the scale set. The load balancer is configured to probe for the health of each machine in the cluster.</li><li><strong>Virtual Network (VNET):</strong> provide a network security boundary encapsulating the infrastructure.</li><li><strong>Key Vault:</strong> provide a controlled access secret store for infrastructure and services.</li><li><strong>CosmosDB:</strong> provide a managed data service which is exposed via the MongoDB wire format.</li><li><strong>Azure Active Directory (AAD):</strong> provide an identity store for access to Azure management APIs. We’ll use AAD to create identities for the applications executing on the virtual machines. This will enable the application to fetch secrets.</li></ul><h3>Provisioning Infrastructure</h3><p>Now that we’ve covered the components of the infrastructure and goals of the application, we can now start pulling the pieces together into a provisioning script. In “<strong>Level: 0</strong>”, we used a combination of scripts and SSH’ing into the machine to install / configure the machine. We’ll level up incrementally in this post and use Azure CLI and cloud-init to provision the infrastructure. There will be no SSH’ing into the machines (until we deploy the Rails + Ember bits via Capistrano) to manually configure. All base configuration will be handled by the cloud-init script.</p><p>Cloud-init is the standard for customizing cloud instances. It provides a simple yaml interface for describing common tasks such as package management / installation, script execution, etc…</p><blockquote>Cloud images are operating system templates and every instance starts out as an identical clone of every other instance. It is the user data that gives every cloud instance its personality and cloud-init is the tool applies user data to your instances automatically. — Canonical</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61e79588fd562674e6f4ba6d9c0e1254/href">https://medium.com/media/61e79588fd562674e6f4ba6d9c0e1254/href</a></iframe><p>The cloud-init is the template we’ll use in our deployment script. As you can probably tell, even if you are not terribly familiar with cloud-init syntax, is that it’s registering a package repository, installing some packages, then finally, running some scripts to prepare the machine. In fact, it’s installing all of the prerequisites for running the Rails application.</p><p>Obviously, cloud-init is much cleaner than hand executed scripts. It’s definitely a step up in maturity.</p><p>Pay close attention to <strong>line 30–33</strong>. We’ll cover this in more detail later, but it’s combining a public and private PEM certificate placed there by the Azure provisioner via Key Vault. That certificate is then used to authenticate Azure CLI, so that the machine will have a pre-authenticated Azure CLI instance to be able to leverage during code deployment to fetch secrets. Next we’ll see how that certificate get’s placed there on the virtual machine.</p><p>The following Bash script will provision all of the infrastructure needed for running the Rails + Ember todo list. I’ll go through it section by section below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7abb2d8ad72c719201cb24d118d4b6b/href">https://medium.com/media/f7abb2d8ad72c719201cb24d118d4b6b/href</a></iframe><p>Break down of the provisioning script:</p><ul><li><strong>Line 4:</strong> bail quickly on the script if it hits any errors</li><li><strong>Line 6–14:</strong> setup variables to allow the script to be relatively simple for others to use and deal with globally unique values like DNS entries</li><li><strong>Lines 17–20:</strong> login if not logged in</li><li><strong>Lines 22–27:</strong> Create the level1 resource group if it doesn’t exist</li><li><strong>Lines 29–36:</strong> Create the Key Vault if it doesn’t exist</li><li><strong>Lines 38–46:</strong> Create the certificate to be used for the Azure Active Directory Service Principal which will be the identity of the applications running on the virtual machines. Create the Rails secret key, which will be used by each of the Rails instances (if this wasn’t a demo, I wouldn’t store this value in source code).</li><li><strong>Lines 48–53:</strong> Create a CosmosDB instance using the MongoDB wire format.</li><li><strong>Lines 56–58:</strong> Delete the Azure Active Directory application and service principal if it already exists, so we can create another one with the same name cleanly.</li><li><strong>Lines 60–63:</strong> Download the public side of the Key Vault certificate created earlier and create an Azure Active Directory Application and Service Principal using the public side of the Key Vault certificate.</li><li><strong>Line 66:</strong> Give the Service Principal access to read secrets in the instance of Key Vault.</li><li><strong>Lines 69–70:</strong> Create a variable containing the virtual machine secrets reference to the certificate in Key Vault to be used to provision the Virtual Machine Scale Set. This will tell the Azure provisioner to place the certificate in /var/lib/waagent/{finger_print}.[crt|prv] on the virtual machine.<br>Remember how we said we’d touch back on the public and private certificate (PEM) cat’ed together in the cloud-init script, well, this is where the certificate comes from. The Azure provisioner will request the certificate on behalf of the user deploying the virtual machine and place the public and private side of the certificate on the provisioned virtual machine. By using this as the secret for our service principal, we are able to pre-authenticate Azure CLI.</li><li><strong>Lines 72–74:</strong> Use sed to replace {{fingerprint}}, {{tenant}}, and {{username}} values in the cloud-init to specialize the cloud-init script for the newly created infrastructure.</li><li><strong>Line 75:</strong> Provision the Virtual Machine Scale Set with three instances, and specifying the specialized cloud-init script and secrets (the Key Vault certificate) to be provisioned on the virtual machines.</li><li><strong>Lines 79–85:</strong> Configure the load balancer for traffic and health checks on port 80 routing back to the backend address pool containing the newly created virtual machines.</li><li><strong>Lines 90–99:</strong> Provision Azure CDN fronting the public fully qualified domain name of the Virtual Machine Scale Set created on line 75. We’ll use the CDN to serve the Javascript and CSS assets for the site.</li><li><strong>Lines 101–106:</strong> We are done! Provide some helpful output.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7181c7a6eba9f5aef735cf0adb9e1974/href">https://medium.com/media/7181c7a6eba9f5aef735cf0adb9e1974/href</a></iframe><p>Once provision.sh has run, the virtual machines in the scale set should be ready for code deployment via Capistrano. Let’s take a look at the changes that have been made to the deploy.rb file.</p><ul><li><strong>Line 4:</strong> Though we are still using Capistrano, we needed to add a bit to the deploy.rb file to ensure we are targeting all of the virtual machines in the scale set. To ensure they are targeted dynamically based on the number of VMs in the set, we shell out to Azure CLI to provide the list.</li><li><strong>Line 56–66:</strong> Build the Ember application</li><li><strong>Line 58:</strong> shell out to Azure CLI again to fetch the fully qualified domain name for the public IP of the load balancer.</li><li><strong>Line 62:</strong> replace the Ember environmental configuration for the production API to be the public fully qualified domain name for the load balancer. In practice, you probably will be able to have a more static value. This was done here so that it will work well with a dynamic value.</li><li><strong>Line 63:</strong> Set the CDN_HOST value so that Ember will build the asset links using the Azure CDN host returned by shelling out to Azure CLI for the fully qualified domain name of the CDN endpoint.</li></ul><h3>DevOps Security Level Up</h3><p>At no time was the private side of the Key Vault certificate, which was used as the secret for the virtual machines service principal identity, ever resident in memory or on disk in the developers machine. The certificate was generated in Key Vault and will only be handled by the Azure provisioning service. The certificate used here has never left the production boundary, and should never need to come in contact with humans. This is definitely a level up from Level 0.</p><h3>Anatomy of a Bootstrapped Rails Application</h3><p>Upon Capistrano deployment, the Rails + Mongoid application will try to startup. It will require a couple secrets at a minimum.</p><ol><li>secret_key_base</li><li>Mongoid connection string</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2cdfd64d11f206d05d511afad55d2fc9/href">https://medium.com/media/2cdfd64d11f206d05d511afad55d2fc9/href</a></iframe><p>Look to lines 10–13. Upon startup, if we are running in production, we’ll shell out to Azure CLI to request the Key Vault secret for the secret_key_base. Since we have a pre-authenticated Azure CLI with access to that Key Vault, we are able to fetch that secret.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d692ca628cef1075bc97b4c6621947b/href">https://medium.com/media/5d692ca628cef1075bc97b4c6621947b/href</a></iframe><p>Look to <strong>lines 25–29</strong>. Upon startup, if running in the production environment, the application will shell out to Azure CLI to fetch the connection strings to it’s instance of CosmosDB. Since we have a pre-authenticated Azure CLI with access to CosmosDB, we are able to retrieve connection strings for our application.</p><h3>Want to run this locally?</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4fecc84df761b96049d5f9589c2faed/href">https://medium.com/media/c4fecc84df761b96049d5f9589c2faed/href</a></iframe><h3>Want to deploy this too?</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ad883481d2a966526da8eccce1772fd/href">https://medium.com/media/6ad883481d2a966526da8eccce1772fd/href</a></iframe><h3>Leveling up to 1</h3><p>This post concentrates on deploying a Rails application, but the ideas and principals outlined in this post could just as easily be applied to a Java, .NET, Golang, etc. application. There is nothing special about the application tier or the infrastructure provisioned. Leveling up your DevOps maturity translates across language and platform boundaries.</p><p>Almost every application requires bootstrapping with secrets. That bootstrapping needs to be done in a responsible manor taking care to ensure that credential usage is tracked and sensitive information stays within secure domains. This just one way this bootstrapping problem can be approached. I think you will agree that this is a level up from the previous post.</p><p>The less human interaction with provisioning and deployment is goodness. In this post we’ve moved from hand rolled virtual machines to building with scripts and cloud-init. This is definitely an improvement, but not even close to mature.</p><h3>Leveling up to 2</h3><p>DevOps is such a wide term. We have only covered a small topic area, which has focused on deployment of infrastructure and applications. As we progress in maturity, we’ll start to expand our topic area into continuous delivery, monitoring, and other related topic areas.</p><p>In my next post, we’ll dive deeper into infrastructure as code and level up again using Ansible on Azure and add some monitoring.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3951c61bda3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azure-developers/level-1-azure-rails-ember-cosmosdb-c3951c61bda3">Level 1: Azure + Rails + Ember + CosmosDB</a> was originally published in <a href="https://medium.com/azure-developers">Azure Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dockerize your Web App]]></title>
            <link>https://medium.com/azure-developers/dockerize-your-web-app-2eed7fa58cad?source=rss----f16d2eae0c47---4</link>
            <guid isPermaLink="false">https://medium.com/p/2eed7fa58cad</guid>
            <category><![CDATA[azure-cli]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Aaron Roney]]></dc:creator>
            <pubDate>Sat, 06 May 2017 05:07:15 GMT</pubDate>
            <atom:updated>2017-06-06T14:58:17.569Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s dockerize our web app! We will be performing all operations using the <a href="https://github.com/Azure/azure-cli">Azure CLI</a>, and all of our work will be built using <a href="https://code.visualstudio.com/">Visual Studio Code</a> on <a href="https://msdn.microsoft.com/en-us/commandline/wsl/about">Bash On Windows</a>, Linux, Mac OS. If you have not already, make sure you have a <a href="http://blog.aaroney.com/2017/02/03/NET-Core-Web-App-in-Azure/">.NET Core Web App</a> ready to go.</p><h3>Prerequisites</h3><ul><li>[Required] <a href="https://github.com/Azure/azure-cli">Azure CLI</a> (<a href="https://docs.microsoft.com/en-us/cli/azure/install-az-cli2">install guide</a>).</li><li>[Required] <a href="https://www.microsoft.com/net/core">.NET Core</a> (<a href="https://github.com/dotnet/cli">CLI 1.0.0-rc4–004800+</a>).</li><li>[Required] <a href="https://azure.microsoft.com/en-us/free/">Azure Subscription</a>.</li><li>[Required] <a href="https://git-scm.com/downloads">git</a>.</li><li>[Required] <a href="https://docs.docker.com/engine/installation/">Docker</a>.</li></ul><h3>Build</h3><blockquote><em>NOTE: all command statements with multiple lines ignore the need for a newline escape.</em></blockquote><p>First, we need a dockerfile. Minimally, we need a docker file that looks like this.</p><pre>FROM microsoft/aspnetcore</pre><pre>LABEL name=&quot;NetCoreHello&quot;</pre><pre>ENTRYPOINT [&quot;dotnet&quot;, &quot;NetCoreHello.dll&quot;]</pre><pre>ARG source=bin/Release/netcoreapp1.1/publish</pre><pre>WORKDIR /app</pre><pre>EXPOSE 80</pre><pre>COPY $source .</pre><h3>Build image</h3><p>Next, let’s create a docker image of our web app.</p><pre>$ dotnet publish -c Release</pre><pre>$ docker build -t twitchax/netcorehello:v1 .</pre><p>If you would like, you can check that your image was built properly.</p><pre>$ docker run -p 80:80 -it twitchax/netcorehello:v1</pre><pre>Hosting environment: Production</pre><pre>Content root path: /app</pre><pre>Now listening on: <a href="http://+/">http://+:80</a></pre><pre>Application started. Press Ctrl+C to shut down.</pre><p>We can verify that our site is working by navigating to <a href="http://localhost/api/name/Aaron">http://localhost/api/name/Aaron</a> (or any endpoint in your app).</p><h3>Publish image</h3><p>Let’s publish our image to docker hub (though, you can use any container registry).</p><pre>$ docker login</pre><pre>$ docker push twitchax/netcorehello:v1</pre><h3>Create and deploy web app</h3><p>First, we need to do some setup if you have not already done so (some of these steps may have been completed before, but we need an --is-linux container).</p><pre>$ az group create -n DemoGroup -l westus</pre><pre>$ az appservice plan create -n DemoPlan -g DemoGroup --location westus --is-linux --sku B1</pre><pre>$ az appservice web create -n DockerNetCoreHello -p DemoPlan -g DemoGroup</pre><p>Finally, we need to configure our web app to run of our docker image.</p><pre>$ az appservice web config container update --docker-custom-image-name twitchax/netcorehello:v1 -n DockerNetCoreHello -g DemoGroup</pre><h3>Test</h3><p>You can use whatever method you prefer to test your new web app interaction with DocumentDB. In my case, I am using curl with <a href="https://msdn.microsoft.com/en-us/commandline/wsl/about">Bash On Windows</a>.</p><p>Get from an endpoint.</p><pre>$ curl http://https://dockernetcorehello.azurewebsites.net/api/hello/Aaron</pre><pre>{</pre><pre>    &quot;response&quot;: &quot;Hello, Awesome Aaron‽&quot;</pre><pre>}</pre><h3>Done</h3><p>That’s it! In about 10 minutes, we have dockerized our web app and deployed it to Azure!</p><p><em>Originally published at </em><a href="http://blog.aaroney.com/2017/05/05/Dockerize-your-Web-App/"><em>blog.aaroney.com</em></a><em> on May 5, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2eed7fa58cad" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azure-developers/dockerize-your-web-app-2eed7fa58cad">Dockerize your Web App</a> was originally published in <a href="https://medium.com/azure-developers">Azure Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The ultimate guide to setting up the Azure CLI on Windows]]></title>
            <link>https://medium.com/azure-developers/the-ultimate-guide-to-setting-up-the-azure-cli-on-windows-adeda6c6b7e1?source=rss----f16d2eae0c47---4</link>
            <guid isPermaLink="false">https://medium.com/p/adeda6c6b7e1</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Brian Benz]]></dc:creator>
            <pubDate>Fri, 17 Mar 2017 18:51:04 GMT</pubDate>
            <atom:updated>2017-06-06T14:58:31.508Z</atom:updated>
            <content:encoded><![CDATA[<p>The <a href="https://docs.microsoft.com/en-us/cli/azure/overview">Azure Command line interface</a> (CLI) is a great way to leverage the power of Azure from the command line, on Mac, Linux and Windows. But to realize even more potential it’s best to run the CLI in an environment that accesses Linux command line tools like grep, awk and sed. On windows, that means setting up the CLI to work with <a href="https://msdn.microsoft.com/en-us/commandline/wsl/about">Bash on Windows</a>. Below is a handy guide to making that happen, with a few tips and tricks to get you started quickly.</p><p>You can <a href="https://docs.microsoft.com/en-us/cli/azure/install-az-cli2">install the CLI</a> on whatever platform you use, including the Windows command line. However, when you try to execute a CLI command that uses Linux tools, you’ll likely get an error message, like this:</p><pre>az vm list — query “[].{name:name,os:storageProfile.osDisk.osType}” — out tsv | grep Linux</pre><pre>‘grep’ is not recognized as an internal or external command, operable program or batch file.</pre><p>I say you’ll <em>likely</em> get this message, because if you have <a href="https://git-for-windows.github.io/">git BASH</a> or <a href="https://www.cygwin.com/">Cygwin</a> installed, the operation may work. But the only <em>supported</em> way to integrate Linux command line tools and the Azure CLI on Windows is by installing Bash on Windows, then installing the CLI in that bash environment.</p><p>The first step is to install bash on windows via <a href="https://msdn.microsoft.com/en-us/commandline/wsl/install_guide">these instructions</a>. Once you have that set up, you can open Bash on Windows from a new Ubuntu icon added during the setup. You can also type bash from the regular command line (and exit to get back):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*cdZDiyPVMdklupOLoNo16Q.gif" /></figure><p>Note that I’m talking about the regular Windows command line and Bash as two different things — this is important because they <em>are</em> two different things. The official name is <a href="https://msdn.microsoft.com/en-us/commandline/wsl/about">Bash on Ubuntu on Windows</a>, and it’s actually Ubuntu Userland running inside Windows. Here’s a good overview of the details from <a href="https://www.linux.com/news/bash-windows-what-does-it-mean">Linux.com</a> and <a href="https://insights.ubuntu.com/2016/03/30/ubuntu-on-windows-the-ubuntu-userspace-for-windows-developers/">Ubuntu Insights</a>.</p><p>Now that bash is running on Windows, and you have the CLI installed on Windows, you can use the CLI, right? Not yet.</p><p>Here’s what you get when you try to type az, the base command for the CLI:</p><pre>az: command not found</pre><p>Remember in the last paragraph when I said that the regular command line and bash are two different things? This distinction is important. Remember that bash on Windows is running <em>on top of</em> windows, not as part of Windows. You need to install packages and dependencies like Python, even if you have Python installed in Windows already, before you install the the CLI.</p><p>For installation, you use the <em>Ubuntu Linux</em> commands, not the <em>Windows</em> commands. The easiest way to do this for the CLI is to follow the apt-get steps in the <a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli">install guide</a>, noting the latest prerequisites and dependencies before starting the CLI installation.</p><p>One important tip — if any of the installation commands fail with an unable to resolve host (none) error message, you need to update your hosts file with your machine name. If you’re an experienced geek, you know the Windows hosts file is at C:\Windows\System32\drivers\etc. But that’s not the hosts file you are looking for. You need to edit the hosts file that is used by the bash environment. Here are the steps:</p><p>In the bash environment, type sudo vi /etc/hosts</p><p>add 127.0.0.1 &lt;WindowsmachineName&gt; to the hosts file, then type</p><p># &lt;escape key&gt; :wq! to exit vi.</p><p>At this point remind yourself of the old joke:<br><em>Why are people still using vi?<br>Because they can’t remember how to get out of it.</em></p><p>OK, now back to work — To verify the Windows computer name was added, type:</p><pre>cat /etc/hosts</pre><p>Your hosts file should now contain these two entries:</p><pre>127.0.0.1 localhost<br>127.0.0.1 &lt;WindowsMachineName&gt;</pre><p>After completing the rest of the apt-get steps in the <a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli">install guide</a>, you should be able to type az and see this screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*i3y0xorlC-kPiz5xw-beLA.png" /><figcaption>Azure CLI</figcaption></figure><p>Now you’re running the CLI on Bash, and have access to all the power of Azure from the CLI, and Linux command line tools from bash on Windows!</p><p>One last tip — you can access files on your local machine from Bash for Windows by using the <a href="http://www.linfo.org/mnt.html">/mnt directory</a>. For example, if your documents directory is in the usual location in Windows (usually C:\Users\&lt;username&gt;\Documents ), you can access it here:</p><pre>/mnt/c/Users/&lt;username&gt;/Documents</pre><p>Now you’re ready to get started with the next recommended step — working with our <a href="https://docs.microsoft.com/en-us/cli/azure/?WT.mc_id=azurebg_ENAzureNewsletter_February&amp;mkt_tok=eyJpIjoiWmpJNE1XUXpNV1k0WkdOaiIsInQiOiJOaXk4S0xVMGVMOVB3Rmc4VmNlSStTeU1nVUlnZjB6WnJ6bEc5Z2JQUlpqXC9tRzRlK3Zlbm8reFBOVkY2MUNtejNqZUZSbHU5bVVHWHM5S2VBZ2pyQnc9PSJ9">documentation and samples</a>. Also, if you’re new to bash, search “bash cheat sheet”, pick one that is right for you, and keep it handy. The StackOverflow <a href="http://stackoverflow.com/questions/tagged/azure-cli">azure-cli</a> and <a href="http://stackoverflow.com/questions/tagged/bash">bash</a> tags could also be your new best friends. For direct feedback, you can also email the CLI team with CLI questions at <a href="/service/mailto:azfeedback@microsoft.com">azfeedback@microsoft.com</a>.</p><p>Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adeda6c6b7e1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azure-developers/the-ultimate-guide-to-setting-up-the-azure-cli-on-windows-adeda6c6b7e1">The ultimate guide to setting up the Azure CLI on Windows</a> was originally published in <a href="https://medium.com/azure-developers">Azure Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AutoRest architectural changes]]></title>
            <link>https://medium.com/azure-developers/autorest-architectural-changes-36c0a39f4774?source=rss----f16d2eae0c47---4</link>
            <guid isPermaLink="false">https://medium.com/p/36c0a39f4774</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[autorest]]></category>
            <category><![CDATA[open-api]]></category>
            <category><![CDATA[swagger]]></category>
            <dc:creator><![CDATA[Garrett Serack]]></dc:creator>
            <pubDate>Fri, 10 Mar 2017 21:26:27 GMT</pubDate>
            <atom:updated>2017-03-31T16:28:00.850Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ksDaxQyFWmz4VBtazCKCoQ.jpeg" /></figure><p>Recently, the team has been working on some rather big changes to the inside of the <a href="https://github.com/azure/autorest">AutoRest</a> code generator.</p><p>Off the top, we’re writing a VSCode language service for Swagger files and using AutoRest as the core of that. In order to do that, we had to get the .NET parts of AutoRest to run nicely on non-windows platforms. Over the last couple of months, we’ve moved the code base to .NET Core, and now have the ability to easily run binaries on Windows, Linux and MacOS.</p><p>Of course, in order to make it easy to distribute AutoRest on multiple platforms and work from inside our VSCode language service extension, the first step was to build a bootstrapper/front-end for AutoRest that handles all the platform-specific binary stuff, and exposes a common, front end that <em>just works right</em>.</p><blockquote><strong>What does ‘just works right’ mean?</strong><br>It’s important that the behavior of AutoRest is consistent, regardless of where you run it, or what platform you run it on. If you’re using the forthcoming VSCode extension, or running the command line, or getting the results from CI, you should see exactly the same thing.</blockquote><p>So, we’ve created an AutoRest package for nodejs, which acts as the bootstrapper of the behind-the-scene bits, and also exposes the interface to use <strong><em>AutoRest-As-A-Library </em></strong>(which … is how we’re going to be hooking it into the VSCode extension that we’re writing)</p><p>The net effect is that as of right now, you should be able to install AutoRest and use it by simply installing nodejs and running:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ca90befcdfacd5598a5e5a7105d4e8e/href">https://medium.com/media/4ca90befcdfacd5598a5e5a7105d4e8e/href</a></iframe><p>(<em>see: </em><a href="https://github.com/Azure/autorest/#installing-autorest"><em>Installing AutoRest</em></a><em> </em>for more information)</p><p>Behind the scenes, there are a lot of changes happening, and I’ll have to get into details about the various bits over a few articles, but the bottom line is that we’re going to be building a lot more of the core of AutoRest in TypeScript, and creating an extension model to allow anyone to extend/modify the behavior of AutoRest with simple plug-ins, which can be written in any language they choose (not tied to .NET anymore).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36c0a39f4774" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azure-developers/autorest-architectural-changes-36c0a39f4774">AutoRest architectural changes</a> was originally published in <a href="https://medium.com/azure-developers">Azure Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Level 0: Deploy Your Rails App on Azure]]></title>
            <link>https://medium.com/azure-developers/level-0-deploy-your-rails-app-on-azure-e7202828199?source=rss----f16d2eae0c47---4</link>
            <guid isPermaLink="false">https://medium.com/p/e7202828199</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[azure-cli]]></category>
            <category><![CDATA[iaas]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[David Justice]]></dc:creator>
            <pubDate>Thu, 16 Feb 2017 16:27:01 GMT</pubDate>
            <atom:updated>2017-06-06T14:58:45.730Z</atom:updated>
            <content:encoded><![CDATA[<p>In my previous post, I introduced the idea of a hypothetical DevOps maturity model. This post is going to illustrate Level 0 from that model.</p><p><a href="https://medium.com/azure-developers/a-prequel-to-open-source-application-development-on-azure-244dba30791e">A Prequel to Open Source Application Development on Azure</a></p><p>If you recall, Level 0 is basically pounding on keys until you have your software stack running on your server(s). There is no automation or testing of your infrastructure or deployment scripts, there’s no CI/CD pipeline to provision infrastructure and your servers are pets that need constant tender loving care. In this post we are going to mash some keys and deploy a simple Ruby on Rails application to an Azure virtual machine.</p><p>Please let me preface this post by saying this is <strong>not the most efficient way</strong> to deploy your Rails bits out to Azure, or any other remote compute resource for that matter. This post is simply to define all of the basics that are taking place as we mature the DevOps model in subsequent posts.</p><h3>Prerequisites</h3><ul><li>Ruby (<a href="https://rvm.io/rvm/install">https://rvm.io/rvm/install</a>)</li><li>Azure CLI (<a href="https://github.com/Azure/azure-cli">https://github.com/Azure/azure-cli</a>)</li><li>Github account</li><li>SSH key pair ~/.ssh/id_rsa{.pub}</li></ul><h3>Create our Rails API Application</h3><p>Let’s generate a simple Rails application, which we’ll deploy out to a VM running in Azure.</p><p>First off, create a <a href="https://github.com/new">new Github repository</a> specifying repo name level0. After the repo is created grab the clone URI as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*q54AOa6XXaUcm_R7x2b31g.png" /><figcaption>Clone with SSH</figcaption></figure><p>In this quick snippet, we clone the repository, install Bundler and Rails gems, create a new Rails application and then start the application running on localhost:3000.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bca5b9a1f6a9ad2618c5453007fa7085/href">https://medium.com/media/bca5b9a1f6a9ad2618c5453007fa7085/href</a></iframe><h3>Provisioning an Azure VM</h3><p>Now that we have a running Rails application, let’s provision our virtual machine to run our newly created Rails application.</p><p>Before we build the VM, let’s start with a bit of background on infrastructure in Azure. In Azure everything starts with a <strong>Resource Group</strong>. A resource group is a logical grouping of related Azure resources. Azure resources are the building blocks of your infrastructure. We’ll be building the following resources.</p><ul><li><strong>Virtual Machine</strong>: virtualized compute instance using managed storage</li><li><strong>Virtual Network</strong>: software defined cloud network</li><li><strong>Network Security Group</strong>: contains a list of access control rules that allow or deny network traffic to your VM instances</li><li><strong>Network Interface</strong>: is the interconnection between a VM and the underlying software network</li><li><strong>Public IP</strong>: publicly accessable IP endpoint</li></ul><p>I find it’s a best practice to keep all of an application’s Azure resources within a single resource group.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1cf8621f715b8408e81a93ea6410112/href">https://medium.com/media/f1cf8621f715b8408e81a93ea6410112/href</a></iframe><p>As you can see from the resource listing above, the az vm create command has created all of the basic resources needed for a publicly accessible VM. Now that the VM has been created, you can access the VM via ssh deploy@${publicIpAddress} where publicIpAddress is the address returned by az vm create .</p><h3>Configure the Azure VM</h3><p>Now that we have a provisioned a VM in Azure, we are going to configure this server to run our Rails application. The basic software we need to run our Rails application is the following:</p><ul><li><strong>Nginx</strong>: reverse proxy to balance incoming requests across multiple Rails processes running via Puma</li><li><strong>RVM</strong>: to manage and install Ruby versions (Ruby 2.4 at this time)</li></ul><p>The commands below should be run on the Azure VM after ssh’ing into the VM.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/058e1b3f8f067af422d5b202cc7ad7b8/href">https://medium.com/media/058e1b3f8f067af422d5b202cc7ad7b8/href</a></iframe><h3>Configure Capistrano Deployment in Rails</h3><blockquote>Capistrano is a framework for building automated deployment scripts. Although Capistrano itself is written in Ruby, it can easily be used to deploy projects of any language or framework, be it Rails, Java, or PHP. — <a href="https://github.com/capistrano/capistrano/blob/master/README.md">Capistrano</a></blockquote><p>We are going to take our vanilla Rails application and capify it. By leveraging Capistrano, it will help provide us a fast inner loop for develop, test and deploy.</p><p>Add the following to your Gemfile in the root of your Rails application.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a696161480f279e88ce3be9724277d33/href">https://medium.com/media/a696161480f279e88ce3be9724277d33/href</a></iframe><p>Run the following.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f66548ab43566064ffcdd1e54aaad2f7/href">https://medium.com/media/f66548ab43566064ffcdd1e54aaad2f7/href</a></iframe><p>Replace the contents of the newly created Capfile with the following.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a9bf1a7f1e62aed272a39afe985b5aa/href">https://medium.com/media/8a9bf1a7f1e62aed272a39afe985b5aa/href</a></iframe><p>At this point, we have a Capfile that will handle many of the Rails build / deployment tasks that can be kind of annoying such as using a specified verision of Ruby, installing gem dependencies from the Gemfile, pre-compiling of assets and git related tasks. Next, we’ll update our config/deploy.rb to prepare for our first deployment of the application.</p><p>Replace the contents of your config/deploy.rb file with the following deployment configuration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a3fe70da2c29f0119b907a83b8e18852/href">https://medium.com/media/a3fe70da2c29f0119b907a83b8e18852/href</a></iframe><p>The above deployment configuration automates and simplifies some boilerplate tasks such as:</p><ul><li>Ensure the latest git ref is up-to-date upon deployment</li><li>Restart or start Puma when new bits are deployed</li><li>Managing multiple release of the application for quick rollback</li><li>Run Rails in production mode</li><li>Link production secrets.yml file</li></ul><p>Now that we have our Capistrano deployment configuration described, we move on to our Nginx configuration. Create config/nginx.conf in the root of your application directory.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f59eeabb6d8efcf638c1d94b00fe1bd/href">https://medium.com/media/2f59eeabb6d8efcf638c1d94b00fe1bd/href</a></iframe><p>For more information about Nginx, check out <a href="https://www.nginx.com/">https://www.nginx.com</a>.</p><h3>Deploying your Rails Application</h3><p>All of our Rails deployment configuration is done. We now move onto deploying our application onto the VM in Azure.</p><p>Run the following commands to execute the initial deployment.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d34526d9ed449cc306e90b13c315a3e/href">https://medium.com/media/0d34526d9ed449cc306e90b13c315a3e/href</a></iframe><p>You should now be able to open your browser to the IP of the Azure VM and see your “Hello World” Rails application. If you want to keep going and continue to extend this application all you have to do is git commit , git push and cap production deploy . Enjoy!</p><p>If you’d like to pull down the code for this post, you can grab it here (<a href="https://github.com/devigned/level0">https://github.com/devigned/level0</a>).</p><h3>Next Up: Level 1 + Todo List</h3><p>We’ll extend this application to add functionality, data, a content distribution network (CDN) and ratchet the maturity level up to Level 1.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7202828199" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azure-developers/level-0-deploy-your-rails-app-on-azure-e7202828199">Level 0: Deploy Your Rails App on Azure</a> was originally published in <a href="https://medium.com/azure-developers">Azure Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add DocumentDB to your Web App]]></title>
            <link>https://medium.com/azure-developers/add-documentdb-to-your-web-app-9767c00cbfe0?source=rss----f16d2eae0c47---4</link>
            <guid isPermaLink="false">https://medium.com/p/9767c00cbfe0</guid>
            <category><![CDATA[azure-cli]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[documentdb]]></category>
            <dc:creator><![CDATA[Aaron Roney]]></dc:creator>
            <pubDate>Wed, 15 Feb 2017 22:34:59 GMT</pubDate>
            <atom:updated>2017-06-06T14:59:20.808Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s build add Add <a href="https://azure.microsoft.com/en-us/services/documentdb/">DocumentDB</a> to your Web App! We will be performing all operations using the <a href="https://github.com/Azure/azure-cli">Azure CLI</a>, and all of our work will be built using <a href="https://code.visualstudio.com/">Visual Studio Code</a> on <a href="https://msdn.microsoft.com/en-us/commandline/wsl/about">Bash On Windows</a>, Linux, Mac OS, or a container (we’ll containerize our app in a few weeks). If you have not already, make sure you have a <a href="http://blog.aaroney.com/2017/02/03/NET-Core-Web-App-in-Azure/">.NET Core Web App</a> ready to go!</p><h3>Prerequisites</h3><ul><li>[Required] <a href="https://github.com/Azure/azure-cli">Azure CLI</a> (<a href="https://docs.microsoft.com/en-us/cli/azure/install-az-cli2">install guide</a>).</li><li>[Required] <a href="https://www.microsoft.com/net/core">.NET Core</a> (<a href="https://github.com/dotnet/cli">CLI 1.0.0-rc4–004800+</a>).</li><li>[Required] <a href="https://azure.microsoft.com/en-us/free/">Azure Subscription</a>.</li><li>[Required] <a href="https://git-scm.com/downloads">git</a>.</li><li>[Required] <a href="https://docs.docker.com/engine/installation/">Docker</a>.</li></ul><h3>Build</h3><blockquote><em>NOTE: all command statements with multiple lines ignore the need for a newline escape.</em></blockquote><p>DocumentDB is one of the cutting edge features available in the Azure CLI, so we need to use a nightly (<a href="https://github.com/Azure/azure-cli/pull/1815">it’s on the way</a>). I am going to use <a href="https://www.docker.com/">Docker</a> to keep the latest version of Azure CLI separate from my system configuration. However, if you prever to use the latest build on your machine without Docker, you can <a href="https://github.com/Azure/azure-cli#nightly-builds">install the nightly</a>.</p><pre>docker run -it azuresdk/azure-cli-python:latest<br>az login<br>az account set — subscription “Aaron Personal (MSDN)”</pre><p>Next, let’s create a new DocumentDB instance. I am going to add friend-keeping functionality to my app. I want to keep a list of friends, and some information about them: name, email, phone number, etc.</p><pre>az documentdb create -g DemoGroup -n friendsdocdb</pre><p>We can then get the endpoint for the DocumentDB we just created.</p><pre>$ az documentdb show -g DemoGroup -n friendsdocdb<br>      --query documentEndpoint -o tsv<br><a href="https://friendsdocdb.documents.azure.com/">https://friendsdocdb.documents.azure.com:443/</a></pre><p>We will need this later, so keep it around.</p><h3>Connect your Web App to DocumentDB</h3><h3>Obtain the primary master key</h3><p>In order to connect, we need to get our primary master key for the DocumentDB.</p><pre>az documentdb regenerate-key -g DemoGroup -n friendsdocdb — key-kind primary<br>az documentdb list-keys -g DemoGroup -n friendsdocdb<br>    --query primaryMasterKey -o tsv</pre><p>We will need this later, so keep it around.</p><h3>Add some DocumentDB code</h3><p>Let’s add DocumentDB capabilities to our app by adding the proper NuGet packages to our project. I have created a nice little library called <a href="https://github.com/twitchax/DocumentDb.Fluent">DocumentDb.Fluent</a> which drastically improves the DocumentDB interaction experience in .NET.</p><pre>dotnet add package DocumentDb.Fluent<br>dotnet restore</pre><p>In any location, you need to create a static DocumentDB connection generator. I added a new class called Helpers and added my generator; in addition, I created an a Friend class as my document type.</p><pre>public static class Helpers<br>{<br>    private const string EndpointUri = &quot;&lt;your_endpoint_uri&gt;&quot;;<br>    private const string PrimaryKey = &quot;&lt;your_primary_key&gt;&quot;;</pre><pre>    public static IDocumentDbInstance DocumentDb =&gt;<br>        DocumentDbInstance.Connect(EndpointUri, PrimaryKey);<br>    public static IDatabase Db = DocumentDb.Database(&quot;Db&quot;);<br>    public static IDocumentCollection&lt;Friend&gt; Friends =&gt;<br>        Db.Collection&lt;Friend&gt;();<br>}</pre><pre>public class Friend : HasId<br>{<br>    public string Name { get; set; }<br>    public string Email { get; set; }<br>}</pre><p>Next, let’s convert the ValuesController (from our <a href="http://blog.aaroney.com/2017/02/03/NET-Core-Web-App-in-Azure/">.NET Core Web App</a>) into a FriendsController. I also decided to rename ValuesController.cs to FriendsController.cs.</p><p>You may notice that the <a href="https://github.com/twitchax/DocumentDb.Fluent">DocumentDb.Fluent</a> library makes all of the calls fairly simple and straightforward. If you prefer, each of the methods I call has a synchronous version, as well.</p><pre>[Route(&quot;api/[controller]&quot;)]<br>public class FriendsController : Controller<br>{<br>    [HttpGet]<br>    public IActionResult Get()<br>    {<br>        return Ok(Helpers.Friends.Query);<br>    }</pre><pre>    [HttpGet(&quot;{id}&quot;)]<br>    public async Task&lt;IActionResult&gt; Get(string id)<br>    {<br>        var friend = await Helpers.Friends.Document(id).ReadAsync();<br>        return Ok(friend);<br>    }</pre><pre>    [HttpPost]<br>    public async Task&lt;IActionResult&gt; Post([FromBody]Friend friend)<br>    {<br>        var doc = await<br>            Helpers.Friends.Document().CreateAsync(friend);<br>        friend.Id = doc.Id;<br>        return Created(doc.Id.ToString(), friend);<br>    }</pre><pre>    [HttpPut(&quot;{id}&quot;)]<br>    public async Task&lt;IActionResult&gt; Put(string id, <br>        [FromBody]Friend friend)<br>    {<br>        await Helpers.Friends.Document(id).UpdateAsync(friend);<br>        return Ok();<br>    }</pre><pre>    [HttpDelete]<br>    public async Task&lt;IActionResult&gt; Delete()<br>    {<br>        await Helpers.Friends.ClearAsync();<br>        return Ok();<br>    }</pre><pre>    [HttpDelete(&quot;{id}&quot;)]<br>    public async Task&lt;IActionResult&gt; Delete(string id)<br>    {<br>        await Helpers.Friends.Document(id).DeleteAsync();<br>        return Ok();<br>    }<br>}</pre><p><strong>Optional:</strong> to pretty print JSON, add a formatter to the middleware in Startup.cs that looks like this.</p><pre>services.AddMvc().AddJsonOptions(options =&gt; {<br>    options.SerializerSettings.Formatting = Formatting.Indented;<br>});</pre><h3>Test</h3><p>You can use whatever method you prefer to test your new web app interaction with DocumentDB. In my case, I am using curl with <a href="https://msdn.microsoft.com/en-us/commandline/wsl/about">Bash On Windows</a>.</p><p>Get friends.</p><pre>$ curl <a href="http://localhost:5000/api/friends">http://localhost:5000/api/friends</a><br>[]</pre><p>Add friend.</p><pre>$ curl -H &quot;Content-Type: application/json&quot; -X POST <br>      -d &#39;{ &quot;name&quot;: &quot;Chelsey&quot;, &quot;email&quot;: &quot;<a href="/service/mailto:an@email.com">an@email.com</a>&quot; }&#39; <br>      <a href="http://localhost:5000/api/friends">http://localhost:5000/api/friends</a><br>{<br>  &quot;name&quot;: &quot;Chelsey&quot;,<br>  &quot;email&quot;: &quot;<a href="/service/mailto:an@email.com">an@email.com</a>&quot;,<br>  &quot;id&quot;: &quot;d98ebc3f-67df-4152-a15a-1ad32d473ad1&quot;<br>}</pre><p>Update friend.</p><pre>$ curl -H &quot;Content-Type: application/json&quot; -X PUT <br>      -d &#39;{ &quot;name&quot;: &quot;Chelsey&quot;, &quot;email&quot;: &quot;<a href="/service/mailto:new@email.com">new@email.com</a>&quot; }&#39; <br>      <a href="http://localhost:5000/api/friends/d98ebc3f-67df-4152-a15a-1ad32d473ad1">http://localhost:5000/api/friends/d98ebc3f-67df-4152-a15a-1ad32d473ad1</a></pre><p>Delete one friend.</p><pre>$ curl -H &quot;Content-Type: application/json&quot; -X DELETE<br>      http://localhost:5000/api/friends/d98ebc3f-67df-4152-a15a-1ad32d473ad1</pre><p>Delete all friends.</p><pre>$ curl -H &quot;Content-Type: application/json&quot; -X DELETE <br>      <a href="http://localhost:5000/api/friends">http://localhost:5000/api/friends</a></pre><h3>Deploy</h3><p>Just as we did when we built our app, we can <a href="http://blog.aaroney.com/2017/02/03/NET-Core-Web-App-in-Azure/">deploy these changes to Azure with git</a>.</p><pre># Push this deploy directory to Azure.<br>git push azure master</pre><pre># Restart the app service (optional).<br>az appservice web restart -g DemoGroup -n AaronDemoHelloApp</pre><h3>Done</h3><p>That’s it! In about 10 minutes, we have added DocumentDB functionality to our web app!</p><p><em>Originally published at </em><a href="http://blog.aaroney.com/2017/02/11/Add-DocumentDB-to-your-Web-App/index.html"><em>blog.aaroney.com</em></a><em> on February 11, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9767c00cbfe0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azure-developers/add-documentdb-to-your-web-app-9767c00cbfe0">Add DocumentDB to your Web App</a> was originally published in <a href="https://medium.com/azure-developers">Azure Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a .NET Core Web App in Azure]]></title>
            <link>https://medium.com/azure-developers/net-core-web-app-in-azure-33b91f956140?source=rss----f16d2eae0c47---4</link>
            <guid isPermaLink="false">https://medium.com/p/33b91f956140</guid>
            <category><![CDATA[aspnetcore]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[azure-cli]]></category>
            <category><![CDATA[azure-websites]]></category>
            <dc:creator><![CDATA[Aaron Roney]]></dc:creator>
            <pubDate>Thu, 09 Feb 2017 01:00:46 GMT</pubDate>
            <atom:updated>2017-06-06T14:59:35.213Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s build a .NET Core Web App in Azure! We will be performing all operations using the <a href="https://github.com/Azure/azure-cli">Azure CLI</a>, and all of our work will be built using <a href="https://code.visualstudio.com/">Visual Studio Code</a> on <a href="https://msdn.microsoft.com/en-us/commandline/wsl/about">Bash On Windows</a>, Linux, Mac OS, or a container (we’ll containerize our app in a few weeks).</p><h3>Prerequisites</h3><ul><li>[Required] <a href="https://www.microsoft.com/net/core">.NET Core</a>.</li><li>[Required] <a href="https://azure.microsoft.com/en-us/free/">Azure Subscription</a>.</li><li>[Required] <a href="https://github.com/Azure/azure-cli">Azure CLI</a> (<a href="https://docs.microsoft.com/en-us/cli/azure/install-az-cli2">install guide</a>).</li><li>[Required] <a href="https://git-scm.com/downloads">git</a>.</li><li><a href="https://code.visualstudio.com/">Visual Studio Code</a>.</li><li><a href="https://msdn.microsoft.com/en-us/commandline/wsl/about">Bash On Windows</a>.</li></ul><h3>Build</h3><p>First, we are going to create a new .NET Web App. I am going to make a simple “Hello, World!” app. To your favorite <strong>shell</strong>!</p><pre>mkdir netcore_hello_world<br>cd netcore_hello_world<br>dotnet new -t Web</pre><p>Next, we need to test that our app works locally.</p><pre>dotnet restore<br>dotnet run</pre><p>At this point, your shell will block, and you can test your app by navigating to the URL specified (in my case, it is <a href="http://localhost:5000/">http://localhost:5000/</a>). Navigate to this URL, and you should see something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gNK10If7-iQtNUuP.png" /></figure><h3>Add a Web API endpoint</h3><p>I have always wanted to have a website respond to my name, so I am going to add a Web API enpoint to my app which will respond the way I want. You can add any endpoint you would like here, so have it respond in Klingon: it’s your app, do what you want.</p><p>Awesomely enough, ASP.NET Core web apps have Web API routing built in. In the Controllers directory, all I need do is simply emulate HomeController.cs to some degree. My new controller is going to be pretty simple since I just want to say “hello”. So, I simply create a new controller (Controllers/ApiController.cs), and I add my controller class to it (usings and namespace ommitted).</p><pre>public class ApiController : Controller<br>{<br>    [HttpGet]<br>    [Route(&quot;api/hello/{name}&quot;)]<br>    public IActionResult SayHello(string name)<br>    {<br>        if(name == &quot;Drumpf&quot;)<br>            return this.BadRequest(&quot;Drumpf?...Really?&quot;);</pre><pre>        var result = new { response = $&quot;Hello, Awesome {name}‽&quot; };<br>        <br>        return this.Ok(result);<br>    }<br>}</pre><p>You will notice a few key points here:</p><ul><li>[HttpGet] informs the runtime that this method represents an HTTP GET endpoint.</li><li>[Route(&quot;api/hello/{name}&quot;)] informs the runtime that the endpoint will be located at api/hello, and it takes a parameter, {name}. This name parameter is reflected in the method signature of SayHello.</li><li>By convention, we are returning an IActionResult, which allows us to easily send status codes with our content (e.g., this.Forbid, this.Ok).</li></ul><p>Next, let’s try our change. First, Ctrl+C to stop the local web server, and restart the server.</p><pre>dotnet run</pre><p>Navigate to the endpoint, and include your name (e.g., <a href="http://localhost:5000/api/hello/Aaron">http://localhost:5000/api/hello/Aaron</a>). You should see the expected response.</p><pre>{ “response” : “Hello, Aaron‽” }</pre><p>If “Drumpf” tries, we will get the expected error result (i.e., Drumpf?...Really?, with a 400 status code).</p><h3>Publish to Azure</h3><h4>Configure Azure CLI</h4><pre>az login<br>az account set<br>    --subscription &quot;Aaron Personal (MSDN)&quot;</pre><h4>Create a new web app on Azure</h4><p>Using the Azure CLI, we can easily create a new web app instance on Azure.</p><pre># Create a demo group for cleanup.<br>az group create<br>    -l westus<br>    -n DemoGroup</pre><pre># Create a shared app service plan ($10 / month).<br>az appservice plan create<br>    -g DemoGroup<br>    -n DemoAppPlan<br>    --sku D1 # F1 for free tier (no custom domains).</pre><pre># Name must be unique to all of Azure.<br>az appservice web create<br>    -g DemoGroup<br>    -p DemoAppPlan<br>    -n AaronDemoHelloApp</pre><p>Now, we can verify the host name of our newly created app.</p><pre>$ az appservice web show<br>      -g DemoGroup<br>      -n AaronDemoHelloApp<br>      --query hostNames --out tsv<br>aarondemohelloapp.azurewebsites.net</pre><p>Navigating to this address (i.e., <a href="http://aarondemohelloapp.azurewebsites.net/">http://aarondemohelloapp.azurewebsites.net/</a>) yields a default Azure web app screen.</p><h4>Deploy to Azure via git</h4><p>At the moment, we are just eager to get our app up on Azure. For now, we will configure deployment using local git.</p><pre>$ az appservice web source-control config-local-git<br>      -g DemoGroup<br>      -n AaronDemoHelloApp<br>      --out tsv<br>https://twitchax@aarondemohelloapp.scm.azurewebsites.net/AaronDemoHelloApp.git</pre><p>However, we need to create a username and password for this deployment endpoint. Let’s set our deployment credentials through the Azure CLI.</p><pre>az appservice web deployment user set<br>    --user-name twitchax</pre><p>You will be prompted to set a password, and that’s it for deployment authentication!</p><p>Now, we can push our app straight from our shell with git.</p><pre># Create a repository and make the first commit.<br>git init<br>git add .<br>git commit -m &quot;First commit!&quot;</pre><pre># Add the Azure endpoint (make sure to use your endpoint).<br>git remote add azure https://twitchax@aarondemohelloapp.scm.azurewebsites.net/AaronDemoHelloApp.git</pre><pre># Push this deploy directory to Azure.<br>git push azure master</pre><pre># Restart the app service (optional).<br>az appservice web restart<br>    -g DemoGroup<br>    -n AaronDemoHelloApp</pre><h4>Revel in your awesomeness</h4><p>Navigate to your azure domain address (i.e., <a href="http://aarondemohelloapp.azurewebsites.net/api/hello/Aaron">http://aarondemohelloapp.azurewebsites.net/api/hello/Aaron</a>) to test your deployment. It’s alive!</p><h3>Share (optional)</h3><p>At this point, we can share our domain name with the world! However, if we would like, we can fairly easily buy a custom domain and point that new domain (or a subdomain) at our new web app.</p><h4>Obtain a domain name</h4><p>Go buy a domain name. I mean, why not? Most of them are as low as <strong>$12 / year</strong>. I, personally, use <a href="https://domains.google/#/">Google Domains</a>, but you can use your favorite service.</p><h4>Configure CNAME with your registrar</h4><p>I added a CNAME record for helloapp.twitchax.com to aarondemohelloapp.azurewebsites.net. In Google Domains, you just find your domain and click “DNS”. Then, add a “custom resource record” which points to your web app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/0*856YwUxpeQrDakPO.png" /></figure><h4>Bind the hostname in Azure</h4><p>Azure requires that we specify which custom domains are allowed to point to our web app. So, back to the trusty Azure CLI, and we can bind to our custom domain name with one, simple command.</p><pre>az appservice web config hostname add<br>    -g DemoGroup<br>    --webapp AaronDemoHelloApp<br>    -n helloapp.twitchax.com</pre><p><strong>NOTE: There is currently a bug (</strong><a href="https://github.com/Azure/azure-cli/issues/1984"><strong>#1984</strong></a><strong>) in Azure CLI which prevents adding a host name, but a </strong><a href="https://github.com/Azure/azure-cli/pull/1985"><strong>proposed fix</strong></a><strong> is on the way! This same operation can be completed in the Azure Portal for the time being (Settings &gt;&gt; Custom domains).</strong></p><h3>Done</h3><p>That’s it! In about 10 minutes, we have built our web app and pushed it to Azure!</p><p>Next week, we will add some data to our web app, so stay tuned.</p><p><em>Originally published at </em><a href="http://blog.aaroney.com/2017/02/03/NET-Core-Web-App-in-Azure/"><em>blog.aaroney.com</em></a><em> on February 3, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33b91f956140" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azure-developers/net-core-web-app-in-azure-33b91f956140">Build a .NET Core Web App in Azure</a> was originally published in <a href="https://medium.com/azure-developers">Azure Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>