Anthony Chu Contact Me

Azure Resource Manager Templates Tips and Tricks

Sunday, October 11, 2015

Over the past week, I spent some time automating Azure App Service infrastructure with Azure Resource Manager (ARM) templates. I discovered a few tips and tricks along the way that I'll describe in detail below...

  • Take an environment name as a parameter
  • Create sticky slot settings
  • Variables aren't just for strings
  • Change the time zone of your web app

A big thanks to David Ebbo's talk at BUILD and his sample "WebAppManyFeatures" template; they are super handy resources for anyone who is working on writing their own ARM templates.

Continue Reading...


Walkthrough: Running an OWIN Self-Hosted Web API in a Windows Docker Container

Tuesday, September 1, 2015

When ASP.NET 5 and .NET Core were first announced, there was a lot of excitement over the ability to run ASP.NET in Docker containers on Linux.

But what about .NET 4.5 apps that only run on Windows? Well, they finally got some love with the introduction of containers support in Windows Server 2016 Technical Preview 3. Now we can run OWIN self-hosted apps in Docker containers on Windows.

While ASP.NET MVC 5 (not to be confused with MVC 6 on ASP.NET 5) cannot run without IIS, ASP.NET Web API and SignalR apps can (thanks to OWIN self hosting). In this article we'll go over how to create a self-hosted ASP.NET Web API app and run it in a Docker Windows Server Container.

Continue Reading...


Walkthrough: Provisioning an Azure Windows Docker Host Using Visual Studio

Sunday, August 30, 2015

Windows Server 2016 Technical Preview 3 was released on August 19. The biggest new feature is the support for Windows Server Containers and the Docker engine.

Microsoft's documentation suggests several ways to get access to Windows Server 2016 TP3 and configure it for use with containers; but none of them talks about how to access the machines removely. Docker Machine would simplify this a lot but it doesn't look like it works with Windows Server yet.

I have found that the simplest way to get started is actually to provision an Azure VM using the Visual Studio Tools for Docker. The Visual Studio tooling really makes it simple to spin up and configure a VM. It'll automatically:

  • Provision the server and related resources using an Azure Resource Manager (ARM) template
  • Configure the server to run containers and the Docker daemon
  • Generate and install certificates to access the machine remotely using the Docker client
  • Open ports 2376 (Docker daemon) and 80 (to simplify deployment of our first web container)

In this article, we'll go through how to set up a Windows Docker host in Azure using Visual Studio and connect to it using the Docker CLI to run some basic commands.

Continue Reading...


Parameterize Skip and Take SQL Queries with Entity Framework

Sunday, August 23, 2015

How SQL queries are generated by Entity Framework depends largely on how the LINQ queries are written. One example of this is how EF decides whether it will parameterize a query. Whenever possible, creating parameterized queries will allow SQL Server to cache a single version of a query and reuse the same execution plan for future executions of the same query that only differ by parameter values.

As a general rule of thumb, when EF parses a LINQ expression tree and it encounters a variable, it will create a parameterized query. When it encounters a constant, it will simply place the constant in the query it generates.

With the Skip(Int32) and Take(Int32) extension methods on IQueryable<T>, integers are passed into the methods and there is no way for EF to figure out if a constant or variable was passed in. For example, this LINQ expression:

context.Users.OrderBy(u => u.Id)
    .Skip(10)
    .Take(5)
    .ToList();

Continue Reading...


Site-Specific Git Deployment Credentials - Azure Web Apps

Sunday, July 19, 2015

Git is a popular way to deploy a web app to Azure. After setting up a local git repository, the portal seems to suggest that the only valid deployment credentials is tied to your Microsoft Account. This might be okay for adhoc deployments from your local machine; but you probably shouldn't use your personal credentials to deploy from a CI server.

Continue Reading...