Flipping a random bit

21May/130

Developing with Windows 8 Hyper-V

Windows 8 Hyper-V is the best thing since Sinclair ZX Spectrum for a developers. As a consultant I love one VM per customer setup. As I tinker with various tech it’s nice to have clean environment to play with. This is how I have configured my ThinkPad W530 Hyper-V with Windows 8 Pro.

Install

Before enabling Windows Hyper-V, you should check if your system supports it by running the CoreInfo utility as an administrator. “Coreinfo –v” will show 3 things. If you see the EPT and * you are good to go. If you need to drop into your BIOS from Windows 8, to enable Virtualization, you can restart in advanced mode: WindowsKey + C –> Settings –> Change PC Settings (on the bottom) –> General –> scroll on the bottom Select Restart under Advanced Startup.

When the Advanced Options boot comes up select : Troubleshoot - > Advanced Options -> UEFI Firmware Settings -> Restart -> Under Security / Virtualization -> Enable VT and VT-d (this is on BIOS on my TP W530)

Of course you can jump into BIOS other ways in your POST before Windows start (Lenovo it’s Enter).

Installing and enabling Hyper-V on windows is accomplished via WindowsKey + C –> Control Panel –> Programs –> Turn Windows Futures On or Off.


image

After you get everything configured you can open Hyper-V manager and connect to your local box.

My Configuration / Phylosophy

First get all the memory you can get for the laptop. I have 32Gb and I have 500GB secondary drive where I store all my VHD’s and VHD library.

Storage setup

On this disk i have VM folder with few sub folders:

image

 

 

 

 

 

 

Clients folder purpose is to have client specific VM setups. Disk is where all VM’s disks go. VHD Library is where I have my base VHDX files. Virtual Machines is the rest of my VM’s I play with.

image

To keep this kind of disk topology you can configure it inside Hyper-V settings when you right click your server name.

image

Network Setup

Right click your server name in the Hyper-V manager and select Virtual Switch Manager. I have 3 networks setup: internal, wired and wireless. Here are all 3 screen shots

image

image

image

There is one more thing to do with Wireless setup. You need to bridge the WiFi and External via Wireless adapters. Go to Control Panel\Network and Internet\Network Connections – select WiFi and Ctrl+Select External via Wireless and right click Add To Bridge.

VM Configuration

First create a base VM. I have two. One with plain OS and one that is Developer pre-loaded e.g. VS 2012. These base images you will use in every VM. There is a catch. You can never change these base images otherwise all your VM’s that use base image will be corrupted. Not ideal but not so bad either.

Setup each of my VM’s consists of System – C.vhdx which is a Differencing disk and I have another disk Development – D where all the files I want to preserve will be stored. My expectation is that C drive can be destroyed at any time while Development disk can be detached and maybe attached to some other VM.

image

To setup new VM here are the steps I go through:

  1. Create new Differencing disk (VHDX)
  2. Name it [something you can recgonize] – System e.g. “Clear Lines – System.vhdx”
  3. Select your base VHDX – these are created previously from VHD Library Folder
  4. Create new VM
  5. Use 1024 startup memory
  6. Use Dynamic Memory
  7. Select Internal, Wired or Wireless or none (you can change it later)
  8. Use existing Virtual Disk (Clear Lines – System.vhdx)
  9. Open Settings of your newly created machine
  10. Add secondary drive under SCSI controller e.g. “Clear Lines – Develpment.vhdx”

image

Now you can start your VM. At this step you could be done but I recommend that you run sysprep on the newly created VM. When you do so you will need the key to active syspreped OS.

To sysprep drop to admin command prompt WindowsKey+X. Navigate to C:\Windows\System32\Sysprep\ and type sysprep. After pressing enter you will get following window:

image

Tips

Updating base image

I mentioned above that once you have base image you will not be able to change it because it will break all the VMs that depend on it. While this is unfortunate I don’t see this a big deal. I wait until there are about 50-60 windows updates and then update the base image. After that I have to re-create the system drive of each VM. This might seem crazy but its fast to do. In the same time I add other goodies to my base machine like refresh of NugetLocal cache of all packages (how to: here, here, here).

Accessing VM

If you double click the VM you will open Virtual Machine Connection manager. This thing is just weird. You cannot pass your clipboard to it. You have to use the menu (exit full screen mode) select Clipboard menu and then Select paste. Instead you can use regular RDP client and connect to VM via IP. You can find the IP of the VM in the Networking tab:

image

You should adjust your VM display resolution to max so that it fits in the Connection Manager. You might need to try few settings.

Accessing Host from VM

If you are on the plane and need to access the host switch to Internal network. After that you can open Windows Explorer and navigate to your host via Network or just \\[your box name].

Accessing USB drives attached to the Host

This one is PITA. Plug your USB drive. Open Disk Manager WindowsKey+X. Right click on the disk and take it offline.

image

Now, go to settings of your VM. Select SCSI interface and new disk. Select Physical drive and select your USB drive. You can do this while VM is running (must be SCSI interface thought).

image

Hopefully you find this useful. If you have any other tips and/or setup configurations let me know. I will try to add others as I remember them

Filed under: Tips & Tricks No Comments
14Feb/130

Setting WCF diagnostics quickly

There are fair amount of questions on SO where diagnosing problems with WCF is nonstarter because we need lot more information about the problem. To gather some details for the reason WCF is not functioning correctly on the server or the client you can turn on WCF diagnostics on your service to get more details about exceptions.

To get you going quickly - in your web (or app) config:

1) Add System.Diagnostics section anywhere under configuration element. You can replace path with which ever path you want the files to be stored at.

<system.diagnostics>
    <sources>
      <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelMessageLoggingListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
      <source name="System.ServiceModel" switchValue="Warning, ActivityTracing" propagateActivity="true">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelTraceListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="C:\temp\services_messages.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelMessageLoggingListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
        <filter type="" />
      </add>
      <add initializeData="C:\temp\services_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack">
        <filter type="" />
      </add>
    </sharedListeners>
</system.diagnostics>


2) Under system.ServiceModel add following:

<diagnostics wmiProviderEnabled="false">
      <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>

 

3) Under C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\ start SvcTraceViewer.exe. Load both message trace (services_messages.svclog) and service trace log (services_tracelog.svclog). You can either drag drop files in the tool or open one then add another

4) Look for red bold letters for a problem.

If you want to make your experience editing the WCF configuration more palatable you can use SvcConfigEditor.exe which is found under same folder as SvcTraceViewer.exe (#3). Just open the config file and you should see Diagnostics folder which will allow you to start/stop and configure diagnostics.

Filed under: WCF No Comments
2Jan/130

Kick start your responsive Web by hosting it on the Azure Web Site

The Azure ecosystem under Scott Guthrie’s stewardship has brought us yet another excellent addition to the Azure offering: the Azure Web Site. What I am most excited about in this offering is the deployment speed and simplicity. There are tons of other things that are very attractive… The Azure portal re-design is now rocking. The Azure Web Site dashboard shows you right away the useful information in one place. The Deployment options are numerous. Configure and Scale simplify the most common reason to tweak your site. Web Role is still there, but this opens up scenarios where you do not need Web Role’s fire power.

If you are a developer or an IT professional or if your hosting provider does not meet your needs, you should sign up for a free account (which gives you a lot of free stuff to play with). One of the perks with a free account is the ten (10!) free Web sites which should stay perpetually free! Listen to Scott Guthrie’s key note from Azureconference.net at 25th min (although you should listen the entire key note). I have republished the Web Site Offering Feature Comparison at the bottom of this article (Azure pricing details page has more information) for easier reference.

To get on board with the Azure Web Site we can take two paths, depending on what you use to write your code. If you are using Visual Studio, things are simple: just download the publishing profile (under quick glance) and import it to Visual Studio.

image

Now you have everything you need to publish to the Azure Web Site. Right-click on your Web project, select Publish and magically your code will be beamed to the Cloud. Publishing dialog has been improved a lot too. Hitting “Start Preview” you can actually see the differences between your local copy and what’s being deployed on the Cloud.

image 
If you are using another IDE, you can use FTP, Git or a few other available providers. I have experimented with Git and it seems very simple and usable. If you are new to Git, the deployments section of the Azure Web Site will explain how to deploy using Git under “Push my local files to Windows Azure”. Deployment is triggered by a simple push to the repository provided by the Azure Web Site. You push, they deploy.

What do you need to get that modern web site started?

Infrastructure:

  • IDE - My development weapon of choice is Visual Studio 2012.
  • An Azure trial account or a MSDN license if you have one.
  • Turn on Web Site Preview – Under Account / Preview Features. This option might not be active anymore because this feature could be already part of the standard offering.

Some helpful software and tools that I use:

  • Responsive web framework – there are at least half-a-dozen of these. I am using Twitter’s Bootstrap
  • LESS - The dynamic style sheet language
  • Mindscape Work Bench – LESS/SASS editor/generator
  • Live page load profiler – mini profiler
  • ELMAH – essential in debugging and exception management
  • Route Debugger – helpful with debugging
  • Glimpse – FireBug-like experience within the page
  • WebGrease – a suite of tools for optimizing javascript, css files and images
  • momentjs.com – library to help you working with time constructs in JavaScript

That’s all for now. Let me know what you think. Also, I am curious to hear from you what problems you are solving using Azure (PaaS, SaaS or IaaS).

WEB SITE OFFERING FEATURE COMPARISON

FEATURE FREE SHARED RESERVED
Custom domain name No Yes Yes
Sites 10 per sub region 100 per sub region 100 per sub region
Storage 1 GB per sub region 1 GB per sub region 10 GB per sub region
Storage transactions Included at no charge Included at no charge Included at no charge
Relational database 20 MB of MySQL database per sub region. Shared by all web sites 20 MB of MySQL database per sub region. Shared by all web sites 20 MB of MySQL database per sub region. Shared by all web sites
Data transfer inbound Free Free Free
Data transfer outbound Limited to 165MB per day per sub region, up to 5 GB per region Billed at standard Pay-As-You-Go rates after the initial 5GB* Billed at standard Pay-As-You-Go rates after the initial 5GB*
CPU Up to 60 minutes of CPU cycles per day Up to 240 minutes of CPU cycles per day Dedicated CPU instances
Price Free $0.013** per hour (preview); $0.02 per hour (general availability) $0.08-$0.32 per hour (preview); $0.12-$0.48 per hour (general availability)
Filed under: Azure No Comments