Remote Debugging On Azure

I decided that I needed to learn a bit about remote debugging on Azure.  I know that you are supposed to use the Azure emulator to hash out your problems before hand, but I still would like the ability to debug remotely in case the need comes up.

I Googled on Bing how to do it and I ran across this article that seems to be a good place to start.  It looks like I need to upload the VS2010 remote tools to Azure as a necessary but not sufficient step.  The thing is, I have no idea how to do that.  Do I upload the tools only once to my azure account?  Is it site && project specific?  I don’t know and Binging on Google doesn’t seem to help.

I then looked at this article but it assumes that I am using a Virtual Machine and installing the MSVSMON.exe to the VM.  If that was the case, I would just install VS2010 to the VM and debug there.  So that article is of no help.

I am stuck on this line of the 1st article: “You can find the tools on Microsoft Download Center here, and then upload to your storage account using whatever Windows Azure Storage account tool of your choice. “  Going over to my Azure account, I see a “Storage” section.

So I create a new storage like so:

image

The illogical meter is running high.  Why should I need to install Data Services to install MSVSMON?  I can do Computer-> Cloud Service, but that us the same as creating a Cloud Service.

I decided to work in the other direction.  I created a new Azure hosted WCF Service in VS2010 like so:

 

image

 

and after the default template of this:

image

I changed Service1 name and then added a single method that returns the sum of two numbers:

public class AddingMachine : IAddingMachine
{
    public Int32 Add(Int32 number1, Int32 number2)
    {
        return number1 + number2;
    }

}

I then deployed his to the Azure server via Visual Studio – 1st I set up the deployment parameters

image

 

Then I added a certificate

image

And during the deployment I got this:

image

After a couple of minutes, I got the site up on Azure:

image

Which I assume might be the way to remote debug?  I then hit myself in the head that the Build Configuration is Release (the default) and not debug and I need the debug symbols to remote debug.  I deployed again and then I opened attach to process in Visual Studio:

image

I then pumped in the name of the site:

image

Doh!

Time to go to Brian Hitney’s office hours!

Data Transfer using WCF

So forgetting OData for a minute (not hard to do), I was thinking about how to transfer SDO classes to and from a WCF service.  All of the WCF projects I have worked on have been POCOs with the appropriate WCF attributes from System.ServiceModel and System.Runtime.Serialization.  I never thought about putting an ADO.NET recordset as a return value from a WCF method.  I also wondered about putting the recordset as a parameter to a WCF method.  I assume it is possible, I was curious about how much effort it would take.  I Binged on Google (or was it Googled on Bing) and these was nothing that jumped out.

I fired up a typical WCF project and then added a consuming console app to the solution.  I then wrote an interface that returns a dataTable like so:

[ServiceContract]
public interface IDataFactory
{
    [OperationContract]
    DataTable GetDataTable();
}
public class DataFactory : IDataFactory
{
    public DataTable GetDataTable()
    {
        throw new NotImplementedException();
    }
}

I then hit F6 and sure enough it compiled.  I then changed the implementation to this

public DataTable GetDataTable()
{
    DataTable dataTable = new DataTable();
    dataTable.TableName = "Customers";
    dataTable.Columns.Add("CustomerId");
    dataTable.Columns.Add("CustomerName");

    DataRow row1 = dataTable.NewRow();
    row1[0] = 1;
    row1[1] = "Customer #1";
    dataTable.Rows.Add(row1);
    DataRow row2 = dataTable.NewRow();
    row2[0] = 2;
    row2[1] = "Customer #2";
    dataTable.Rows.Add(row2);

    return dataTable;

}

and I am still compiling.  So then I went to the client and added a reference and it worked:

image

I then fired up the client like so:

static void Main(string[] args)
{
    Console.WriteLine("Starting");

    DataFactoryClient client = new DataFactoryClient();
    DataTable table = client.GetDataTable();

    foreach (DataRow row in table.Rows)
    {
        Console.WriteLine(String.Format("Customer {0} named {1}.",row[0],row[1]));
    }

    Console.WriteLine("Ending");
    Console.ReadKey();
}

And I hit F5:

image

 

Wow.  Microsoft made this stupid simple.

I then though about how to pass in an individual data row. 

[OperationContract]
String InsertDataRow(DataRow row);
public String InsertDataRow(DataRow row)
{
    return String.Format("You entered {0}.", row[0].ToString());
}

And when I hit update reference from my consuming app, I got this:

image

Crud!  I then thought I could just add a serializable data row like so:

[Serializable]
public class SerializableDataRow: DataRow
{
}

And this:

[OperationContract]
String InsertDataRow(SerializableDataRow row);

But no, I get this:

image

So now I have to jump down a rabbit hole and possible violate the Liskov Substitution Principle.  Since I want things to be stupid simple, I gave up with inheritance.  I then found this post.  So either use a datatable (and suffer the overhead) or convert the DataRow into something that can be seialized (like XML, custom classes, etc..)

So I give Microsoft a C on this – somewhat stupid simple, but not entirely…

Web Stress Tests: Part 2

Now that I have a web performance test that is run repeatedly by the loadtest, I want to alter a couple of things.  First, I want to change the Url from local host to another environment.  In my case, WinHost.  Here are the two Urls:

http://localhost:3002/AddingMachine.svc
http://www.tenfingersfree.com/tff/AddingMachine.svc

To allow the Url to be configurable, I want into the Web Text Editor and pressed on the parameterize Web Servers button

image

After this dialog box:

image

The Web Test in the project auto-magically puts in a parameter into its Url property

image

I then updated the Url to include the service name

image

I then ran my web test and it failed.

image

Apparently, I don’t need the service name in there.  Taking it out gives me green.

I then swapped in the WinHost web server and I still get green

 

So the next thing I want to make dynamic are the input parameters.  To that end, I created a notepad file like so:

image

I then changed the extension to .csv and imported it into the web test via the Add Data Source button on the test

 

image

It looks by default it assumes the 1st row is a column heading.  The only thing I changed from the default is the access method property of the table to random:

image

I now have to get these values into the String Body.  The MSDN documentation assumes that I will be altering input via the query parameter or the post parameters.  I am not doing that, I need to update the String Body.

image

to

image

When I ran it, I got this:

image

I then binged into this article that showed me how my data source syntax was wrong and how to get the correct syntax generated for me:

 

image

 

And I updated the string body like so:

image

And sure enough – different numbers thrown at my web service:

image

Wahoo!

Web Performance Test

 

So I decided I wanted to learn more about the testing capabilities of VS2010 – esp. load testing a web service.  I fired up Visual Studio and created an out of the box WCF Service with the following 1 method:

public class AddingMachine : IAddingMachine
{
    public int GetData(int value1, int value2)
    {
        Random random = new Random();
        Int32 delay = random.Next(15);
        Thread.Sleep(TimeSpan.FromSeconds(delay));

        return value1 + value2;
    }
}

I then added a new test project using a Web Performance Test template:

image

I then hit record, closed IE which automatically popped up, and navigated to the service using the WCF Test Client. 

image

I am sure you are not surprised that nothing was recorded.  The problem is that the out of the box Web Performance Test assumes that you are calling a web site so I couldn’t just hit a recording and navigate to a webservice the same way I would navigate to a website.

Instead, I had to right click and add a new web service request.  I then changed the Url property to the service location and tried to run the test.

image

I then binged on Google and ran across a couple of Stack Overflow posts and this nugget on MSDN.  Apparently, I need to use Fiddler to capture the request.  I fired up Fiddler and WCF Test Client (remember the “.” after local host) and sure enough and can make the call and intercept the traffic:

image

I copied the entire request from Fiddler:

image

But I got this when I ran the test I got the same exception.  The problem is that the article assumes an .asmx web service and I am using WCF.  Digging into the article’s code sample, I realized that I needed a Header like so:

image

and I needed to put only the body from Fiddler into the String Body property

Fiddler:

image

WebTest:

image

And green is good

image