Tuesday, 23 October 2012
MSBuild code formatting
Monday, 22 October 2012
Sunday, 1 July 2012
Wednesday, 8 February 2012
A minimal SignalR example
SignalR is an “async signaling library for .NET to help build real-time, multi-user interactive web applications”.
And its very cool. A minimal example…
Add the “SignalR” NuGet package to a web application:
Install-Package SignalR
The HTML:
<html>
<head>
</head>
<body>
<script src="../Scripts/jquery-1.6.4.js"></script>
<script src="../Scripts/jquery.signalR.js"></script>
<script src="../signalr/hubs"></script>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
var chat;
$(function () {
// Created proxy
chat = $.connection.myChat;
// Assign a function to be called by the server
chat.addMessage = onAddMessage;
// Register a function with the button click
$("#broadcast").click(onBroadcast);
// Start the connection
$.connection.hub.start();
});
function onAddMessage(message) {
// Add the message to the list
$('#messages').append('<li>' + message + '</li>');
}
function onBroadcast() {
// Call the chat method on the server
chat.send($('#message').val());
}
</script>
<input type="text" id="message" />
<input type="button" id="broadcast" />
<ul id="messages"></ul>
</div>
</form>
</body>
</html>
The code (C#):
using SignalR.Hubs;
public class MyChat : Hub
{
public void Send(string message)
{
// Call the addMessage method on all clients
Clients.addMessage(message);
}
}
And that is it.
Now you have a real-time chat/message application. View the page in multiple browsers and see all the client receive all the messages in real-time.
Friday, 9 December 2011
The only Windows Azure Pricing Calculator you will ever need
I wrote this to cost up a project: https://skydrive.live.com/view.aspx?cid=0DE849CA9FB5B198&resid=DE849CA9FB5B198%21704
For UK currency.
Unlike every single other calculator out there it allows you to…
- Specify a profile for 5 environments (each profile can differ in number/size of Compute Instances etc):
- Integration Test
- System Test
- User Acceptance Test
- Pre-Production
- Production
- Specify how many hours (per week) you need your Compute Instances for (you might be happy to tear down your hosted services each night – if you’re not using them, why pay?)
Monthly and yearly totals shown.
Friday, 4 November 2011
Windows Azure Pricing
Pay as you go: http://www.microsoft.com/windowsazure/offers/MS-AZR-0003P
What qualifies as a transaction in Windows Azure Storage (you pay per transaction): http://blogs.msdn.com/b/windowsazurestorage/archive/2010/07/09/understanding-windows-azure-storage-billing-bandwidth-transactions-and-capacity.aspx
MSDN Benefits for Windows Azure: http://www.microsoft.com/windowsazure/msdn-benefits/
Thursday, 3 November 2011
Windows Azure and operational cost reduction
One of the things that strikes me the most about using Windows Azure (or most cloud solutions) is the savings you can make with your test environments.
In Windows Azure world, your on-going cost is for your Compute instances (what you deploy your applications to) and your storage. Whether you are using the application or not, you are paying money for your Compute instances and storage to exist. Other costs (Access Control, CDN etc) you pay per use or transaction.
So if you have a system test or user acceptance test environment that you are not using, you can simply delete the Compute instances and any storage artefacts. Then you don’t pay for them.
Contrast this will your on premise applications. You probably have multiple test environments for different projects and those are sitting there, costing you money whether you use them or not.
Some people suggest that Windows Azure (and some other cloud services are not that cheap). I disagree. Let’s say I need a system test environment for 5 days a month. A “Large” Compute instance (4 x 1.6GHz, 7GB RAM, 1000GB storage) costs $0.48/hour. Well 5 days at 8 hours a day (most people don’t work 24/7) costs me $19.20 (this includes the operating system license). I can script the creation of my compute instances and other artefacts very simply, so automatically spinning up or shutting down assets on demand.
So, a pretty meaty server for a system test environment on Windows Azure costs me $19.20 for the 5 days per month I want to use it.
How much is your on premise hardware costing to run for a whole month?
Tuesday, 1 November 2011
PowerShell, MSBuild and 64-bit platforms
If you call PowerShell from MSBuild on a 64-bit platform, you will often get unexpected errors. One such error is as follows:
No snap-ins have been registered for windows powershell version 2
The probable cause is that the MSBuild executable you are running is not 64-bit. On 64-bit platforms you should execute MSBuild from the following location:
%SystemDrive%\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe
Depending on how/what you have installed, your Start Menu shortcuts might be pointing to the 32-bit version.
Monday, 31 October 2011
Elegantly testing for a PowerShell Snap-In
This PowerShell script tries to load the WAPPSCmdlets snap-in, fails silently if the loading of the snap-in fails (if it isn’t installed), advises the user and exits from the script.
if ((Get-PSSnapin | ?{$_.Name -eq "WAPPSCmdlets"}) -eq $null)
{
Add-PSSnapin WAPPSCmdlets -erroraction SilentlyContinue
$SnapIn = GET-PSSnapIn WAPPSCmdlets -erroraction SilentlyContinue
if ($SnapIn -eq $null)
{
Write-Error "To run this script the 'Windows Azure Platform PowerShell Cmdlets' are required."
Write-Error "Please download from 'http://wappowershell.codeplex.com/' and install as a PowerShell Snap-in (not as a Module)."
Exit
}
}
I’m testing for “WAPPSCmdlets” but you could test for any PowerShell Snap-in.
Simples (if you don’t get it).
Saturday, 22 October 2011
Increasing quotas on Windows Azure
By default, your subscription quotas on Windows Azure are as follows:
- Cores – 20
- Hosted Services – 6
- Storage – 5
To increase these you need to submit a request: https://support.microsoft.com/oas/default.aspx?prid=13185&st=1
Options:
- Support topic – “Service Deployment and Developer Portal”
- Sub-topic – “Quota increase”
