That Conference 2015 and My ASP.NET 5 Talk

This week, I had the privilege to attend That Conference as a speaker to give a talk on ASP.NET 5. Here is a quick blog post on my conference experience.
2015-08-16 18:02
Tugberk Ugurlu


This week, I had the privilege to attend That Conference as a speaker to give a talk on ASP.NET 5. The conference is all done and dusted now. Also, I am tired traveling between Turkey, US and UK :) Even if I now want to lie down lazily all day long and do nothing else, I still want to write about my conference experience.

The Conference

2015-08-12 16.15.08

That Conference was a unique experience for me. It marked my first ever visit to US and I had a chance to visit two cities: Chicago and Wisconsin Dells. As for the conference, it is a well-organized family friendly conference. I can say that this might even be the best conference I have ever attended. I also had a chance to meet some great people like Steve Cleary, Ryan Niemeyer, Seth Juarez and many more that I already had known from the community. I also made some new friends like Anabella Watson and engaged in very interesting conversations with those. I will be definitely keeping in touch with them for sure!

It was a three days conference and in each day, there was a keynote held. The first day was very special but I missed it :s It was Uncle Bob giving the keynote that day. The second day was a bit different because the keynote speaker was an FBI agent (yes, #AchievementUnlocked!). Byron Franz talked about cyber threat during his keynote. The last day's keynote speaker was Max Lynch, the co-founder of Ionic. To be honest, I really liked the concept of having a keynote each day. It was really empowering to start each day with an inspiring session.

I really loved the concept of Open Spaces! You can just go and block an available time to hold a discussion on a topic and people who are interested in the topic will participate you for an hour to geek out on that topic. How amazing is that! You have 8 more choices if none of the sessions happening in a block is not interesting for you. The best part about the Open Spaces is that you engage in conversation with others and share experience. I had a chance to host one on DLM (Database Lifecycle Management) and it was really enjoyable:

2015-08-12 11.28.22

I also loved having 30 minute breaks between each session. There were no rush to catch sessions, it allowed speaker to engage conversations right after the session ends. The another advantage of this was that everybody were able to meet and talk to each other during these break. I absolutely loved this concept!

One bad thing about the conference is that the talks were not recorded :s There are so many great sessions going on at the same time and it's hard to choose. As the talks are not recorded for you to watch later, making decision on sessions was a bit more difficult. I am sure I had to sacrifice some great sessions.

My Session on ASP.NET 5

2015-08-12 14.29.03

I had a great time delivering my ASP.NET 5 talk. Even though it was the last session of the conference, there was a lot of interest in the topic. You can find the slides from my ASP.NET 5 talk under my Speakerdeck account and the project I have shown on GitHub. I also had bunch of interesting questions about ASP.NET 5, specifically how the the existing pieces fit into this new world. Some of those questions will make great blog posts here in my blog :) If you are specifically interested in the session topic, I gave the same talk at Progressive .NET Tutorials 2015 in London a month ago and it was recoded.

I also had a chance to join MS Dev Show podcast for a quick discussion on ASP.NET 5, which was really fun. You can check that out here.

Special Thanks

I would like to specifically thank Redgate for making it possible for me to attend the conference by covering and arranging all my travel. For the record, I am not exaggerating :) We have a Travel department at Redgate to basically handle everything about your trip. I also want to thank Chris Massey who runs the Conference Club at Redgate and helped me on getting better at presenting by giving his input on certain areas to improve. Finally, thanks That Conference people for inviting me to speak and organizing a very special conference!

Elasticsearch Array Contains Search With Terms Filter

Here is a quick blog post on Elasticsearch and terms filter to achieve array contains search with terms filter
2015-07-14 22:17
Tugberk Ugurlu


Here is a quick blog post on Elasticsearch and terms filter while I still remember how the hell it works :) Yes, this is possibly the 20th time that I looked for how to achieve array contains functionality in Elasticseach and it's a clear sign for me that I need to blog about it :)

I created the index called movies (mostly borrowed from Joel's great Elasticsearch 101 blog post) and here is its mapping:

PUT movies/_mapping/movie
{
  "movie": {
    "properties": {
       "director": {
          "type": "string"
       },
       "genres": {
          "type": "string",
          "index": "not_analyzed"
       },
       "title": {
          "type": "string"
       },
       "year": {
          "type": "long"
       }
    }
  }
}

The genres field mapping is important here as it needs to be not analyzed. I also indexed a few stuff in it:

POST movies/movie
{
    "title": "Apocalypse Now",
    "director": "Francis Ford Coppola",
    "year": 1979,
    "genres": ["Drama", "War", "Foo"]
}

POST movies/movie
{
    "title": "Apocalypse Now",
    "director": "Francis Ford Coppola",
    "year": 1979,
    "genres": ["Drama", "War", "Foo", "Bar"]
}

POST movies/movie
{
    "title": "Apocalypse Now",
    "director": "Francis Ford Coppola",
    "year": 1979,
    "genres": ["Drama", "Bar"]
}

Now, I am interested in finding out the movies which is in War or Foo genre. The way to achieve that is the terms filter as mentioned:

GET movies/movie/_search
{
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "terms": {
          "genres": ["War", "Foo"]
        }
      }
    }
  }
}

We will get us the following result:

"hits": [
   {
      "_index": "movies",
      "_type": "movie",
      "_id": "AU6OkygJidzUtyfB9L2D",
      "_score": 1,
      "_source": {
         "title": "Apocalypse Now",
         "director": "Francis Ford Coppola",
         "year": 1979,
         "genres": [
            "Drama",
            "War",
            "Foo",
            "Bar"
         ]
      }
   },
   {
      "_index": "movies",
      "_type": "movie",
      "_id": "AU6OkwUeidzUtyfB9L1q",
      "_score": 1,
      "_source": {
         "title": "Apocalypse Now",
         "director": "Francis Ford Coppola",
         "year": 1979,
         "genres": [
            "Drama",
            "War",
            "Foo"
         ]
      }
   }
]

What if we want to see the movies which is in War, Foo and Bar genres at the same time? Well, there are probably other ways of doing this but here is how I hacked it together with bool and term filter:

GET movies/movie/_search
{
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "bool": {
          "must": [
            { 
              "term": {
                "genres": "War"
              }
            }
          ],
          
          "must": [
            { 
              "term": {
                "genres": "Foo"
              }
            }
          ],
          
          "must": [
            { 
              "term": {
                "genres": "Bar"
              }
            }
          ]
        }
      }
    }
  }
}

The result:

"hits": [
   {
      "_index": "movies",
      "_type": "movie",
      "_id": "AU6OkygJidzUtyfB9L2D",
      "_score": 1,
      "_source": {
         "title": "Apocalypse Now",
         "director": "Francis Ford Coppola",
         "year": 1979,
         "genres": [
            "Drama",
            "War",
            "Foo",
            "Bar"
         ]
      }
   }
]

The exact match is a whole different story :)

Playing Around with Docker: Hello World, Development Environment and Your Application

I have been also looking into Docker for a while now. In this post, I am planning to cover what made me love Docker and where it shines for me.
2015-07-13 19:16
Tugberk Ugurlu


When you have a urge to blog about something, it's mostly the case that you have just learnt something :) Well, it's the case for me now. I have been looking into Linux space for a while now and I didn't expect it to go this smooth. It is wonderful and I must admit that I have been missing on too many nice stuff by sticking with Windows for my development environment. However, I have one thing, one big thing that I have no regret at all: .NET ecosystem. It's one of the great ecosystems to write application on top and as it's now so easy to get it into non-Windows environments, the entry door for those environments are now wide open to me.

I have been also looking into Docker for a while now and I was mostly trying to understand the concept as it's so distant to you if you were only developing on Windows for long time. After the concept was clear, the fun part started to take place. In this post, I am planning to cover that part and show you what made me love Docker.

Why Docker

Here is why I think Docker is useful for me (not much different than the other people's reasons):

  • Repeatable, declarative environments. This can get much better with Docker compose for your development, CI, QA (a.k.a. your Pre-Production) environments. 
  • Read, try and tear down when you are learning a new tool like Redis, RabbitMQ, etc. Just run the docker run command and create the container. Play with the tools on that container and remove the container at the end.
  • One way of deploying stuff. AWS, Azure, whatever. Wherever you go, you will use the same script to deploy your stuff.
  • Shifting your thinking to modularize the hell out of your solution (microservices, there I said it). This can open up insane opportunities. For example, developing each part of your application with the stack that is suitable for the job. Not only you will preserve your sanity by using the right tool but also you will have different parts inside your solution which can be developed separately by separate people who has different skill sets. I strongly suggest the .NET Rocks podcast on Building Microservices with Howard Dierking to understand more about this.
  • I am not sure about this but Docker also makes it really trivial for people to dockerize repro environments for issues.

There will be possibly more by these are the stuff that made me love Docker.

Hello World

I will assume that you installed Docker and you are ready to go. In my case here, I am using Ubuntu 14.04 LTS but I assume it should be the same on OS X as well.

As you can expect from Docker, the "Hello World" example is also declared and packaged up (A.K.A. dockerized). To get the "Hello World" example running, just run the below command:

docker run ubuntu:14.04 /bin/echo 'Hello world'

What happens when you do this is explained under Docker Hello World docs but briefly, you have a container based on Ubuntu 14.04 image and ran echo 'Hello World' in it and exited.

Screenshot from 2015-07-13 06^%10^%46

As mentioned, this container will not live after the echo is finished its job but it is still there to run. If you run the below command, you will see that container is there:

docker ps -a

Screenshot from 2015-07-13 06^%11^%51

We start the container by running the following command based on the container ID we retrieved from the docker ps output:

docker start --attach 6a174ac370a2

Screenshot from 2015-07-13 06^%17^%28

We also used --attach switch here to attach STDOUT/STDERR and forward signals and that's why we are able to see the hello world written in our console. Let's see a more realistic container example this time by getting an alive container up:

docker run -d ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"

This example is the exact same example you can find on "A daemonized Hello world" section of Docker Hello World doc. The interesting stuff here is the -d switch which tells Docker to run the container and put it in the background. If we run docker ps now, we should see that the container is still at the running state:

Screenshot from 2015-07-13 06^%38^%03

We can attach to a running container's STDOUT/STDERR by running the below command based on the container ID:

docker attach ff2847155ced

Screenshot from 2015-07-13 06^%39^%43

You can detach from the container and leave it running with CTRL-p CTRL-q.

Also, you should have noticed that the first run command we have run took a while to get it up because it downloaded all the images from the registry. However, the second one was instantaneous as Ubuntu 14.04 was already there. So, we can understand from here that Docker images are immutable and composable which is great. You can look at the images you have under your host by running docker images command.

Screenshot from 2015-07-13 06^%46^%10

Development Environment

As mentioned before, Docker makes it super easy to get stuff in and try them out. For example, Redis is on Docker registry and I can just run it as another container:

docker run --name my-redis -d redis:3.0.2

Screenshot from 2015-07-13 06^%59^%06

Screenshot from 2015-07-13 06^%59^%34

Screenshot from 2015-07-13 07^%01^%33

I am seeing here that the TCP port 6379 is also exposed which is the port that Redis is exposed. However, I need to know the IP address of this host to connect to this Redis instance from the host. We can figure out the IP address of a running container through the inspect command:

docker inspect --format '{{ .NetworkSettings.IPAddress }}' dfaf0cf33467

Screenshot from 2015-07-13 07^%08^%10

Now, I can connect to this Redis instance with redis-cli tool I have installed in my host:

redis-cli -h 172.17.0.10 -p 6379

Screenshot from 2015-07-13 07^%13^%38

I can play with this as long as I want and I can stop the container whenever I don't need it anymore. I can follow this process for nearly everything (e.g. Ruby, GoLang, Elasticsearch, MongoDB, RabbitMQ, you-name-your-thing, etc.). For example, get yourself a python development environment, you can run the following docker run command:

docker run -t -i python:2.7.10 /bin/bash

This will get you an interactive container with Python installed in it and you can do anything you want with it:

Screenshot from 2015-07-13 07^%37^%25

When you’re done you can use the exit command or enter Ctrl-D to finish your interactive session inside the container and effectively stop the container. This container is still in your easy reach. You can start it again by obtaining its ID by running docker ps -a and running the start command with the container ID.

You might wonder how tools like Redis, MongoDB and Elasticsearch fit into this world as they need to persist data on disk but Docker containers in nature are created and torn down without any worry. This is a well-thought problem and Docker has a solution for this problem with Data Volumes.

Your Application

This is all great and shiny but where does our application fit into this? There are some many different approaches that you can take with Docker for your application but let me show you a straight from and a powerful approach which will possibly give you an idea.

For an application example, I have chosen to dockerize Octopus Deploy Library web application which works on top of Node.js. The way to achieve this is through the Dockerfile. It has a well written documentation and here is how the Dockerfile for Octopus Deploy library would look like:

FROM node:0.12.7

RUN ["npm", "install", "gulp", "-g"]
RUN ["npm", "install", "bower", "-g"]
RUN ["npm", "install", "grunt-cli", "-g"]

COPY . /app
WORKDIR /app

RUN ["npm", "install"]
RUN ["bower", "--allow-root", "install"]

EXPOSE 4000

ENTRYPOINT ["gulp"]

In my opinion, self-descriptiveness is the the best part of this file. We are defining here that the application image should be based on node:0.12.7 image, which has node.js stuff in it. Then, we run a few npm commands to install what we need. Later, we copy our stuff and change the working directory. Lastly, we install dependencies, expose the TCP port 4000 and specify the entry point command.

Octopus Deploy does its magic and gets the server up when you run gulp default task. That's why it's our entry point here.

We can now build our application image:

docker build -t octopus-library .

Screenshot from 2015-07-13 08^%33^%50

This kicks off the build and creates the image if everything goes well. Lastly, we can get the container up and running under our host using the same run command:

docker run -t -d -p 4040:4000 octopus-library

We use -p option here to map the internal 4000 TCP port to 4040 TCP port of the host. With this way, you can access the running application from the host through 4040 TCP port:

Screenshot from 2015-07-13 08^%50^%02

You can repeat the same steps by cloning my fork of Octopus Library and switching to docker branch.

Resources

Progressive .NET Tutorials 2015 and Recording Videos of My ASP.NET 5 Talks

Last Friday, I was at Progressive .NET Tutorials 2015 in London and I gave two talks on ASP.NET 5. Here are the recording videos and slides of my two ASP.NET 5 talks!
2015-07-07 21:45
Tugberk Ugurlu


Last Friday, I was at Progressive .NET Tutorials 2015 in London and I gave two talks on ASP.NET 5. The conference was really good, I had a chance to meet with new great people. One nice thing about this conference is that the sessions were recorded. You can check out all the recordings here. My two talks on ASP.NET 5 were also recorded:

ASP.NET 5: How to Get Your Cheese Back

Slides for this talk is also available under my Speakerdeck account:

Going Further with ASP.NET 5

Here are the links to several resources related to these talks:

Enjoy! :)

Slides of Introduction to Database Lifecycle Management Talk at /dev/summer 2015

Yesterday, I was at /dev/summer 2015, Cambridge and gave a talk on DLM (Database Lifecycle Management). I have uploaded the slides under my Speakerdeck account.
2015-06-28 11:57
Tugberk Ugurlu


Yesterday, I was at /dev/summer 2015, Cambridge. It was a really good event and I had a chance to attend a few talks on Go Language, Web Profiling and Open Source.

2015-06-27 16.36.26-1

2015-06-27 12.46.58

2015-06-27 11.40.33

I also gave a talk on DLM (Database Lifecycle Management), which is what we have been working at Redgate for a while to make it easy to adopt.

2015-06-27 16.31.18

I have uploaded the slides under my Speaker Deck account.

Also, here are the links I have at the end of the slides and a few more:

Tags