Friday, October 29, 2010

Windows Azure Update

I thought I know a lot about Windows Azure! But PDC 2010 Key Note totally changed my view. The Windows Azure team seems to have done a tremendous work lately! Really tremendous! And once again, Microsoft proved that they listen to community, listen to what do we want.

Here is a list of features that will soon be available, but I suggest that you watch at least the keynote of day one (http://player.microsoftpdc.com)! If you want to fast forward to the Windows Azure part – go to straight to 1hr 20 min:

  • Elevated privileges
  • Full IIS
  • Remote Desktop
  • VM Role
  • New, much richer and better management portal

… much much more!

I have no patience to get my hands on it!

Don’t miss to visit the Windows Azure team blog!

Saturday, October 23, 2010

Microsoft Productivity Power Tools for Visual Studio 2010 has been Updated

It’s great that we have this feature pack from Microsoft and they are constantly improving it. Just go and download latest version from here.

Productivity Power Tools features at a glance:

  • Solution Navigator.
    A powerful tool windows which merges functionality from Solution Explorer, Class View, Object Explorer, Call Hierarchy, Navigate To and Find Symbol references!
  • Tab Well UI.
    Working with multiple files has never been easier with Tab Well UI. The feature I used the most – Pinned tabs. It allows you to pin certain files so you never lose them :)
  • Searchable Add Reference dialog.
    My favorite! Your default add reference dialog is changed to better user experience. Never scroll for assembly! Just search for it!
  • HTML Copy
    Another favorite. Never have to use external tools or add-ins! Just select any code and copy it! It is automatically copied as HTML. If you paste in RTF editor – your code is recognized. If you paste it in plain text editor – no bloating HTML is pasted, as well as if you paste inside Visual Studio.

There are so much more features, just go and get it! It’s free!

Saturday, October 9, 2010

Equivalent of Unix’s ls –lah | grep something for Windows

Hello, ever since I am using linux based platforms I loved them for the rich command shell. It’s been very easy for me to find what I am looking for using command piping and the grep command. A very common combination that I’ve been through is “ls –lah | grep something”, which searches for specific file in current folder. Or “ps –ax | grep processname” which searches for specific processanme in the list of all running processes. Recently I had to, on Windows OS, very often run “netstat –an” to search whether specific port is occupied and by which executable. However that Windows OS is Windows Server, and it has lots of services running, so finding a specific port was terribly hard. A quick search gave me desired result.

You can use Windows’ command “find” exactly the same way you use “grep” in linux/unix! So finding a specific port occupation is like that:

netstat –anb | find “:80”

this will list all “:80” in the list, which basically means – all 80 ports occupied!

Great stuff!

Friday, October 8, 2010

Convert video files in Windows Azure /using FFMPEG/

There was a question on the Windows Azure MSDN forums, that pushed me to do that sample! The question is “Can I use Windows Azure environment to convert video files”. The simple answer is "YES”! But how to achieve that?

Frankly, I was thinking on that for a while. Yes, I really was! I’ve been using FFMPEG in my projects, but Linux based with PHP. I was wandering how it works on Windows OS. And the time to figure that out came!

I created a very very light demo project on how to process video files using FFMPEG in Windows Azure, you can download it from here.

What you have to know – FFMPEG windows binary is single executable which brings all codecs (up to release date) with it. You have to put it in you Azure role (worker role preferably) and execute it via the Process.Start(ProcessStartiInfo psi) overload method. I have included the binary and a sample video for your convenience!

Here is what I do:

            Assembly asm = Assembly.GetExecutingAssembly();
            string path = asm.Location;
            path = path.Substring(0, path.LastIndexOf(@"\")+1);
            //path = path + "ffmpeg\ffmpeg.exe";
            string tmpName = Path.GetTempFileName();
            tmpName = tmpName.Substring(0, tmpName.Length - 4);
            tmpName = tmpName + ".flv";
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = string.Format(@"""{0}ffmpeg\ffmpeg.exe""", path);
            psi.Arguments = string.Format(@"-i ""{0}ffmpeg\MVI_1042.AVI"" -y ""{1}""", path, tmpName);
            psi.CreateNoWindow = false;
            psi.ErrorDialog = false;
            psi.UseShellExecute = false;
            psi.WindowStyle = ProcessWindowStyle.Hidden;
            psi.RedirectStandardOutput = true;
            psi.RedirectStandardError = true;        
            try
            {
                // Start the process with the info we specified.
                // Call WaitForExit and then the using statement will close.
                using (Process exeProcess = Process.Start(psi))
                {
                    StreamReader output = exeProcess.StandardOutput;
                    StreamReader error = exeProcess.StandardError;
                    exeProcess.WaitForExit();
                    string outString = output.ReadToEnd();
                    string errString = error.ReadToEnd();
                    Trace.WriteLine(outString);
                    Trace.TraceError(errString);
                    byte[] fileBytes = File.ReadAllBytes(tmpName);
                }
            }
            catch(Exception e)
            {
                Trace.TraceError(e.Message);
            }

Of course, you can upgrade a lot of thing of this demo application, but it was create in just couple of minutes! One thing you may want to consider is using Azure Blob as store for your executable! Each time you start a conversion process, just check the blob if it is changed. Thus you will be able to update to the most recent version of FFMPEG without even touching your deployed Azure Service!